]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.4-201308030031.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.4-201308030031.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 2fe6e76..df58221 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,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 @@ -2195,6 +2199,22 @@ 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_sanitize_slab=
256 + 0/1 to disable/enable slab object sanitization (enabled by
257 + default).
258 +
259 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
260 +
261 + pax_extra_latent_entropy
262 + Enable a very simple form of latent entropy extraction
263 + from the first 4GB of memory as the bootmem allocator
264 + passes the memory pages to the buddy allocator.
265 +
266 pcbit= [HW,ISDN]
267
268 pcd. [PARIDE]
269 diff --git a/Makefile b/Makefile
270 index b4df9b2..256e7cc 100644
271 --- a/Makefile
272 +++ b/Makefile
273 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
274
275 HOSTCC = gcc
276 HOSTCXX = g++
277 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
278 -HOSTCXXFLAGS = -O2
279 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
280 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
281 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
282
283 # Decide whether to build built-in, modular, or both.
284 # Normally, just do built-in.
285 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
286 # Rules shared between *config targets and build targets
287
288 # Basic helpers built in scripts/
289 -PHONY += scripts_basic
290 -scripts_basic:
291 +PHONY += scripts_basic gcc-plugins
292 +scripts_basic: gcc-plugins
293 $(Q)$(MAKE) $(build)=scripts/basic
294 $(Q)rm -f .tmp_quiet_recordmcount
295
296 @@ -576,6 +577,65 @@ else
297 KBUILD_CFLAGS += -O2
298 endif
299
300 +ifndef DISABLE_PAX_PLUGINS
301 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
302 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
303 +else
304 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
305 +endif
306 +ifneq ($(PLUGINCC),)
307 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
308 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
309 +endif
310 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
311 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
312 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
313 +endif
314 +ifdef CONFIG_KALLOCSTAT_PLUGIN
315 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
316 +endif
317 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
318 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
319 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
320 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
321 +endif
322 +ifdef CONFIG_CHECKER_PLUGIN
323 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
324 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
325 +endif
326 +endif
327 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
328 +ifdef CONFIG_PAX_SIZE_OVERFLOW
329 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
330 +endif
331 +ifdef CONFIG_PAX_LATENT_ENTROPY
332 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
333 +endif
334 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
335 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
336 +endif
337 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
338 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
339 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
340 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
341 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
342 +ifeq ($(KBUILD_EXTMOD),)
343 +gcc-plugins:
344 + $(Q)$(MAKE) $(build)=tools/gcc
345 +else
346 +gcc-plugins: ;
347 +endif
348 +else
349 +gcc-plugins:
350 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
351 + $(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.))
352 +else
353 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
354 +endif
355 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
356 +endif
357 +endif
358 +
359 include $(srctree)/arch/$(SRCARCH)/Makefile
360
361 ifdef CONFIG_READABLE_ASM
362 @@ -733,7 +793,7 @@ export mod_sign_cmd
363
364
365 ifeq ($(KBUILD_EXTMOD),)
366 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
367 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
368
369 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
370 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
371 @@ -782,6 +842,8 @@ endif
372
373 # The actual objects are generated when descending,
374 # make sure no implicit rule kicks in
375 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
376 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
377 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
378
379 # Handle descending into subdirectories listed in $(vmlinux-dirs)
380 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
381 # Error messages still appears in the original language
382
383 PHONY += $(vmlinux-dirs)
384 -$(vmlinux-dirs): prepare scripts
385 +$(vmlinux-dirs): gcc-plugins prepare scripts
386 $(Q)$(MAKE) $(build)=$@
387
388 # Store (new) KERNELRELASE string in include/config/kernel.release
389 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
390 $(Q)$(MAKE) $(build)=.
391
392 # All the preparing..
393 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
394 prepare: prepare0
395
396 # Generate some files
397 @@ -942,6 +1005,8 @@ all: modules
398 # using awk while concatenating to the final file.
399
400 PHONY += modules
401 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
402 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
403 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
404 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
405 @$(kecho) ' Building modules, stage 2.';
406 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
407
408 # Target to prepare building external modules
409 PHONY += modules_prepare
410 -modules_prepare: prepare scripts
411 +modules_prepare: gcc-plugins prepare scripts
412
413 # Target to install modules
414 PHONY += modules_install
415 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
416 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
417 signing_key.priv signing_key.x509 x509.genkey \
418 extra_certificates signing_key.x509.keyid \
419 - signing_key.x509.signer
420 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
421
422 # clean - Delete most, but leave enough to build external modules
423 #
424 @@ -1063,6 +1128,7 @@ distclean: mrproper
425 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
426 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
427 -o -name '.*.rej' \
428 + -o -name '.*.rej' -o -name '*.so' \
429 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
430 -type f -print | xargs rm -f
431
432 @@ -1223,6 +1289,8 @@ PHONY += $(module-dirs) modules
433 $(module-dirs): crmodverdir $(objtree)/Module.symvers
434 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
435
436 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
437 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
438 modules: $(module-dirs)
439 @$(kecho) ' Building modules, stage 2.';
440 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
441 @@ -1359,17 +1427,21 @@ else
442 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
443 endif
444
445 -%.s: %.c prepare scripts FORCE
446 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
447 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
448 +%.s: %.c gcc-plugins prepare scripts FORCE
449 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
450 %.i: %.c prepare scripts FORCE
451 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
452 -%.o: %.c prepare scripts FORCE
453 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
454 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
455 +%.o: %.c gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.lst: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 -%.s: %.S prepare scripts FORCE
460 +%.s: %.S gcc-plugins prepare scripts FORCE
461 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
462 -%.o: %.S prepare scripts FORCE
463 +%.o: %.S gcc-plugins prepare scripts FORCE
464 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
465 %.symtypes: %.c prepare scripts FORCE
466 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
467 @@ -1379,11 +1451,15 @@ endif
468 $(cmd_crmodverdir)
469 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
470 $(build)=$(build-dir)
471 -%/: prepare scripts FORCE
472 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
473 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
474 +%/: gcc-plugins prepare scripts FORCE
475 $(cmd_crmodverdir)
476 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
477 $(build)=$(build-dir)
478 -%.ko: prepare scripts FORCE
479 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
480 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
481 +%.ko: gcc-plugins prepare scripts FORCE
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir) $(@:.ko=.o)
485 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
486 index c2cbe4f..f7264b4 100644
487 --- a/arch/alpha/include/asm/atomic.h
488 +++ b/arch/alpha/include/asm/atomic.h
489 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
490 #define atomic_dec(v) atomic_sub(1,(v))
491 #define atomic64_dec(v) atomic64_sub(1,(v))
492
493 +#define atomic64_read_unchecked(v) atomic64_read(v)
494 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
495 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
496 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
497 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
498 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
499 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
500 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
501 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
502 +
503 #define smp_mb__before_atomic_dec() smp_mb()
504 #define smp_mb__after_atomic_dec() smp_mb()
505 #define smp_mb__before_atomic_inc() smp_mb()
506 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
507 index ad368a9..fbe0f25 100644
508 --- a/arch/alpha/include/asm/cache.h
509 +++ b/arch/alpha/include/asm/cache.h
510 @@ -4,19 +4,19 @@
511 #ifndef __ARCH_ALPHA_CACHE_H
512 #define __ARCH_ALPHA_CACHE_H
513
514 +#include <linux/const.h>
515
516 /* Bytes per L1 (data) cache line. */
517 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
518 -# define L1_CACHE_BYTES 64
519 # define L1_CACHE_SHIFT 6
520 #else
521 /* Both EV4 and EV5 are write-through, read-allocate,
522 direct-mapped, physical.
523 */
524 -# define L1_CACHE_BYTES 32
525 # define L1_CACHE_SHIFT 5
526 #endif
527
528 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
529 #define SMP_CACHE_BYTES L1_CACHE_BYTES
530
531 #endif
532 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
533 index 968d999..d36b2df 100644
534 --- a/arch/alpha/include/asm/elf.h
535 +++ b/arch/alpha/include/asm/elf.h
536 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
537
538 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
539
540 +#ifdef CONFIG_PAX_ASLR
541 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
542 +
543 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
544 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
545 +#endif
546 +
547 /* $0 is set by ld.so to a pointer to a function which might be
548 registered using atexit. This provides a mean for the dynamic
549 linker to call DT_FINI functions for shared libraries that have
550 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
551 index bc2a0da..8ad11ee 100644
552 --- a/arch/alpha/include/asm/pgalloc.h
553 +++ b/arch/alpha/include/asm/pgalloc.h
554 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
555 pgd_set(pgd, pmd);
556 }
557
558 +static inline void
559 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
560 +{
561 + pgd_populate(mm, pgd, pmd);
562 +}
563 +
564 extern pgd_t *pgd_alloc(struct mm_struct *mm);
565
566 static inline void
567 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
568 index 81a4342..348b927 100644
569 --- a/arch/alpha/include/asm/pgtable.h
570 +++ b/arch/alpha/include/asm/pgtable.h
571 @@ -102,6 +102,17 @@ struct vm_area_struct;
572 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
573 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
574 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
575 +
576 +#ifdef CONFIG_PAX_PAGEEXEC
577 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
578 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
579 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
580 +#else
581 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
582 +# define PAGE_COPY_NOEXEC PAGE_COPY
583 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
584 +#endif
585 +
586 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
587
588 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
589 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
590 index 2fd00b7..cfd5069 100644
591 --- a/arch/alpha/kernel/module.c
592 +++ b/arch/alpha/kernel/module.c
593 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
594
595 /* The small sections were sorted to the end of the segment.
596 The following should definitely cover them. */
597 - gp = (u64)me->module_core + me->core_size - 0x8000;
598 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
599 got = sechdrs[me->arch.gotsecindex].sh_addr;
600
601 for (i = 0; i < n; i++) {
602 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
603 index b9e37ad..44c24e7 100644
604 --- a/arch/alpha/kernel/osf_sys.c
605 +++ b/arch/alpha/kernel/osf_sys.c
606 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
607 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
608
609 static unsigned long
610 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
611 - unsigned long limit)
612 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
613 + unsigned long limit, unsigned long flags)
614 {
615 struct vm_unmapped_area_info info;
616 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
617
618 info.flags = 0;
619 info.length = len;
620 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
621 info.high_limit = limit;
622 info.align_mask = 0;
623 info.align_offset = 0;
624 + info.threadstack_offset = offset;
625 return vm_unmapped_area(&info);
626 }
627
628 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
629 merely specific addresses, but regions of memory -- perhaps
630 this feature should be incorporated into all ports? */
631
632 +#ifdef CONFIG_PAX_RANDMMAP
633 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
634 +#endif
635 +
636 if (addr) {
637 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
638 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
639 if (addr != (unsigned long) -ENOMEM)
640 return addr;
641 }
642
643 /* Next, try allocating at TASK_UNMAPPED_BASE. */
644 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
645 - len, limit);
646 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
647 +
648 if (addr != (unsigned long) -ENOMEM)
649 return addr;
650
651 /* Finally, try allocating in low memory. */
652 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
653 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
654
655 return addr;
656 }
657 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
658 index 0c4132d..88f0d53 100644
659 --- a/arch/alpha/mm/fault.c
660 +++ b/arch/alpha/mm/fault.c
661 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
662 __reload_thread(pcb);
663 }
664
665 +#ifdef CONFIG_PAX_PAGEEXEC
666 +/*
667 + * PaX: decide what to do with offenders (regs->pc = fault address)
668 + *
669 + * returns 1 when task should be killed
670 + * 2 when patched PLT trampoline was detected
671 + * 3 when unpatched PLT trampoline was detected
672 + */
673 +static int pax_handle_fetch_fault(struct pt_regs *regs)
674 +{
675 +
676 +#ifdef CONFIG_PAX_EMUPLT
677 + int err;
678 +
679 + do { /* PaX: patched PLT emulation #1 */
680 + unsigned int ldah, ldq, jmp;
681 +
682 + err = get_user(ldah, (unsigned int *)regs->pc);
683 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
684 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
685 +
686 + if (err)
687 + break;
688 +
689 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
690 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
691 + jmp == 0x6BFB0000U)
692 + {
693 + unsigned long r27, addr;
694 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
695 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
696 +
697 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
698 + err = get_user(r27, (unsigned long *)addr);
699 + if (err)
700 + break;
701 +
702 + regs->r27 = r27;
703 + regs->pc = r27;
704 + return 2;
705 + }
706 + } while (0);
707 +
708 + do { /* PaX: patched PLT emulation #2 */
709 + unsigned int ldah, lda, br;
710 +
711 + err = get_user(ldah, (unsigned int *)regs->pc);
712 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
713 + err |= get_user(br, (unsigned int *)(regs->pc+8));
714 +
715 + if (err)
716 + break;
717 +
718 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
719 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
720 + (br & 0xFFE00000U) == 0xC3E00000U)
721 + {
722 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
723 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
724 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
725 +
726 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
727 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
728 + return 2;
729 + }
730 + } while (0);
731 +
732 + do { /* PaX: unpatched PLT emulation */
733 + unsigned int br;
734 +
735 + err = get_user(br, (unsigned int *)regs->pc);
736 +
737 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
738 + unsigned int br2, ldq, nop, jmp;
739 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
740 +
741 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + err = get_user(br2, (unsigned int *)addr);
743 + err |= get_user(ldq, (unsigned int *)(addr+4));
744 + err |= get_user(nop, (unsigned int *)(addr+8));
745 + err |= get_user(jmp, (unsigned int *)(addr+12));
746 + err |= get_user(resolver, (unsigned long *)(addr+16));
747 +
748 + if (err)
749 + break;
750 +
751 + if (br2 == 0xC3600000U &&
752 + ldq == 0xA77B000CU &&
753 + nop == 0x47FF041FU &&
754 + jmp == 0x6B7B0000U)
755 + {
756 + regs->r28 = regs->pc+4;
757 + regs->r27 = addr+16;
758 + regs->pc = resolver;
759 + return 3;
760 + }
761 + }
762 + } while (0);
763 +#endif
764 +
765 + return 1;
766 +}
767 +
768 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
769 +{
770 + unsigned long i;
771 +
772 + printk(KERN_ERR "PAX: bytes at PC: ");
773 + for (i = 0; i < 5; i++) {
774 + unsigned int c;
775 + if (get_user(c, (unsigned int *)pc+i))
776 + printk(KERN_CONT "???????? ");
777 + else
778 + printk(KERN_CONT "%08x ", c);
779 + }
780 + printk("\n");
781 +}
782 +#endif
783
784 /*
785 * This routine handles page faults. It determines the address,
786 @@ -133,8 +251,29 @@ retry:
787 good_area:
788 si_code = SEGV_ACCERR;
789 if (cause < 0) {
790 - if (!(vma->vm_flags & VM_EXEC))
791 + if (!(vma->vm_flags & VM_EXEC)) {
792 +
793 +#ifdef CONFIG_PAX_PAGEEXEC
794 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
795 + goto bad_area;
796 +
797 + up_read(&mm->mmap_sem);
798 + switch (pax_handle_fetch_fault(regs)) {
799 +
800 +#ifdef CONFIG_PAX_EMUPLT
801 + case 2:
802 + case 3:
803 + return;
804 +#endif
805 +
806 + }
807 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
808 + do_group_exit(SIGKILL);
809 +#else
810 goto bad_area;
811 +#endif
812 +
813 + }
814 } else if (!cause) {
815 /* Allow reads even for write-only mappings */
816 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
817 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
818 index 136f263..f471277 100644
819 --- a/arch/arm/Kconfig
820 +++ b/arch/arm/Kconfig
821 @@ -1766,7 +1766,7 @@ config ALIGNMENT_TRAP
822
823 config UACCESS_WITH_MEMCPY
824 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
825 - depends on MMU
826 + depends on MMU && !PAX_MEMORY_UDEREF
827 default y if CPU_FEROCEON
828 help
829 Implement faster copy_to_user and clear_user methods for CPU
830 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
831 index da1c77d..2ee6056 100644
832 --- a/arch/arm/include/asm/atomic.h
833 +++ b/arch/arm/include/asm/atomic.h
834 @@ -17,17 +17,35 @@
835 #include <asm/barrier.h>
836 #include <asm/cmpxchg.h>
837
838 +#ifdef CONFIG_GENERIC_ATOMIC64
839 +#include <asm-generic/atomic64.h>
840 +#endif
841 +
842 #define ATOMIC_INIT(i) { (i) }
843
844 #ifdef __KERNEL__
845
846 +#define _ASM_EXTABLE(from, to) \
847 +" .pushsection __ex_table,\"a\"\n"\
848 +" .align 3\n" \
849 +" .long " #from ", " #to"\n" \
850 +" .popsection"
851 +
852 /*
853 * On ARM, ordinary assignment (str instruction) doesn't clear the local
854 * strex/ldrex monitor on some implementations. The reason we can use it for
855 * atomic_set() is the clrex or dummy strex done on every exception return.
856 */
857 #define atomic_read(v) (*(volatile int *)&(v)->counter)
858 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
859 +{
860 + return v->counter;
861 +}
862 #define atomic_set(v,i) (((v)->counter) = (i))
863 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
864 +{
865 + v->counter = i;
866 +}
867
868 #if __LINUX_ARM_ARCH__ >= 6
869
870 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
871 int result;
872
873 __asm__ __volatile__("@ atomic_add\n"
874 +"1: ldrex %1, [%3]\n"
875 +" adds %0, %1, %4\n"
876 +
877 +#ifdef CONFIG_PAX_REFCOUNT
878 +" bvc 3f\n"
879 +"2: bkpt 0xf103\n"
880 +"3:\n"
881 +#endif
882 +
883 +" strex %1, %0, [%3]\n"
884 +" teq %1, #0\n"
885 +" bne 1b"
886 +
887 +#ifdef CONFIG_PAX_REFCOUNT
888 +"\n4:\n"
889 + _ASM_EXTABLE(2b, 4b)
890 +#endif
891 +
892 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
893 + : "r" (&v->counter), "Ir" (i)
894 + : "cc");
895 +}
896 +
897 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
898 +{
899 + unsigned long tmp;
900 + int result;
901 +
902 + __asm__ __volatile__("@ atomic_add_unchecked\n"
903 "1: ldrex %0, [%3]\n"
904 " add %0, %0, %4\n"
905 " strex %1, %0, [%3]\n"
906 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
907 smp_mb();
908
909 __asm__ __volatile__("@ atomic_add_return\n"
910 +"1: ldrex %1, [%3]\n"
911 +" adds %0, %1, %4\n"
912 +
913 +#ifdef CONFIG_PAX_REFCOUNT
914 +" bvc 3f\n"
915 +" mov %0, %1\n"
916 +"2: bkpt 0xf103\n"
917 +"3:\n"
918 +#endif
919 +
920 +" strex %1, %0, [%3]\n"
921 +" teq %1, #0\n"
922 +" bne 1b"
923 +
924 +#ifdef CONFIG_PAX_REFCOUNT
925 +"\n4:\n"
926 + _ASM_EXTABLE(2b, 4b)
927 +#endif
928 +
929 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
930 + : "r" (&v->counter), "Ir" (i)
931 + : "cc");
932 +
933 + smp_mb();
934 +
935 + return result;
936 +}
937 +
938 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
939 +{
940 + unsigned long tmp;
941 + int result;
942 +
943 + smp_mb();
944 +
945 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
946 "1: ldrex %0, [%3]\n"
947 " add %0, %0, %4\n"
948 " strex %1, %0, [%3]\n"
949 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
950 int result;
951
952 __asm__ __volatile__("@ atomic_sub\n"
953 +"1: ldrex %1, [%3]\n"
954 +" subs %0, %1, %4\n"
955 +
956 +#ifdef CONFIG_PAX_REFCOUNT
957 +" bvc 3f\n"
958 +"2: bkpt 0xf103\n"
959 +"3:\n"
960 +#endif
961 +
962 +" strex %1, %0, [%3]\n"
963 +" teq %1, #0\n"
964 +" bne 1b"
965 +
966 +#ifdef CONFIG_PAX_REFCOUNT
967 +"\n4:\n"
968 + _ASM_EXTABLE(2b, 4b)
969 +#endif
970 +
971 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
972 + : "r" (&v->counter), "Ir" (i)
973 + : "cc");
974 +}
975 +
976 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
977 +{
978 + unsigned long tmp;
979 + int result;
980 +
981 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
982 "1: ldrex %0, [%3]\n"
983 " sub %0, %0, %4\n"
984 " strex %1, %0, [%3]\n"
985 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
986 smp_mb();
987
988 __asm__ __volatile__("@ atomic_sub_return\n"
989 -"1: ldrex %0, [%3]\n"
990 -" sub %0, %0, %4\n"
991 +"1: ldrex %1, [%3]\n"
992 +" subs %0, %1, %4\n"
993 +
994 +#ifdef CONFIG_PAX_REFCOUNT
995 +" bvc 3f\n"
996 +" mov %0, %1\n"
997 +"2: bkpt 0xf103\n"
998 +"3:\n"
999 +#endif
1000 +
1001 " strex %1, %0, [%3]\n"
1002 " teq %1, #0\n"
1003 " bne 1b"
1004 +
1005 +#ifdef CONFIG_PAX_REFCOUNT
1006 +"\n4:\n"
1007 + _ASM_EXTABLE(2b, 4b)
1008 +#endif
1009 +
1010 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1011 : "r" (&v->counter), "Ir" (i)
1012 : "cc");
1013 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1014 return oldval;
1015 }
1016
1017 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1018 +{
1019 + unsigned long oldval, res;
1020 +
1021 + smp_mb();
1022 +
1023 + do {
1024 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1025 + "ldrex %1, [%3]\n"
1026 + "mov %0, #0\n"
1027 + "teq %1, %4\n"
1028 + "strexeq %0, %5, [%3]\n"
1029 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1030 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1031 + : "cc");
1032 + } while (res);
1033 +
1034 + smp_mb();
1035 +
1036 + return oldval;
1037 +}
1038 +
1039 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1040 {
1041 unsigned long tmp, tmp2;
1042 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1043
1044 return val;
1045 }
1046 +
1047 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1048 +{
1049 + return atomic_add_return(i, v);
1050 +}
1051 +
1052 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1053 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1054 +{
1055 + (void) atomic_add_return(i, v);
1056 +}
1057
1058 static inline int atomic_sub_return(int i, atomic_t *v)
1059 {
1060 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1061 return val;
1062 }
1063 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1064 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1065 +{
1066 + (void) atomic_sub_return(i, v);
1067 +}
1068
1069 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1070 {
1071 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1072 return ret;
1073 }
1074
1075 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1076 +{
1077 + return atomic_cmpxchg(v, old, new);
1078 +}
1079 +
1080 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1081 {
1082 unsigned long flags;
1083 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1084 #endif /* __LINUX_ARM_ARCH__ */
1085
1086 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1087 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1088 +{
1089 + return xchg(&v->counter, new);
1090 +}
1091
1092 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1093 {
1094 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1095 }
1096
1097 #define atomic_inc(v) atomic_add(1, v)
1098 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1099 +{
1100 + atomic_add_unchecked(1, v);
1101 +}
1102 #define atomic_dec(v) atomic_sub(1, v)
1103 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1104 +{
1105 + atomic_sub_unchecked(1, v);
1106 +}
1107
1108 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1109 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1110 +{
1111 + return atomic_add_return_unchecked(1, v) == 0;
1112 +}
1113 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1114 #define atomic_inc_return(v) (atomic_add_return(1, v))
1115 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1116 +{
1117 + return atomic_add_return_unchecked(1, v);
1118 +}
1119 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1120 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1121
1122 @@ -241,6 +428,14 @@ typedef struct {
1123 u64 __aligned(8) counter;
1124 } atomic64_t;
1125
1126 +#ifdef CONFIG_PAX_REFCOUNT
1127 +typedef struct {
1128 + u64 __aligned(8) counter;
1129 +} atomic64_unchecked_t;
1130 +#else
1131 +typedef atomic64_t atomic64_unchecked_t;
1132 +#endif
1133 +
1134 #define ATOMIC64_INIT(i) { (i) }
1135
1136 #ifdef CONFIG_ARM_LPAE
1137 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1138 return result;
1139 }
1140
1141 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1142 +{
1143 + u64 result;
1144 +
1145 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1146 +" ldrd %0, %H0, [%1]"
1147 + : "=&r" (result)
1148 + : "r" (&v->counter), "Qo" (v->counter)
1149 + );
1150 +
1151 + return result;
1152 +}
1153 +
1154 static inline void atomic64_set(atomic64_t *v, u64 i)
1155 {
1156 __asm__ __volatile__("@ atomic64_set\n"
1157 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1158 : "r" (&v->counter), "r" (i)
1159 );
1160 }
1161 +
1162 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1163 +{
1164 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1165 +" strd %2, %H2, [%1]"
1166 + : "=Qo" (v->counter)
1167 + : "r" (&v->counter), "r" (i)
1168 + );
1169 +}
1170 #else
1171 static inline u64 atomic64_read(const atomic64_t *v)
1172 {
1173 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1174 return result;
1175 }
1176
1177 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1178 +{
1179 + u64 result;
1180 +
1181 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1182 +" ldrexd %0, %H0, [%1]"
1183 + : "=&r" (result)
1184 + : "r" (&v->counter), "Qo" (v->counter)
1185 + );
1186 +
1187 + return result;
1188 +}
1189 +
1190 static inline void atomic64_set(atomic64_t *v, u64 i)
1191 {
1192 u64 tmp;
1193 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1194 : "r" (&v->counter), "r" (i)
1195 : "cc");
1196 }
1197 +
1198 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1199 +{
1200 + u64 tmp;
1201 +
1202 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1203 +"1: ldrexd %0, %H0, [%2]\n"
1204 +" strexd %0, %3, %H3, [%2]\n"
1205 +" teq %0, #0\n"
1206 +" bne 1b"
1207 + : "=&r" (tmp), "=Qo" (v->counter)
1208 + : "r" (&v->counter), "r" (i)
1209 + : "cc");
1210 +}
1211 +
1212 #endif
1213
1214 static inline void atomic64_add(u64 i, atomic64_t *v)
1215 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1216 __asm__ __volatile__("@ atomic64_add\n"
1217 "1: ldrexd %0, %H0, [%3]\n"
1218 " adds %0, %0, %4\n"
1219 +" adcs %H0, %H0, %H4\n"
1220 +
1221 +#ifdef CONFIG_PAX_REFCOUNT
1222 +" bvc 3f\n"
1223 +"2: bkpt 0xf103\n"
1224 +"3:\n"
1225 +#endif
1226 +
1227 +" strexd %1, %0, %H0, [%3]\n"
1228 +" teq %1, #0\n"
1229 +" bne 1b"
1230 +
1231 +#ifdef CONFIG_PAX_REFCOUNT
1232 +"\n4:\n"
1233 + _ASM_EXTABLE(2b, 4b)
1234 +#endif
1235 +
1236 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1237 + : "r" (&v->counter), "r" (i)
1238 + : "cc");
1239 +}
1240 +
1241 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1242 +{
1243 + u64 result;
1244 + unsigned long tmp;
1245 +
1246 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1247 +"1: ldrexd %0, %H0, [%3]\n"
1248 +" adds %0, %0, %4\n"
1249 " adc %H0, %H0, %H4\n"
1250 " strexd %1, %0, %H0, [%3]\n"
1251 " teq %1, #0\n"
1252 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1253
1254 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1255 {
1256 - u64 result;
1257 - unsigned long tmp;
1258 + u64 result, tmp;
1259
1260 smp_mb();
1261
1262 __asm__ __volatile__("@ atomic64_add_return\n"
1263 +"1: ldrexd %1, %H1, [%3]\n"
1264 +" adds %0, %1, %4\n"
1265 +" adcs %H0, %H1, %H4\n"
1266 +
1267 +#ifdef CONFIG_PAX_REFCOUNT
1268 +" bvc 3f\n"
1269 +" mov %0, %1\n"
1270 +" mov %H0, %H1\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 + smp_mb();
1289 +
1290 + return result;
1291 +}
1292 +
1293 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1294 +{
1295 + u64 result;
1296 + unsigned long tmp;
1297 +
1298 + smp_mb();
1299 +
1300 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1301 "1: ldrexd %0, %H0, [%3]\n"
1302 " adds %0, %0, %4\n"
1303 " adc %H0, %H0, %H4\n"
1304 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1305 __asm__ __volatile__("@ atomic64_sub\n"
1306 "1: ldrexd %0, %H0, [%3]\n"
1307 " subs %0, %0, %4\n"
1308 +" sbcs %H0, %H0, %H4\n"
1309 +
1310 +#ifdef CONFIG_PAX_REFCOUNT
1311 +" bvc 3f\n"
1312 +"2: bkpt 0xf103\n"
1313 +"3:\n"
1314 +#endif
1315 +
1316 +" strexd %1, %0, %H0, [%3]\n"
1317 +" teq %1, #0\n"
1318 +" bne 1b"
1319 +
1320 +#ifdef CONFIG_PAX_REFCOUNT
1321 +"\n4:\n"
1322 + _ASM_EXTABLE(2b, 4b)
1323 +#endif
1324 +
1325 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1326 + : "r" (&v->counter), "r" (i)
1327 + : "cc");
1328 +}
1329 +
1330 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1331 +{
1332 + u64 result;
1333 + unsigned long tmp;
1334 +
1335 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1336 +"1: ldrexd %0, %H0, [%3]\n"
1337 +" subs %0, %0, %4\n"
1338 " sbc %H0, %H0, %H4\n"
1339 " strexd %1, %0, %H0, [%3]\n"
1340 " teq %1, #0\n"
1341 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1342
1343 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1344 {
1345 - u64 result;
1346 - unsigned long tmp;
1347 + u64 result, tmp;
1348
1349 smp_mb();
1350
1351 __asm__ __volatile__("@ atomic64_sub_return\n"
1352 -"1: ldrexd %0, %H0, [%3]\n"
1353 -" subs %0, %0, %4\n"
1354 -" sbc %H0, %H0, %H4\n"
1355 +"1: ldrexd %1, %H1, [%3]\n"
1356 +" subs %0, %1, %4\n"
1357 +" sbcs %H0, %H1, %H4\n"
1358 +
1359 +#ifdef CONFIG_PAX_REFCOUNT
1360 +" bvc 3f\n"
1361 +" mov %0, %1\n"
1362 +" mov %H0, %H1\n"
1363 +"2: bkpt 0xf103\n"
1364 +"3:\n"
1365 +#endif
1366 +
1367 " strexd %1, %0, %H0, [%3]\n"
1368 " teq %1, #0\n"
1369 " bne 1b"
1370 +
1371 +#ifdef CONFIG_PAX_REFCOUNT
1372 +"\n4:\n"
1373 + _ASM_EXTABLE(2b, 4b)
1374 +#endif
1375 +
1376 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1377 : "r" (&v->counter), "r" (i)
1378 : "cc");
1379 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1380 return oldval;
1381 }
1382
1383 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1384 +{
1385 + u64 oldval;
1386 + unsigned long res;
1387 +
1388 + smp_mb();
1389 +
1390 + do {
1391 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1392 + "ldrexd %1, %H1, [%3]\n"
1393 + "mov %0, #0\n"
1394 + "teq %1, %4\n"
1395 + "teqeq %H1, %H4\n"
1396 + "strexdeq %0, %5, %H5, [%3]"
1397 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1398 + : "r" (&ptr->counter), "r" (old), "r" (new)
1399 + : "cc");
1400 + } while (res);
1401 +
1402 + smp_mb();
1403 +
1404 + return oldval;
1405 +}
1406 +
1407 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1408 {
1409 u64 result;
1410 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1411
1412 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1413 {
1414 - u64 result;
1415 - unsigned long tmp;
1416 + u64 result, tmp;
1417
1418 smp_mb();
1419
1420 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1421 -"1: ldrexd %0, %H0, [%3]\n"
1422 -" subs %0, %0, #1\n"
1423 -" sbc %H0, %H0, #0\n"
1424 +"1: ldrexd %1, %H1, [%3]\n"
1425 +" subs %0, %1, #1\n"
1426 +" sbcs %H0, %H1, #0\n"
1427 +
1428 +#ifdef CONFIG_PAX_REFCOUNT
1429 +" bvc 3f\n"
1430 +" mov %0, %1\n"
1431 +" mov %H0, %H1\n"
1432 +"2: bkpt 0xf103\n"
1433 +"3:\n"
1434 +#endif
1435 +
1436 " teq %H0, #0\n"
1437 -" bmi 2f\n"
1438 +" bmi 4f\n"
1439 " strexd %1, %0, %H0, [%3]\n"
1440 " teq %1, #0\n"
1441 " bne 1b\n"
1442 -"2:"
1443 +"4:\n"
1444 +
1445 +#ifdef CONFIG_PAX_REFCOUNT
1446 + _ASM_EXTABLE(2b, 4b)
1447 +#endif
1448 +
1449 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1450 : "r" (&v->counter)
1451 : "cc");
1452 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1453 " teq %0, %5\n"
1454 " teqeq %H0, %H5\n"
1455 " moveq %1, #0\n"
1456 -" beq 2f\n"
1457 +" beq 4f\n"
1458 " adds %0, %0, %6\n"
1459 -" adc %H0, %H0, %H6\n"
1460 +" adcs %H0, %H0, %H6\n"
1461 +
1462 +#ifdef CONFIG_PAX_REFCOUNT
1463 +" bvc 3f\n"
1464 +"2: bkpt 0xf103\n"
1465 +"3:\n"
1466 +#endif
1467 +
1468 " strexd %2, %0, %H0, [%4]\n"
1469 " teq %2, #0\n"
1470 " bne 1b\n"
1471 -"2:"
1472 +"4:\n"
1473 +
1474 +#ifdef CONFIG_PAX_REFCOUNT
1475 + _ASM_EXTABLE(2b, 4b)
1476 +#endif
1477 +
1478 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1479 : "r" (&v->counter), "r" (u), "r" (a)
1480 : "cc");
1481 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1482
1483 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1484 #define atomic64_inc(v) atomic64_add(1LL, (v))
1485 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1486 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1487 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1488 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1489 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1490 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1491 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1492 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1493 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1494 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1495 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1496 index 75fe66b..ba3dee4 100644
1497 --- a/arch/arm/include/asm/cache.h
1498 +++ b/arch/arm/include/asm/cache.h
1499 @@ -4,8 +4,10 @@
1500 #ifndef __ASMARM_CACHE_H
1501 #define __ASMARM_CACHE_H
1502
1503 +#include <linux/const.h>
1504 +
1505 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1506 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1507 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1508
1509 /*
1510 * Memory returned by kmalloc() may be used for DMA, so we must make
1511 @@ -24,5 +26,6 @@
1512 #endif
1513
1514 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1515 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1516
1517 #endif
1518 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1519 index 17d0ae8..014e350 100644
1520 --- a/arch/arm/include/asm/cacheflush.h
1521 +++ b/arch/arm/include/asm/cacheflush.h
1522 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1523 void (*dma_unmap_area)(const void *, size_t, int);
1524
1525 void (*dma_flush_range)(const void *, const void *);
1526 -};
1527 +} __no_const;
1528
1529 /*
1530 * Select the calling method
1531 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1532 index 6dcc164..b14d917 100644
1533 --- a/arch/arm/include/asm/checksum.h
1534 +++ b/arch/arm/include/asm/checksum.h
1535 @@ -37,7 +37,19 @@ __wsum
1536 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1537
1538 __wsum
1539 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1540 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1541 +
1542 +static inline __wsum
1543 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1544 +{
1545 + __wsum ret;
1546 + pax_open_userland();
1547 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1548 + pax_close_userland();
1549 + return ret;
1550 +}
1551 +
1552 +
1553
1554 /*
1555 * Fold a partial checksum without adding pseudo headers
1556 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1557 index 4f009c1..466c59b 100644
1558 --- a/arch/arm/include/asm/cmpxchg.h
1559 +++ b/arch/arm/include/asm/cmpxchg.h
1560 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1561
1562 #define xchg(ptr,x) \
1563 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1564 +#define xchg_unchecked(ptr,x) \
1565 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1566
1567 #include <asm-generic/cmpxchg-local.h>
1568
1569 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1570 index 6ddbe44..b5e38b1 100644
1571 --- a/arch/arm/include/asm/domain.h
1572 +++ b/arch/arm/include/asm/domain.h
1573 @@ -48,18 +48,37 @@
1574 * Domain types
1575 */
1576 #define DOMAIN_NOACCESS 0
1577 -#define DOMAIN_CLIENT 1
1578 #ifdef CONFIG_CPU_USE_DOMAINS
1579 +#define DOMAIN_USERCLIENT 1
1580 +#define DOMAIN_KERNELCLIENT 1
1581 #define DOMAIN_MANAGER 3
1582 +#define DOMAIN_VECTORS DOMAIN_USER
1583 #else
1584 +
1585 +#ifdef CONFIG_PAX_KERNEXEC
1586 #define DOMAIN_MANAGER 1
1587 +#define DOMAIN_KERNEXEC 3
1588 +#else
1589 +#define DOMAIN_MANAGER 1
1590 +#endif
1591 +
1592 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1593 +#define DOMAIN_USERCLIENT 0
1594 +#define DOMAIN_UDEREF 1
1595 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1596 +#else
1597 +#define DOMAIN_USERCLIENT 1
1598 +#define DOMAIN_VECTORS DOMAIN_USER
1599 +#endif
1600 +#define DOMAIN_KERNELCLIENT 1
1601 +
1602 #endif
1603
1604 #define domain_val(dom,type) ((type) << (2*(dom)))
1605
1606 #ifndef __ASSEMBLY__
1607
1608 -#ifdef CONFIG_CPU_USE_DOMAINS
1609 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1610 static inline void set_domain(unsigned val)
1611 {
1612 asm volatile(
1613 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1614 isb();
1615 }
1616
1617 -#define modify_domain(dom,type) \
1618 - do { \
1619 - struct thread_info *thread = current_thread_info(); \
1620 - unsigned int domain = thread->cpu_domain; \
1621 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1622 - thread->cpu_domain = domain | domain_val(dom, type); \
1623 - set_domain(thread->cpu_domain); \
1624 - } while (0)
1625 -
1626 +extern void modify_domain(unsigned int dom, unsigned int type);
1627 #else
1628 static inline void set_domain(unsigned val) { }
1629 static inline void modify_domain(unsigned dom, unsigned type) { }
1630 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1631 index 38050b1..9d90e8b 100644
1632 --- a/arch/arm/include/asm/elf.h
1633 +++ b/arch/arm/include/asm/elf.h
1634 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1635 the loader. We need to make sure that it is out of the way of the program
1636 that it will "exec", and that there is sufficient room for the brk. */
1637
1638 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1639 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1640 +
1641 +#ifdef CONFIG_PAX_ASLR
1642 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1643 +
1644 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1645 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1646 +#endif
1647
1648 /* When the program starts, a1 contains a pointer to a function to be
1649 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1650 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1651 extern void elf_set_personality(const struct elf32_hdr *);
1652 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1653
1654 -struct mm_struct;
1655 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1656 -#define arch_randomize_brk arch_randomize_brk
1657 -
1658 #endif
1659 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1660 index de53547..52b9a28 100644
1661 --- a/arch/arm/include/asm/fncpy.h
1662 +++ b/arch/arm/include/asm/fncpy.h
1663 @@ -81,7 +81,9 @@
1664 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1665 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1666 \
1667 + pax_open_kernel(); \
1668 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1669 + pax_close_kernel(); \
1670 flush_icache_range((unsigned long)(dest_buf), \
1671 (unsigned long)(dest_buf) + (size)); \
1672 \
1673 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1674 index e42cf59..7b94b8f 100644
1675 --- a/arch/arm/include/asm/futex.h
1676 +++ b/arch/arm/include/asm/futex.h
1677 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1678 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1679 return -EFAULT;
1680
1681 + pax_open_userland();
1682 +
1683 smp_mb();
1684 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1685 "1: ldrex %1, [%4]\n"
1686 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1687 : "cc", "memory");
1688 smp_mb();
1689
1690 + pax_close_userland();
1691 +
1692 *uval = val;
1693 return ret;
1694 }
1695 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1696 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1697 return -EFAULT;
1698
1699 + pax_open_userland();
1700 +
1701 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1702 "1: " TUSER(ldr) " %1, [%4]\n"
1703 " teq %1, %2\n"
1704 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1705 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1706 : "cc", "memory");
1707
1708 + pax_close_userland();
1709 +
1710 *uval = val;
1711 return ret;
1712 }
1713 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1714 return -EFAULT;
1715
1716 pagefault_disable(); /* implies preempt_disable() */
1717 + pax_open_userland();
1718
1719 switch (op) {
1720 case FUTEX_OP_SET:
1721 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1722 ret = -ENOSYS;
1723 }
1724
1725 + pax_close_userland();
1726 pagefault_enable(); /* subsumes preempt_enable() */
1727
1728 if (!ret) {
1729 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1730 index 83eb2f7..ed77159 100644
1731 --- a/arch/arm/include/asm/kmap_types.h
1732 +++ b/arch/arm/include/asm/kmap_types.h
1733 @@ -4,6 +4,6 @@
1734 /*
1735 * This is the "bare minimum". AIO seems to require this.
1736 */
1737 -#define KM_TYPE_NR 16
1738 +#define KM_TYPE_NR 17
1739
1740 #endif
1741 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1742 index 9e614a1..3302cca 100644
1743 --- a/arch/arm/include/asm/mach/dma.h
1744 +++ b/arch/arm/include/asm/mach/dma.h
1745 @@ -22,7 +22,7 @@ struct dma_ops {
1746 int (*residue)(unsigned int, dma_t *); /* optional */
1747 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1748 const char *type;
1749 -};
1750 +} __do_const;
1751
1752 struct dma_struct {
1753 void *addr; /* single DMA address */
1754 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1755 index 2fe141f..192dc01 100644
1756 --- a/arch/arm/include/asm/mach/map.h
1757 +++ b/arch/arm/include/asm/mach/map.h
1758 @@ -27,13 +27,16 @@ struct map_desc {
1759 #define MT_MINICLEAN 6
1760 #define MT_LOW_VECTORS 7
1761 #define MT_HIGH_VECTORS 8
1762 -#define MT_MEMORY 9
1763 +#define MT_MEMORY_RWX 9
1764 #define MT_ROM 10
1765 -#define MT_MEMORY_NONCACHED 11
1766 +#define MT_MEMORY_NONCACHED_RX 11
1767 #define MT_MEMORY_DTCM 12
1768 #define MT_MEMORY_ITCM 13
1769 #define MT_MEMORY_SO 14
1770 #define MT_MEMORY_DMA_READY 15
1771 +#define MT_MEMORY_RW 16
1772 +#define MT_MEMORY_RX 17
1773 +#define MT_MEMORY_NONCACHED_RW 18
1774
1775 #ifdef CONFIG_MMU
1776 extern void iotable_init(struct map_desc *, int);
1777 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1778 index 12f71a1..04e063c 100644
1779 --- a/arch/arm/include/asm/outercache.h
1780 +++ b/arch/arm/include/asm/outercache.h
1781 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1782 #endif
1783 void (*set_debug)(unsigned long);
1784 void (*resume)(void);
1785 -};
1786 +} __no_const;
1787
1788 #ifdef CONFIG_OUTER_CACHE
1789
1790 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1791 index 812a494..71fc0b6 100644
1792 --- a/arch/arm/include/asm/page.h
1793 +++ b/arch/arm/include/asm/page.h
1794 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1795 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1796 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1797 unsigned long vaddr, struct vm_area_struct *vma);
1798 -};
1799 +} __no_const;
1800
1801 #ifdef MULTI_USER
1802 extern struct cpu_user_fns cpu_user;
1803 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1804 index 943504f..c37a730 100644
1805 --- a/arch/arm/include/asm/pgalloc.h
1806 +++ b/arch/arm/include/asm/pgalloc.h
1807 @@ -17,6 +17,7 @@
1808 #include <asm/processor.h>
1809 #include <asm/cacheflush.h>
1810 #include <asm/tlbflush.h>
1811 +#include <asm/system_info.h>
1812
1813 #define check_pgt_cache() do { } while (0)
1814
1815 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1816 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1817 }
1818
1819 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1820 +{
1821 + pud_populate(mm, pud, pmd);
1822 +}
1823 +
1824 #else /* !CONFIG_ARM_LPAE */
1825
1826 /*
1827 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1828 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1829 #define pmd_free(mm, pmd) do { } while (0)
1830 #define pud_populate(mm,pmd,pte) BUG()
1831 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1832
1833 #endif /* CONFIG_ARM_LPAE */
1834
1835 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1836 __free_page(pte);
1837 }
1838
1839 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1840 +{
1841 +#ifdef CONFIG_ARM_LPAE
1842 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1843 +#else
1844 + if (addr & SECTION_SIZE)
1845 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1846 + else
1847 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1848 +#endif
1849 + flush_pmd_entry(pmdp);
1850 +}
1851 +
1852 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1853 pmdval_t prot)
1854 {
1855 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1856 static inline void
1857 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1858 {
1859 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1860 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1861 }
1862 #define pmd_pgtable(pmd) pmd_page(pmd)
1863
1864 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1865 index 5cfba15..f415e1a 100644
1866 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1867 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1868 @@ -20,12 +20,15 @@
1869 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1870 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1871 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1872 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1873 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1874 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1875 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1876 +
1877 /*
1878 * - section
1879 */
1880 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1881 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1882 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1883 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1884 @@ -37,6 +40,7 @@
1885 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1886 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1887 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1888 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1889
1890 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1891 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1892 @@ -66,6 +70,7 @@
1893 * - extended small page/tiny page
1894 */
1895 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1896 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1897 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1898 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1899 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1900 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1901 index f97ee02..07f1be5 100644
1902 --- a/arch/arm/include/asm/pgtable-2level.h
1903 +++ b/arch/arm/include/asm/pgtable-2level.h
1904 @@ -125,6 +125,7 @@
1905 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1906 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1907 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1908 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1909
1910 /*
1911 * These are the memory types, defined to be compatible with
1912 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1913 index 18f5cef..25b8f43 100644
1914 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1915 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1916 @@ -41,6 +41,7 @@
1917 */
1918 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1919 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1920 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1921 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1922 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1923 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1924 @@ -71,6 +72,7 @@
1925 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1926 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1927 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1928 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1929 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1930
1931 /*
1932 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1933 index 86b8fe3..e25f975 100644
1934 --- a/arch/arm/include/asm/pgtable-3level.h
1935 +++ b/arch/arm/include/asm/pgtable-3level.h
1936 @@ -74,6 +74,7 @@
1937 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1938 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1939 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1940 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1941 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1942 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1943 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1944 @@ -82,6 +83,7 @@
1945 /*
1946 * To be used in assembly code with the upper page attributes.
1947 */
1948 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1949 #define L_PTE_XN_HIGH (1 << (54 - 32))
1950 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1951
1952 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1953 index 9bcd262..fba731c 100644
1954 --- a/arch/arm/include/asm/pgtable.h
1955 +++ b/arch/arm/include/asm/pgtable.h
1956 @@ -30,6 +30,9 @@
1957 #include <asm/pgtable-2level.h>
1958 #endif
1959
1960 +#define ktla_ktva(addr) (addr)
1961 +#define ktva_ktla(addr) (addr)
1962 +
1963 /*
1964 * Just any arbitrary offset to the start of the vmalloc VM area: the
1965 * current 8MB value just means that there will be a 8MB "hole" after the
1966 @@ -45,6 +48,9 @@
1967 #define LIBRARY_TEXT_START 0x0c000000
1968
1969 #ifndef __ASSEMBLY__
1970 +extern pteval_t __supported_pte_mask;
1971 +extern pmdval_t __supported_pmd_mask;
1972 +
1973 extern void __pte_error(const char *file, int line, pte_t);
1974 extern void __pmd_error(const char *file, int line, pmd_t);
1975 extern void __pgd_error(const char *file, int line, pgd_t);
1976 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1977 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1978 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1979
1980 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1981 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1982 +
1983 +#ifdef CONFIG_PAX_KERNEXEC
1984 +#include <asm/domain.h>
1985 +#include <linux/thread_info.h>
1986 +#include <linux/preempt.h>
1987 +#endif
1988 +
1989 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1990 +static inline int test_domain(int domain, int domaintype)
1991 +{
1992 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
1993 +}
1994 +#endif
1995 +
1996 +#ifdef CONFIG_PAX_KERNEXEC
1997 +static inline unsigned long pax_open_kernel(void) {
1998 +#ifdef CONFIG_ARM_LPAE
1999 + /* TODO */
2000 +#else
2001 + preempt_disable();
2002 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2003 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2004 +#endif
2005 + return 0;
2006 +}
2007 +
2008 +static inline unsigned long pax_close_kernel(void) {
2009 +#ifdef CONFIG_ARM_LPAE
2010 + /* TODO */
2011 +#else
2012 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2013 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2014 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2015 + preempt_enable_no_resched();
2016 +#endif
2017 + return 0;
2018 +}
2019 +#else
2020 +static inline unsigned long pax_open_kernel(void) { return 0; }
2021 +static inline unsigned long pax_close_kernel(void) { return 0; }
2022 +#endif
2023 +
2024 /*
2025 * This is the lowest virtual address we can permit any user space
2026 * mapping to be mapped at. This is particularly important for
2027 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2028 /*
2029 * The pgprot_* and protection_map entries will be fixed up in runtime
2030 * to include the cachable and bufferable bits based on memory policy,
2031 - * as well as any architecture dependent bits like global/ASID and SMP
2032 - * shared mapping bits.
2033 + * as well as any architecture dependent bits like global/ASID, PXN,
2034 + * and SMP shared mapping bits.
2035 */
2036 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2037
2038 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2039 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2040 {
2041 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2042 - L_PTE_NONE | L_PTE_VALID;
2043 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2044 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2045 return pte;
2046 }
2047 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2048 index f3628fb..a0672dd 100644
2049 --- a/arch/arm/include/asm/proc-fns.h
2050 +++ b/arch/arm/include/asm/proc-fns.h
2051 @@ -75,7 +75,7 @@ extern struct processor {
2052 unsigned int suspend_size;
2053 void (*do_suspend)(void *);
2054 void (*do_resume)(void *);
2055 -} processor;
2056 +} __do_const processor;
2057
2058 #ifndef MULTI_CPU
2059 extern void cpu_proc_init(void);
2060 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2061 index 06e7d50..8a8e251 100644
2062 --- a/arch/arm/include/asm/processor.h
2063 +++ b/arch/arm/include/asm/processor.h
2064 @@ -65,9 +65,8 @@ struct thread_struct {
2065 regs->ARM_cpsr |= PSR_ENDSTATE; \
2066 regs->ARM_pc = pc & ~1; /* pc */ \
2067 regs->ARM_sp = sp; /* sp */ \
2068 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2069 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2070 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2071 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2072 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2073 nommu_start_thread(regs); \
2074 })
2075
2076 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2077 index ce0dbe7..c085b6f 100644
2078 --- a/arch/arm/include/asm/psci.h
2079 +++ b/arch/arm/include/asm/psci.h
2080 @@ -29,7 +29,7 @@ struct psci_operations {
2081 int (*cpu_off)(struct psci_power_state state);
2082 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2083 int (*migrate)(unsigned long cpuid);
2084 -};
2085 +} __no_const;
2086
2087 extern struct psci_operations psci_ops;
2088
2089 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2090 index d3a22be..3a69ad5 100644
2091 --- a/arch/arm/include/asm/smp.h
2092 +++ b/arch/arm/include/asm/smp.h
2093 @@ -107,7 +107,7 @@ struct smp_operations {
2094 int (*cpu_disable)(unsigned int cpu);
2095 #endif
2096 #endif
2097 -};
2098 +} __no_const;
2099
2100 /*
2101 * set platform specific SMP operations
2102 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2103 index 1995d1a..76693a2 100644
2104 --- a/arch/arm/include/asm/thread_info.h
2105 +++ b/arch/arm/include/asm/thread_info.h
2106 @@ -77,9 +77,9 @@ struct thread_info {
2107 .flags = 0, \
2108 .preempt_count = INIT_PREEMPT_COUNT, \
2109 .addr_limit = KERNEL_DS, \
2110 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2111 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2112 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2113 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2114 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2115 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2116 .restart_block = { \
2117 .fn = do_no_restart_syscall, \
2118 }, \
2119 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2120 #define TIF_SYSCALL_AUDIT 9
2121 #define TIF_SYSCALL_TRACEPOINT 10
2122 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2123 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2124 +/* within 8 bits of TIF_SYSCALL_TRACE
2125 + * to meet flexible second operand requirements
2126 + */
2127 +#define TIF_GRSEC_SETXID 12
2128 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2129 #define TIF_USING_IWMMXT 17
2130 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2131 #define TIF_RESTORE_SIGMASK 20
2132 @@ -166,10 +170,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2133 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2134 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2135 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2136 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2137
2138 /* Checks for any syscall work in entry-common.S */
2139 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2140 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2141 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2142
2143 /*
2144 * Change these and you break ASM code in entry-common.S
2145 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2146 index 7e1f760..d42d7f8 100644
2147 --- a/arch/arm/include/asm/uaccess.h
2148 +++ b/arch/arm/include/asm/uaccess.h
2149 @@ -18,6 +18,7 @@
2150 #include <asm/domain.h>
2151 #include <asm/unified.h>
2152 #include <asm/compiler.h>
2153 +#include <asm/pgtable.h>
2154
2155 #define VERIFY_READ 0
2156 #define VERIFY_WRITE 1
2157 @@ -63,11 +64,35 @@ extern int __put_user_bad(void);
2158 static inline void set_fs(mm_segment_t fs)
2159 {
2160 current_thread_info()->addr_limit = fs;
2161 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2162 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2163 }
2164
2165 #define segment_eq(a,b) ((a) == (b))
2166
2167 +static inline void pax_open_userland(void)
2168 +{
2169 +
2170 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2171 + if (segment_eq(get_fs(), USER_DS)) {
2172 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2173 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2174 + }
2175 +#endif
2176 +
2177 +}
2178 +
2179 +static inline void pax_close_userland(void)
2180 +{
2181 +
2182 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2183 + if (segment_eq(get_fs(), USER_DS)) {
2184 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2185 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2186 + }
2187 +#endif
2188 +
2189 +}
2190 +
2191 #define __addr_ok(addr) ({ \
2192 unsigned long flag; \
2193 __asm__("cmp %2, %0; movlo %0, #0" \
2194 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2195
2196 #define get_user(x,p) \
2197 ({ \
2198 + int __e; \
2199 might_fault(); \
2200 - __get_user_check(x,p); \
2201 + pax_open_userland(); \
2202 + __e = __get_user_check(x,p); \
2203 + pax_close_userland(); \
2204 + __e; \
2205 })
2206
2207 extern int __put_user_1(void *, unsigned int);
2208 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2209
2210 #define put_user(x,p) \
2211 ({ \
2212 + int __e; \
2213 might_fault(); \
2214 - __put_user_check(x,p); \
2215 + pax_open_userland(); \
2216 + __e = __put_user_check(x,p); \
2217 + pax_close_userland(); \
2218 + __e; \
2219 })
2220
2221 #else /* CONFIG_MMU */
2222 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2223 #define __get_user(x,ptr) \
2224 ({ \
2225 long __gu_err = 0; \
2226 + pax_open_userland(); \
2227 __get_user_err((x),(ptr),__gu_err); \
2228 + pax_close_userland(); \
2229 __gu_err; \
2230 })
2231
2232 #define __get_user_error(x,ptr,err) \
2233 ({ \
2234 + pax_open_userland(); \
2235 __get_user_err((x),(ptr),err); \
2236 + pax_close_userland(); \
2237 (void) 0; \
2238 })
2239
2240 @@ -312,13 +349,17 @@ do { \
2241 #define __put_user(x,ptr) \
2242 ({ \
2243 long __pu_err = 0; \
2244 + pax_open_userland(); \
2245 __put_user_err((x),(ptr),__pu_err); \
2246 + pax_close_userland(); \
2247 __pu_err; \
2248 })
2249
2250 #define __put_user_error(x,ptr,err) \
2251 ({ \
2252 + pax_open_userland(); \
2253 __put_user_err((x),(ptr),err); \
2254 + pax_close_userland(); \
2255 (void) 0; \
2256 })
2257
2258 @@ -418,11 +459,44 @@ do { \
2259
2260
2261 #ifdef CONFIG_MMU
2262 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2263 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2264 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2265 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2266 +
2267 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2268 +{
2269 + unsigned long ret;
2270 +
2271 + check_object_size(to, n, false);
2272 + pax_open_userland();
2273 + ret = ___copy_from_user(to, from, n);
2274 + pax_close_userland();
2275 + return ret;
2276 +}
2277 +
2278 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2279 +{
2280 + unsigned long ret;
2281 +
2282 + check_object_size(from, n, true);
2283 + pax_open_userland();
2284 + ret = ___copy_to_user(to, from, n);
2285 + pax_close_userland();
2286 + return ret;
2287 +}
2288 +
2289 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2290 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2291 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2292 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2293 +
2294 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2295 +{
2296 + unsigned long ret;
2297 + pax_open_userland();
2298 + ret = ___clear_user(addr, n);
2299 + pax_close_userland();
2300 + return ret;
2301 +}
2302 +
2303 #else
2304 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2305 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2306 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2307
2308 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2309 {
2310 + if ((long)n < 0)
2311 + return n;
2312 +
2313 if (access_ok(VERIFY_READ, from, n))
2314 n = __copy_from_user(to, from, n);
2315 else /* security hole - plug it */
2316 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2317
2318 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2319 {
2320 + if ((long)n < 0)
2321 + return n;
2322 +
2323 if (access_ok(VERIFY_WRITE, to, n))
2324 n = __copy_to_user(to, from, n);
2325 return n;
2326 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2327 index 96ee092..37f1844 100644
2328 --- a/arch/arm/include/uapi/asm/ptrace.h
2329 +++ b/arch/arm/include/uapi/asm/ptrace.h
2330 @@ -73,7 +73,7 @@
2331 * ARMv7 groups of PSR bits
2332 */
2333 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2334 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2335 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2336 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2337 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2338
2339 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2340 index 60d3b73..e5a0f22 100644
2341 --- a/arch/arm/kernel/armksyms.c
2342 +++ b/arch/arm/kernel/armksyms.c
2343 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2344
2345 /* networking */
2346 EXPORT_SYMBOL(csum_partial);
2347 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2348 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2349 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2350 EXPORT_SYMBOL(__csum_ipv6_magic);
2351
2352 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2353 #ifdef CONFIG_MMU
2354 EXPORT_SYMBOL(copy_page);
2355
2356 -EXPORT_SYMBOL(__copy_from_user);
2357 -EXPORT_SYMBOL(__copy_to_user);
2358 -EXPORT_SYMBOL(__clear_user);
2359 +EXPORT_SYMBOL(___copy_from_user);
2360 +EXPORT_SYMBOL(___copy_to_user);
2361 +EXPORT_SYMBOL(___clear_user);
2362
2363 EXPORT_SYMBOL(__get_user_1);
2364 EXPORT_SYMBOL(__get_user_2);
2365 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2366 index 582b405..a78366b 100644
2367 --- a/arch/arm/kernel/entry-armv.S
2368 +++ b/arch/arm/kernel/entry-armv.S
2369 @@ -47,6 +47,87 @@
2370 9997:
2371 .endm
2372
2373 + .macro pax_enter_kernel
2374 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2375 + @ make aligned space for saved DACR
2376 + sub sp, sp, #8
2377 + @ save regs
2378 + stmdb sp!, {r1, r2}
2379 + @ read DACR from cpu_domain into r1
2380 + mov r2, sp
2381 + @ assume 8K pages, since we have to split the immediate in two
2382 + bic r2, r2, #(0x1fc0)
2383 + bic r2, r2, #(0x3f)
2384 + ldr r1, [r2, #TI_CPU_DOMAIN]
2385 + @ store old DACR on stack
2386 + str r1, [sp, #8]
2387 +#ifdef CONFIG_PAX_KERNEXEC
2388 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2389 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2390 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2391 +#endif
2392 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2393 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2394 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2395 +#endif
2396 + @ write r1 to current_thread_info()->cpu_domain
2397 + str r1, [r2, #TI_CPU_DOMAIN]
2398 + @ write r1 to DACR
2399 + mcr p15, 0, r1, c3, c0, 0
2400 + @ instruction sync
2401 + instr_sync
2402 + @ restore regs
2403 + ldmia sp!, {r1, r2}
2404 +#endif
2405 + .endm
2406 +
2407 + .macro pax_open_userland
2408 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2409 + @ save regs
2410 + stmdb sp!, {r0, r1}
2411 + @ read DACR from cpu_domain into r1
2412 + mov r0, sp
2413 + @ assume 8K pages, since we have to split the immediate in two
2414 + bic r0, r0, #(0x1fc0)
2415 + bic r0, r0, #(0x3f)
2416 + ldr r1, [r0, #TI_CPU_DOMAIN]
2417 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2418 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2419 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2420 + @ write r1 to current_thread_info()->cpu_domain
2421 + str r1, [r0, #TI_CPU_DOMAIN]
2422 + @ write r1 to DACR
2423 + mcr p15, 0, r1, c3, c0, 0
2424 + @ instruction sync
2425 + instr_sync
2426 + @ restore regs
2427 + ldmia sp!, {r0, r1}
2428 +#endif
2429 + .endm
2430 +
2431 + .macro pax_close_userland
2432 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2433 + @ save regs
2434 + stmdb sp!, {r0, r1}
2435 + @ read DACR from cpu_domain into r1
2436 + mov r0, sp
2437 + @ assume 8K pages, since we have to split the immediate in two
2438 + bic r0, r0, #(0x1fc0)
2439 + bic r0, r0, #(0x3f)
2440 + ldr r1, [r0, #TI_CPU_DOMAIN]
2441 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2442 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2443 + @ write r1 to current_thread_info()->cpu_domain
2444 + str r1, [r0, #TI_CPU_DOMAIN]
2445 + @ write r1 to DACR
2446 + mcr p15, 0, r1, c3, c0, 0
2447 + @ instruction sync
2448 + instr_sync
2449 + @ restore regs
2450 + ldmia sp!, {r0, r1}
2451 +#endif
2452 + .endm
2453 +
2454 .macro pabt_helper
2455 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2456 #ifdef MULTI_PABORT
2457 @@ -89,11 +170,15 @@
2458 * Invalid mode handlers
2459 */
2460 .macro inv_entry, reason
2461 +
2462 + pax_enter_kernel
2463 +
2464 sub sp, sp, #S_FRAME_SIZE
2465 ARM( stmib sp, {r1 - lr} )
2466 THUMB( stmia sp, {r0 - r12} )
2467 THUMB( str sp, [sp, #S_SP] )
2468 THUMB( str lr, [sp, #S_LR] )
2469 +
2470 mov r1, #\reason
2471 .endm
2472
2473 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2474 .macro svc_entry, stack_hole=0
2475 UNWIND(.fnstart )
2476 UNWIND(.save {r0 - pc} )
2477 +
2478 + pax_enter_kernel
2479 +
2480 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2481 +
2482 #ifdef CONFIG_THUMB2_KERNEL
2483 SPFIX( str r0, [sp] ) @ temporarily saved
2484 SPFIX( mov r0, sp )
2485 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2486 ldmia r0, {r3 - r5}
2487 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2488 mov r6, #-1 @ "" "" "" ""
2489 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2490 + @ offset sp by 8 as done in pax_enter_kernel
2491 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2492 +#else
2493 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2494 +#endif
2495 SPFIX( addeq r2, r2, #4 )
2496 str r3, [sp, #-4]! @ save the "real" r0 copied
2497 @ from the exception stack
2498 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2499 .macro usr_entry
2500 UNWIND(.fnstart )
2501 UNWIND(.cantunwind ) @ don't unwind the user space
2502 +
2503 + pax_enter_kernel_user
2504 +
2505 sub sp, sp, #S_FRAME_SIZE
2506 ARM( stmib sp, {r1 - r12} )
2507 THUMB( stmia sp, {r0 - r12} )
2508 @@ -414,7 +511,9 @@ __und_usr:
2509 tst r3, #PSR_T_BIT @ Thumb mode?
2510 bne __und_usr_thumb
2511 sub r4, r2, #4 @ ARM instr at LR - 4
2512 + pax_open_userland
2513 1: ldrt r0, [r4]
2514 + pax_close_userland
2515 #ifdef CONFIG_CPU_ENDIAN_BE8
2516 rev r0, r0 @ little endian instruction
2517 #endif
2518 @@ -449,10 +548,14 @@ __und_usr_thumb:
2519 */
2520 .arch armv6t2
2521 #endif
2522 + pax_open_userland
2523 2: ldrht r5, [r4]
2524 + pax_close_userland
2525 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2526 blo __und_usr_fault_16 @ 16bit undefined instruction
2527 + pax_open_userland
2528 3: ldrht r0, [r2]
2529 + pax_close_userland
2530 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2531 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2532 orr r0, r0, r5, lsl #16
2533 @@ -481,7 +584,8 @@ ENDPROC(__und_usr)
2534 */
2535 .pushsection .fixup, "ax"
2536 .align 2
2537 -4: mov pc, r9
2538 +4: pax_close_userland
2539 + mov pc, r9
2540 .popsection
2541 .pushsection __ex_table,"a"
2542 .long 1b, 4b
2543 @@ -690,7 +794,7 @@ ENTRY(__switch_to)
2544 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2545 THUMB( str sp, [ip], #4 )
2546 THUMB( str lr, [ip], #4 )
2547 -#ifdef CONFIG_CPU_USE_DOMAINS
2548 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2549 ldr r6, [r2, #TI_CPU_DOMAIN]
2550 #endif
2551 set_tls r3, r4, r5
2552 @@ -699,7 +803,7 @@ ENTRY(__switch_to)
2553 ldr r8, =__stack_chk_guard
2554 ldr r7, [r7, #TSK_STACK_CANARY]
2555 #endif
2556 -#ifdef CONFIG_CPU_USE_DOMAINS
2557 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2558 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2559 #endif
2560 mov r5, r0
2561 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2562 index bc5bc0a..d0998ca 100644
2563 --- a/arch/arm/kernel/entry-common.S
2564 +++ b/arch/arm/kernel/entry-common.S
2565 @@ -10,18 +10,46 @@
2566
2567 #include <asm/unistd.h>
2568 #include <asm/ftrace.h>
2569 +#include <asm/domain.h>
2570 #include <asm/unwind.h>
2571
2572 +#include "entry-header.S"
2573 +
2574 #ifdef CONFIG_NEED_RET_TO_USER
2575 #include <mach/entry-macro.S>
2576 #else
2577 .macro arch_ret_to_user, tmp1, tmp2
2578 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2579 + @ save regs
2580 + stmdb sp!, {r1, r2}
2581 + @ read DACR from cpu_domain into r1
2582 + mov r2, sp
2583 + @ assume 8K pages, since we have to split the immediate in two
2584 + bic r2, r2, #(0x1fc0)
2585 + bic r2, r2, #(0x3f)
2586 + ldr r1, [r2, #TI_CPU_DOMAIN]
2587 +#ifdef CONFIG_PAX_KERNEXEC
2588 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2589 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2591 +#endif
2592 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2593 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2594 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2595 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2596 +#endif
2597 + @ write r1 to current_thread_info()->cpu_domain
2598 + str r1, [r2, #TI_CPU_DOMAIN]
2599 + @ write r1 to DACR
2600 + mcr p15, 0, r1, c3, c0, 0
2601 + @ instruction sync
2602 + instr_sync
2603 + @ restore regs
2604 + ldmia sp!, {r1, r2}
2605 +#endif
2606 .endm
2607 #endif
2608
2609 -#include "entry-header.S"
2610 -
2611 -
2612 .align 5
2613 /*
2614 * This is the fast syscall return path. We do as little as
2615 @@ -350,6 +378,7 @@ ENDPROC(ftrace_stub)
2616
2617 .align 5
2618 ENTRY(vector_swi)
2619 +
2620 sub sp, sp, #S_FRAME_SIZE
2621 stmia sp, {r0 - r12} @ Calling r0 - r12
2622 ARM( add r8, sp, #S_PC )
2623 @@ -399,6 +428,12 @@ ENTRY(vector_swi)
2624 ldr scno, [lr, #-4] @ get SWI instruction
2625 #endif
2626
2627 + /*
2628 + * do this here to avoid a performance hit of wrapping the code above
2629 + * that directly dereferences userland to parse the SWI instruction
2630 + */
2631 + pax_enter_kernel_user
2632 +
2633 #ifdef CONFIG_ALIGNMENT_TRAP
2634 ldr ip, __cr_alignment
2635 ldr ip, [ip]
2636 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2637 index 160f337..db67ee4 100644
2638 --- a/arch/arm/kernel/entry-header.S
2639 +++ b/arch/arm/kernel/entry-header.S
2640 @@ -73,6 +73,60 @@
2641 msr cpsr_c, \rtemp @ switch back to the SVC mode
2642 .endm
2643
2644 + .macro pax_enter_kernel_user
2645 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2646 + @ save regs
2647 + stmdb sp!, {r0, r1}
2648 + @ read DACR from cpu_domain into r1
2649 + mov r0, sp
2650 + @ assume 8K pages, since we have to split the immediate in two
2651 + bic r0, r0, #(0x1fc0)
2652 + bic r0, r0, #(0x3f)
2653 + ldr r1, [r0, #TI_CPU_DOMAIN]
2654 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2655 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2656 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2657 +#endif
2658 +#ifdef CONFIG_PAX_KERNEXEC
2659 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2660 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2661 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2662 +#endif
2663 + @ write r1 to current_thread_info()->cpu_domain
2664 + str r1, [r0, #TI_CPU_DOMAIN]
2665 + @ write r1 to DACR
2666 + mcr p15, 0, r1, c3, c0, 0
2667 + @ instruction sync
2668 + instr_sync
2669 + @ restore regs
2670 + ldmia sp!, {r0, r1}
2671 +#endif
2672 + .endm
2673 +
2674 + .macro pax_exit_kernel
2675 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2676 + @ save regs
2677 + stmdb sp!, {r0, r1}
2678 + @ read old DACR from stack into r1
2679 + ldr r1, [sp, #(8 + S_SP)]
2680 + sub r1, r1, #8
2681 + ldr r1, [r1]
2682 +
2683 + @ write r1 to current_thread_info()->cpu_domain
2684 + mov r0, sp
2685 + @ assume 8K pages, since we have to split the immediate in two
2686 + bic r0, r0, #(0x1fc0)
2687 + bic r0, r0, #(0x3f)
2688 + str r1, [r0, #TI_CPU_DOMAIN]
2689 + @ write r1 to DACR
2690 + mcr p15, 0, r1, c3, c0, 0
2691 + @ instruction sync
2692 + instr_sync
2693 + @ restore regs
2694 + ldmia sp!, {r0, r1}
2695 +#endif
2696 + .endm
2697 +
2698 #ifndef CONFIG_THUMB2_KERNEL
2699 .macro svc_exit, rpsr, irq = 0
2700 .if \irq != 0
2701 @@ -92,6 +146,9 @@
2702 blne trace_hardirqs_off
2703 #endif
2704 .endif
2705 +
2706 + pax_exit_kernel
2707 +
2708 msr spsr_cxsf, \rpsr
2709 #if defined(CONFIG_CPU_V6)
2710 ldr r0, [sp]
2711 @@ -155,6 +212,9 @@
2712 blne trace_hardirqs_off
2713 #endif
2714 .endif
2715 +
2716 + pax_exit_kernel
2717 +
2718 ldr lr, [sp, #S_SP] @ top of the stack
2719 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2720 clrex @ clear the exclusive monitor
2721 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2722 index 2adda11..7fbe958 100644
2723 --- a/arch/arm/kernel/fiq.c
2724 +++ b/arch/arm/kernel/fiq.c
2725 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2726 #if defined(CONFIG_CPU_USE_DOMAINS)
2727 memcpy((void *)0xffff001c, start, length);
2728 #else
2729 + pax_open_kernel();
2730 memcpy(vectors_page + 0x1c, start, length);
2731 + pax_close_kernel();
2732 #endif
2733 flush_icache_range(0xffff001c, 0xffff001c + length);
2734 if (!vectors_high())
2735 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2736 index 8bac553..caee108 100644
2737 --- a/arch/arm/kernel/head.S
2738 +++ b/arch/arm/kernel/head.S
2739 @@ -52,7 +52,9 @@
2740 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2741
2742 .macro pgtbl, rd, phys
2743 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2744 + mov \rd, #TEXT_OFFSET
2745 + sub \rd, #PG_DIR_SIZE
2746 + add \rd, \rd, \phys
2747 .endm
2748
2749 /*
2750 @@ -434,7 +436,7 @@ __enable_mmu:
2751 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2752 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2753 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2754 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2755 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2756 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2757 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2758 #endif
2759 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2760 index 1fd749e..47adb08 100644
2761 --- a/arch/arm/kernel/hw_breakpoint.c
2762 +++ b/arch/arm/kernel/hw_breakpoint.c
2763 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2764 return NOTIFY_OK;
2765 }
2766
2767 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2768 +static struct notifier_block dbg_reset_nb = {
2769 .notifier_call = dbg_reset_notify,
2770 };
2771
2772 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2773 index 1e9be5d..03edbc2 100644
2774 --- a/arch/arm/kernel/module.c
2775 +++ b/arch/arm/kernel/module.c
2776 @@ -37,12 +37,37 @@
2777 #endif
2778
2779 #ifdef CONFIG_MMU
2780 -void *module_alloc(unsigned long size)
2781 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2782 {
2783 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2784 + return NULL;
2785 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2786 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2787 + GFP_KERNEL, prot, -1,
2788 __builtin_return_address(0));
2789 }
2790 +
2791 +void *module_alloc(unsigned long size)
2792 +{
2793 +
2794 +#ifdef CONFIG_PAX_KERNEXEC
2795 + return __module_alloc(size, PAGE_KERNEL);
2796 +#else
2797 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2798 +#endif
2799 +
2800 +}
2801 +
2802 +#ifdef CONFIG_PAX_KERNEXEC
2803 +void module_free_exec(struct module *mod, void *module_region)
2804 +{
2805 + module_free(mod, module_region);
2806 +}
2807 +
2808 +void *module_alloc_exec(unsigned long size)
2809 +{
2810 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2811 +}
2812 +#endif
2813 #endif
2814
2815 int
2816 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2817 index 07314af..c46655c 100644
2818 --- a/arch/arm/kernel/patch.c
2819 +++ b/arch/arm/kernel/patch.c
2820 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2821 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2822 int size;
2823
2824 + pax_open_kernel();
2825 if (thumb2 && __opcode_is_thumb16(insn)) {
2826 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2827 size = sizeof(u16);
2828 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2829 *(u32 *)addr = insn;
2830 size = sizeof(u32);
2831 }
2832 + pax_close_kernel();
2833
2834 flush_icache_range((uintptr_t)(addr),
2835 (uintptr_t)(addr) + size);
2836 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2837 index 1f2740e..b36e225 100644
2838 --- a/arch/arm/kernel/perf_event_cpu.c
2839 +++ b/arch/arm/kernel/perf_event_cpu.c
2840 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2841 return NOTIFY_OK;
2842 }
2843
2844 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2845 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2846 .notifier_call = cpu_pmu_notify,
2847 };
2848
2849 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2850 index 6e8931c..82ec6a5 100644
2851 --- a/arch/arm/kernel/process.c
2852 +++ b/arch/arm/kernel/process.c
2853 @@ -28,7 +28,6 @@
2854 #include <linux/tick.h>
2855 #include <linux/utsname.h>
2856 #include <linux/uaccess.h>
2857 -#include <linux/random.h>
2858 #include <linux/hw_breakpoint.h>
2859 #include <linux/cpuidle.h>
2860 #include <linux/leds.h>
2861 @@ -223,6 +222,7 @@ void machine_power_off(void)
2862
2863 if (pm_power_off)
2864 pm_power_off();
2865 + BUG();
2866 }
2867
2868 /*
2869 @@ -236,7 +236,7 @@ void machine_power_off(void)
2870 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2871 * to use. Implementing such co-ordination would be essentially impossible.
2872 */
2873 -void machine_restart(char *cmd)
2874 +__noreturn void machine_restart(char *cmd)
2875 {
2876 smp_send_stop();
2877
2878 @@ -258,8 +258,8 @@ void __show_regs(struct pt_regs *regs)
2879
2880 show_regs_print_info(KERN_DEFAULT);
2881
2882 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2883 - print_symbol("LR is at %s\n", regs->ARM_lr);
2884 + printk("PC is at %pA\n", instruction_pointer(regs));
2885 + printk("LR is at %pA\n", regs->ARM_lr);
2886 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2887 "sp : %08lx ip : %08lx fp : %08lx\n",
2888 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2889 @@ -426,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2890 return 0;
2891 }
2892
2893 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2894 -{
2895 - unsigned long range_end = mm->brk + 0x02000000;
2896 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2897 -}
2898 -
2899 #ifdef CONFIG_MMU
2900 /*
2901 * The vectors page is always readable from user space for the
2902 @@ -441,12 +435,12 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
2903 static struct vm_area_struct gate_vma = {
2904 .vm_start = 0xffff0000,
2905 .vm_end = 0xffff0000 + PAGE_SIZE,
2906 - .vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC,
2907 + .vm_flags = VM_NONE,
2908 };
2909
2910 static int __init gate_vma_init(void)
2911 {
2912 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2913 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2914 return 0;
2915 }
2916 arch_initcall(gate_vma_init);
2917 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2918 index 3653164..d83e55d 100644
2919 --- a/arch/arm/kernel/psci.c
2920 +++ b/arch/arm/kernel/psci.c
2921 @@ -24,7 +24,7 @@
2922 #include <asm/opcodes-virt.h>
2923 #include <asm/psci.h>
2924
2925 -struct psci_operations psci_ops;
2926 +struct psci_operations psci_ops __read_only;
2927
2928 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2929
2930 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2931 index 03deeff..741ce88 100644
2932 --- a/arch/arm/kernel/ptrace.c
2933 +++ b/arch/arm/kernel/ptrace.c
2934 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2935 return current_thread_info()->syscall;
2936 }
2937
2938 +#ifdef CONFIG_GRKERNSEC_SETXID
2939 +extern void gr_delayed_cred_worker(void);
2940 +#endif
2941 +
2942 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2943 {
2944 current_thread_info()->syscall = scno;
2945
2946 +#ifdef CONFIG_GRKERNSEC_SETXID
2947 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2948 + gr_delayed_cred_worker();
2949 +#endif
2950 +
2951 /* Do the secure computing check first; failures should be fast. */
2952 if (secure_computing(scno) == -1)
2953 return -1;
2954 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2955 index b4b1d39..efdc9be 100644
2956 --- a/arch/arm/kernel/setup.c
2957 +++ b/arch/arm/kernel/setup.c
2958 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2959 unsigned int elf_hwcap __read_mostly;
2960 EXPORT_SYMBOL(elf_hwcap);
2961
2962 +pteval_t __supported_pte_mask __read_only;
2963 +pmdval_t __supported_pmd_mask __read_only;
2964
2965 #ifdef MULTI_CPU
2966 -struct processor processor __read_mostly;
2967 +struct processor processor;
2968 #endif
2969 #ifdef MULTI_TLB
2970 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2971 +struct cpu_tlb_fns cpu_tlb __read_only;
2972 #endif
2973 #ifdef MULTI_USER
2974 -struct cpu_user_fns cpu_user __read_mostly;
2975 +struct cpu_user_fns cpu_user __read_only;
2976 #endif
2977 #ifdef MULTI_CACHE
2978 -struct cpu_cache_fns cpu_cache __read_mostly;
2979 +struct cpu_cache_fns cpu_cache __read_only;
2980 #endif
2981 #ifdef CONFIG_OUTER_CACHE
2982 -struct outer_cache_fns outer_cache __read_mostly;
2983 +struct outer_cache_fns outer_cache __read_only;
2984 EXPORT_SYMBOL(outer_cache);
2985 #endif
2986
2987 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
2988 asm("mrc p15, 0, %0, c0, c1, 4"
2989 : "=r" (mmfr0));
2990 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2991 - (mmfr0 & 0x000000f0) >= 0x00000030)
2992 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2993 cpu_arch = CPU_ARCH_ARMv7;
2994 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2996 + __supported_pte_mask |= L_PTE_PXN;
2997 + __supported_pmd_mask |= PMD_PXNTABLE;
2998 + }
2999 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3000 (mmfr0 & 0x000000f0) == 0x00000020)
3001 cpu_arch = CPU_ARCH_ARMv6;
3002 else
3003 @@ -479,7 +485,7 @@ static void __init setup_processor(void)
3004 __cpu_architecture = __get_cpu_architecture();
3005
3006 #ifdef MULTI_CPU
3007 - processor = *list->proc;
3008 + memcpy((void *)&processor, list->proc, sizeof processor);
3009 #endif
3010 #ifdef MULTI_TLB
3011 cpu_tlb = *list->tlb;
3012 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3013 index 296786b..a8d4dd5 100644
3014 --- a/arch/arm/kernel/signal.c
3015 +++ b/arch/arm/kernel/signal.c
3016 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3017 __put_user(sigreturn_codes[idx+1], rc+1))
3018 return 1;
3019
3020 - if (cpsr & MODE32_BIT) {
3021 - /*
3022 - * 32-bit code can use the new high-page
3023 - * signal return code support.
3024 - */
3025 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3026 - } else {
3027 - /*
3028 - * Ensure that the instruction cache sees
3029 - * the return code written onto the stack.
3030 - */
3031 - flush_icache_range((unsigned long)rc,
3032 - (unsigned long)(rc + 2));
3033 + /*
3034 + * Ensure that the instruction cache sees
3035 + * the return code written onto the stack.
3036 + */
3037 + flush_icache_range((unsigned long)rc,
3038 + (unsigned long)(rc + 2));
3039
3040 - retcode = ((unsigned long)rc) + thumb;
3041 - }
3042 + retcode = ((unsigned long)rc) + thumb;
3043 }
3044
3045 regs->ARM_r0 = map_sig(ksig->sig);
3046 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3047 index 5919eb4..b5d6dfe 100644
3048 --- a/arch/arm/kernel/smp.c
3049 +++ b/arch/arm/kernel/smp.c
3050 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3051
3052 static DECLARE_COMPLETION(cpu_running);
3053
3054 -static struct smp_operations smp_ops;
3055 +static struct smp_operations smp_ops __read_only;
3056
3057 void __init smp_set_ops(struct smp_operations *ops)
3058 {
3059 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3060 index 18b32e8..b0c8dca 100644
3061 --- a/arch/arm/kernel/traps.c
3062 +++ b/arch/arm/kernel/traps.c
3063 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3064 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3065 {
3066 #ifdef CONFIG_KALLSYMS
3067 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3068 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3069 #else
3070 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3071 #endif
3072 @@ -259,6 +259,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3073 static int die_owner = -1;
3074 static unsigned int die_nest_count;
3075
3076 +extern void gr_handle_kernel_exploit(void);
3077 +
3078 static unsigned long oops_begin(void)
3079 {
3080 int cpu;
3081 @@ -301,6 +303,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3082 panic("Fatal exception in interrupt");
3083 if (panic_on_oops)
3084 panic("Fatal exception");
3085 +
3086 + gr_handle_kernel_exploit();
3087 +
3088 if (signr)
3089 do_exit(signr);
3090 }
3091 @@ -594,7 +599,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3092 * The user helper at 0xffff0fe0 must be used instead.
3093 * (see entry-armv.S for details)
3094 */
3095 + pax_open_kernel();
3096 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3097 + pax_close_kernel();
3098 }
3099 return 0;
3100
3101 @@ -834,13 +841,10 @@ void __init early_trap_init(void *vectors_base)
3102 */
3103 kuser_get_tls_init(vectors);
3104
3105 - /*
3106 - * Copy signal return handlers into the vector page, and
3107 - * set sigreturn to be a pointer to these.
3108 - */
3109 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3110 - sigreturn_codes, sizeof(sigreturn_codes));
3111 -
3112 flush_icache_range(vectors, vectors + PAGE_SIZE);
3113 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3114 +
3115 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3116 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3117 +#endif
3118 +
3119 }
3120 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3121 index a871b8e..123b00a 100644
3122 --- a/arch/arm/kernel/vmlinux.lds.S
3123 +++ b/arch/arm/kernel/vmlinux.lds.S
3124 @@ -8,7 +8,11 @@
3125 #include <asm/thread_info.h>
3126 #include <asm/memory.h>
3127 #include <asm/page.h>
3128 -
3129 +
3130 +#ifdef CONFIG_PAX_KERNEXEC
3131 +#include <asm/pgtable.h>
3132 +#endif
3133 +
3134 #define PROC_INFO \
3135 . = ALIGN(4); \
3136 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3137 @@ -94,6 +98,11 @@ SECTIONS
3138 _text = .;
3139 HEAD_TEXT
3140 }
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 + . = ALIGN(1<<SECTION_SHIFT);
3144 +#endif
3145 +
3146 .text : { /* Real text segment */
3147 _stext = .; /* Text and read-only data */
3148 __exception_text_start = .;
3149 @@ -116,6 +125,8 @@ SECTIONS
3150 ARM_CPU_KEEP(PROC_INFO)
3151 }
3152
3153 + _etext = .; /* End of text section */
3154 +
3155 RO_DATA(PAGE_SIZE)
3156
3157 . = ALIGN(4);
3158 @@ -146,7 +157,9 @@ SECTIONS
3159
3160 NOTES
3161
3162 - _etext = .; /* End of text and rodata section */
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166
3167 #ifndef CONFIG_XIP_KERNEL
3168 . = ALIGN(PAGE_SIZE);
3169 @@ -207,6 +220,11 @@ SECTIONS
3170 . = PAGE_OFFSET + TEXT_OFFSET;
3171 #else
3172 __init_end = .;
3173 +
3174 +#ifdef CONFIG_PAX_KERNEXEC
3175 + . = ALIGN(1<<SECTION_SHIFT);
3176 +#endif
3177 +
3178 . = ALIGN(THREAD_SIZE);
3179 __data_loc = .;
3180 #endif
3181 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3182 index 14a0d98..7771a7d 100644
3183 --- a/arch/arm/lib/clear_user.S
3184 +++ b/arch/arm/lib/clear_user.S
3185 @@ -12,14 +12,14 @@
3186
3187 .text
3188
3189 -/* Prototype: int __clear_user(void *addr, size_t sz)
3190 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3191 * Purpose : clear some user memory
3192 * Params : addr - user memory address to clear
3193 * : sz - number of bytes to clear
3194 * Returns : number of bytes NOT cleared
3195 */
3196 ENTRY(__clear_user_std)
3197 -WEAK(__clear_user)
3198 +WEAK(___clear_user)
3199 stmfd sp!, {r1, lr}
3200 mov r2, #0
3201 cmp r1, #4
3202 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3203 USER( strnebt r2, [r0])
3204 mov r0, #0
3205 ldmfd sp!, {r1, pc}
3206 -ENDPROC(__clear_user)
3207 +ENDPROC(___clear_user)
3208 ENDPROC(__clear_user_std)
3209
3210 .pushsection .fixup,"ax"
3211 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3212 index 66a477a..bee61d3 100644
3213 --- a/arch/arm/lib/copy_from_user.S
3214 +++ b/arch/arm/lib/copy_from_user.S
3215 @@ -16,7 +16,7 @@
3216 /*
3217 * Prototype:
3218 *
3219 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3220 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3221 *
3222 * Purpose:
3223 *
3224 @@ -84,11 +84,11 @@
3225
3226 .text
3227
3228 -ENTRY(__copy_from_user)
3229 +ENTRY(___copy_from_user)
3230
3231 #include "copy_template.S"
3232
3233 -ENDPROC(__copy_from_user)
3234 +ENDPROC(___copy_from_user)
3235
3236 .pushsection .fixup,"ax"
3237 .align 0
3238 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3239 index 6ee2f67..d1cce76 100644
3240 --- a/arch/arm/lib/copy_page.S
3241 +++ b/arch/arm/lib/copy_page.S
3242 @@ -10,6 +10,7 @@
3243 * ASM optimised string functions
3244 */
3245 #include <linux/linkage.h>
3246 +#include <linux/const.h>
3247 #include <asm/assembler.h>
3248 #include <asm/asm-offsets.h>
3249 #include <asm/cache.h>
3250 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3251 index d066df6..df28194 100644
3252 --- a/arch/arm/lib/copy_to_user.S
3253 +++ b/arch/arm/lib/copy_to_user.S
3254 @@ -16,7 +16,7 @@
3255 /*
3256 * Prototype:
3257 *
3258 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3259 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3260 *
3261 * Purpose:
3262 *
3263 @@ -88,11 +88,11 @@
3264 .text
3265
3266 ENTRY(__copy_to_user_std)
3267 -WEAK(__copy_to_user)
3268 +WEAK(___copy_to_user)
3269
3270 #include "copy_template.S"
3271
3272 -ENDPROC(__copy_to_user)
3273 +ENDPROC(___copy_to_user)
3274 ENDPROC(__copy_to_user_std)
3275
3276 .pushsection .fixup,"ax"
3277 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3278 index 7d08b43..f7ca7ea 100644
3279 --- a/arch/arm/lib/csumpartialcopyuser.S
3280 +++ b/arch/arm/lib/csumpartialcopyuser.S
3281 @@ -57,8 +57,8 @@
3282 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3283 */
3284
3285 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3286 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3287 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3288 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3289
3290 #include "csumpartialcopygeneric.S"
3291
3292 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3293 index 64dbfa5..84a3fd9 100644
3294 --- a/arch/arm/lib/delay.c
3295 +++ b/arch/arm/lib/delay.c
3296 @@ -28,7 +28,7 @@
3297 /*
3298 * Default to the loop-based delay implementation.
3299 */
3300 -struct arm_delay_ops arm_delay_ops = {
3301 +struct arm_delay_ops arm_delay_ops __read_only = {
3302 .delay = __loop_delay,
3303 .const_udelay = __loop_const_udelay,
3304 .udelay = __loop_udelay,
3305 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3306 index 025f742..8432b08 100644
3307 --- a/arch/arm/lib/uaccess_with_memcpy.c
3308 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3309 @@ -104,7 +104,7 @@ out:
3310 }
3311
3312 unsigned long
3313 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3314 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3315 {
3316 /*
3317 * This test is stubbed out of the main function above to keep
3318 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3319 index f389228..592ef66 100644
3320 --- a/arch/arm/mach-kirkwood/common.c
3321 +++ b/arch/arm/mach-kirkwood/common.c
3322 @@ -149,7 +149,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3323 clk_gate_ops.disable(hw);
3324 }
3325
3326 -static struct clk_ops clk_gate_fn_ops;
3327 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3328 +{
3329 + return clk_gate_ops.is_enabled(hw);
3330 +}
3331 +
3332 +static struct clk_ops clk_gate_fn_ops = {
3333 + .enable = clk_gate_fn_enable,
3334 + .disable = clk_gate_fn_disable,
3335 + .is_enabled = clk_gate_fn_is_enabled,
3336 +};
3337
3338 static struct clk __init *clk_register_gate_fn(struct device *dev,
3339 const char *name,
3340 @@ -183,14 +192,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3341 gate_fn->fn_en = fn_en;
3342 gate_fn->fn_dis = fn_dis;
3343
3344 - /* ops is the gate ops, but with our enable/disable functions */
3345 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3346 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3347 - clk_gate_fn_ops = clk_gate_ops;
3348 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3349 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3350 - }
3351 -
3352 clk = clk_register(dev, &gate_fn->gate.hw);
3353
3354 if (IS_ERR(clk))
3355 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3356 index f6eeb87..cc90868 100644
3357 --- a/arch/arm/mach-omap2/board-n8x0.c
3358 +++ b/arch/arm/mach-omap2/board-n8x0.c
3359 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3360 }
3361 #endif
3362
3363 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3364 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3365 .late_init = n8x0_menelaus_late_init,
3366 };
3367
3368 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3369 index 6c4da12..d9ca72d 100644
3370 --- a/arch/arm/mach-omap2/gpmc.c
3371 +++ b/arch/arm/mach-omap2/gpmc.c
3372 @@ -147,7 +147,6 @@ struct omap3_gpmc_regs {
3373 };
3374
3375 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3376 -static struct irq_chip gpmc_irq_chip;
3377 static unsigned gpmc_irq_start;
3378
3379 static struct resource gpmc_mem_root;
3380 @@ -711,6 +710,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3381
3382 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3383
3384 +static struct irq_chip gpmc_irq_chip = {
3385 + .name = "gpmc",
3386 + .irq_startup = gpmc_irq_noop_ret,
3387 + .irq_enable = gpmc_irq_enable,
3388 + .irq_disable = gpmc_irq_disable,
3389 + .irq_shutdown = gpmc_irq_noop,
3390 + .irq_ack = gpmc_irq_noop,
3391 + .irq_mask = gpmc_irq_noop,
3392 + .irq_unmask = gpmc_irq_noop,
3393 +
3394 +};
3395 +
3396 static int gpmc_setup_irq(void)
3397 {
3398 int i;
3399 @@ -725,15 +736,6 @@ static int gpmc_setup_irq(void)
3400 return gpmc_irq_start;
3401 }
3402
3403 - gpmc_irq_chip.name = "gpmc";
3404 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3405 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3406 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3407 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3408 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3409 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3410 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3411 -
3412 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3413 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3414
3415 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3416 index f8bb3b9..831e7b8 100644
3417 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3418 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3419 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3420 return NOTIFY_OK;
3421 }
3422
3423 -static struct notifier_block __refdata irq_hotplug_notifier = {
3424 +static struct notifier_block irq_hotplug_notifier = {
3425 .notifier_call = irq_cpu_hotplug_notify,
3426 };
3427
3428 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3429 index e6d2307..d057195 100644
3430 --- a/arch/arm/mach-omap2/omap_device.c
3431 +++ b/arch/arm/mach-omap2/omap_device.c
3432 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3433 struct platform_device __init *omap_device_build(const char *pdev_name,
3434 int pdev_id,
3435 struct omap_hwmod *oh,
3436 - void *pdata, int pdata_len)
3437 + const void *pdata, int pdata_len)
3438 {
3439 struct omap_hwmod *ohs[] = { oh };
3440
3441 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3442 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3443 int pdev_id,
3444 struct omap_hwmod **ohs,
3445 - int oh_cnt, void *pdata,
3446 + int oh_cnt, const void *pdata,
3447 int pdata_len)
3448 {
3449 int ret = -ENOMEM;
3450 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3451 index 044c31d..2ee0861 100644
3452 --- a/arch/arm/mach-omap2/omap_device.h
3453 +++ b/arch/arm/mach-omap2/omap_device.h
3454 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3455 /* Core code interface */
3456
3457 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3458 - struct omap_hwmod *oh, void *pdata,
3459 + struct omap_hwmod *oh, const void *pdata,
3460 int pdata_len);
3461
3462 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3463 struct omap_hwmod **oh, int oh_cnt,
3464 - void *pdata, int pdata_len);
3465 + const void *pdata, int pdata_len);
3466
3467 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3468 struct omap_hwmod **ohs, int oh_cnt);
3469 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3470 index 7341eff..fd75e34 100644
3471 --- a/arch/arm/mach-omap2/omap_hwmod.c
3472 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3473 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3474 int (*init_clkdm)(struct omap_hwmod *oh);
3475 void (*update_context_lost)(struct omap_hwmod *oh);
3476 int (*get_context_lost)(struct omap_hwmod *oh);
3477 -};
3478 +} __no_const;
3479
3480 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3481 -static struct omap_hwmod_soc_ops soc_ops;
3482 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3483
3484 /* omap_hwmod_list contains all registered struct omap_hwmods */
3485 static LIST_HEAD(omap_hwmod_list);
3486 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3487 index d15c7bb..b2d1f0c 100644
3488 --- a/arch/arm/mach-omap2/wd_timer.c
3489 +++ b/arch/arm/mach-omap2/wd_timer.c
3490 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3491 struct omap_hwmod *oh;
3492 char *oh_name = "wd_timer2";
3493 char *dev_name = "omap_wdt";
3494 - struct omap_wd_timer_platform_data pdata;
3495 + static struct omap_wd_timer_platform_data pdata = {
3496 + .read_reset_sources = prm_read_reset_sources
3497 + };
3498
3499 if (!cpu_class_is_omap2() || of_have_populated_dt())
3500 return 0;
3501 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3502 return -EINVAL;
3503 }
3504
3505 - pdata.read_reset_sources = prm_read_reset_sources;
3506 -
3507 pdev = omap_device_build(dev_name, id, oh, &pdata,
3508 sizeof(struct omap_wd_timer_platform_data));
3509 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3510 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3511 index 0cdba8d..297993e 100644
3512 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3513 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3514 @@ -181,7 +181,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3515 bool entered_lp2 = false;
3516
3517 if (tegra_pending_sgi())
3518 - ACCESS_ONCE(abort_flag) = true;
3519 + ACCESS_ONCE_RW(abort_flag) = true;
3520
3521 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3522
3523 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3524 index cad3ca86..1d79e0f 100644
3525 --- a/arch/arm/mach-ux500/setup.h
3526 +++ b/arch/arm/mach-ux500/setup.h
3527 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3528 .type = MT_DEVICE, \
3529 }
3530
3531 -#define __MEM_DEV_DESC(x, sz) { \
3532 - .virtual = IO_ADDRESS(x), \
3533 - .pfn = __phys_to_pfn(x), \
3534 - .length = sz, \
3535 - .type = MT_MEMORY, \
3536 -}
3537 -
3538 extern struct smp_operations ux500_smp_ops;
3539 extern void ux500_cpu_die(unsigned int cpu);
3540
3541 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3542 index 35955b5..b475042 100644
3543 --- a/arch/arm/mm/Kconfig
3544 +++ b/arch/arm/mm/Kconfig
3545 @@ -432,7 +432,7 @@ config CPU_32v5
3546
3547 config CPU_32v6
3548 bool
3549 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3550 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3551 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3552
3553 config CPU_32v6K
3554 @@ -581,6 +581,7 @@ config CPU_CP15_MPU
3555
3556 config CPU_USE_DOMAINS
3557 bool
3558 + depends on !ARM_LPAE && !PAX_KERNEXEC
3559 help
3560 This option enables or disables the use of domain switching
3561 via the set_fs() function.
3562 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3563 index 6f4585b..7b6f52b 100644
3564 --- a/arch/arm/mm/alignment.c
3565 +++ b/arch/arm/mm/alignment.c
3566 @@ -211,10 +211,12 @@ union offset_union {
3567 #define __get16_unaligned_check(ins,val,addr) \
3568 do { \
3569 unsigned int err = 0, v, a = addr; \
3570 + pax_open_userland(); \
3571 __get8_unaligned_check(ins,v,a,err); \
3572 val = v << ((BE) ? 8 : 0); \
3573 __get8_unaligned_check(ins,v,a,err); \
3574 val |= v << ((BE) ? 0 : 8); \
3575 + pax_close_userland(); \
3576 if (err) \
3577 goto fault; \
3578 } while (0)
3579 @@ -228,6 +230,7 @@ union offset_union {
3580 #define __get32_unaligned_check(ins,val,addr) \
3581 do { \
3582 unsigned int err = 0, v, a = addr; \
3583 + pax_open_userland(); \
3584 __get8_unaligned_check(ins,v,a,err); \
3585 val = v << ((BE) ? 24 : 0); \
3586 __get8_unaligned_check(ins,v,a,err); \
3587 @@ -236,6 +239,7 @@ union offset_union {
3588 val |= v << ((BE) ? 8 : 16); \
3589 __get8_unaligned_check(ins,v,a,err); \
3590 val |= v << ((BE) ? 0 : 24); \
3591 + pax_close_userland(); \
3592 if (err) \
3593 goto fault; \
3594 } while (0)
3595 @@ -249,6 +253,7 @@ union offset_union {
3596 #define __put16_unaligned_check(ins,val,addr) \
3597 do { \
3598 unsigned int err = 0, v = val, a = addr; \
3599 + pax_open_userland(); \
3600 __asm__( FIRST_BYTE_16 \
3601 ARM( "1: "ins" %1, [%2], #1\n" ) \
3602 THUMB( "1: "ins" %1, [%2]\n" ) \
3603 @@ -268,6 +273,7 @@ union offset_union {
3604 " .popsection\n" \
3605 : "=r" (err), "=&r" (v), "=&r" (a) \
3606 : "0" (err), "1" (v), "2" (a)); \
3607 + pax_close_userland(); \
3608 if (err) \
3609 goto fault; \
3610 } while (0)
3611 @@ -281,6 +287,7 @@ union offset_union {
3612 #define __put32_unaligned_check(ins,val,addr) \
3613 do { \
3614 unsigned int err = 0, v = val, a = addr; \
3615 + pax_open_userland(); \
3616 __asm__( FIRST_BYTE_32 \
3617 ARM( "1: "ins" %1, [%2], #1\n" ) \
3618 THUMB( "1: "ins" %1, [%2]\n" ) \
3619 @@ -310,6 +317,7 @@ union offset_union {
3620 " .popsection\n" \
3621 : "=r" (err), "=&r" (v), "=&r" (a) \
3622 : "0" (err), "1" (v), "2" (a)); \
3623 + pax_close_userland(); \
3624 if (err) \
3625 goto fault; \
3626 } while (0)
3627 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3628 index 5dbf13f..1a60561 100644
3629 --- a/arch/arm/mm/fault.c
3630 +++ b/arch/arm/mm/fault.c
3631 @@ -25,6 +25,7 @@
3632 #include <asm/system_misc.h>
3633 #include <asm/system_info.h>
3634 #include <asm/tlbflush.h>
3635 +#include <asm/sections.h>
3636
3637 #include "fault.h"
3638
3639 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3640 if (fixup_exception(regs))
3641 return;
3642
3643 +#ifdef CONFIG_PAX_KERNEXEC
3644 + if ((fsr & FSR_WRITE) &&
3645 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3646 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3647 + {
3648 + if (current->signal->curr_ip)
3649 + 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),
3650 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3651 + else
3652 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3653 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3654 + }
3655 +#endif
3656 +
3657 /*
3658 * No handler, we'll have to terminate things with extreme prejudice.
3659 */
3660 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3661 }
3662 #endif
3663
3664 +#ifdef CONFIG_PAX_PAGEEXEC
3665 + if (fsr & FSR_LNX_PF) {
3666 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3667 + do_group_exit(SIGKILL);
3668 + }
3669 +#endif
3670 +
3671 tsk->thread.address = addr;
3672 tsk->thread.error_code = fsr;
3673 tsk->thread.trap_no = 14;
3674 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3675 }
3676 #endif /* CONFIG_MMU */
3677
3678 +#ifdef CONFIG_PAX_PAGEEXEC
3679 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3680 +{
3681 + long i;
3682 +
3683 + printk(KERN_ERR "PAX: bytes at PC: ");
3684 + for (i = 0; i < 20; i++) {
3685 + unsigned char c;
3686 + if (get_user(c, (__force unsigned char __user *)pc+i))
3687 + printk(KERN_CONT "?? ");
3688 + else
3689 + printk(KERN_CONT "%02x ", c);
3690 + }
3691 + printk("\n");
3692 +
3693 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3694 + for (i = -1; i < 20; i++) {
3695 + unsigned long c;
3696 + if (get_user(c, (__force unsigned long __user *)sp+i))
3697 + printk(KERN_CONT "???????? ");
3698 + else
3699 + printk(KERN_CONT "%08lx ", c);
3700 + }
3701 + printk("\n");
3702 +}
3703 +#endif
3704 +
3705 /*
3706 * First Level Translation Fault Handler
3707 *
3708 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3709 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3710 struct siginfo info;
3711
3712 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3713 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3714 + if (current->signal->curr_ip)
3715 + 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),
3716 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3717 + else
3718 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3719 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3720 + goto die;
3721 + }
3722 +#endif
3723 +
3724 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3725 return;
3726
3727 +die:
3728 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3729 inf->name, fsr, addr);
3730
3731 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3732 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3733 struct siginfo info;
3734
3735 + if (user_mode(regs)) {
3736 + if (addr == 0xffff0fe0UL) {
3737 + /*
3738 + * PaX: __kuser_get_tls emulation
3739 + */
3740 + regs->ARM_r0 = current_thread_info()->tp_value;
3741 + regs->ARM_pc = regs->ARM_lr;
3742 + return;
3743 + }
3744 + }
3745 +
3746 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3747 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3748 + if (current->signal->curr_ip)
3749 + 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),
3750 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3751 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3752 + else
3753 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3754 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3755 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3756 + goto die;
3757 + }
3758 +#endif
3759 +
3760 +#ifdef CONFIG_PAX_REFCOUNT
3761 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3762 + unsigned int bkpt;
3763 +
3764 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3765 + current->thread.error_code = ifsr;
3766 + current->thread.trap_no = 0;
3767 + pax_report_refcount_overflow(regs);
3768 + fixup_exception(regs);
3769 + return;
3770 + }
3771 + }
3772 +#endif
3773 +
3774 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3775 return;
3776
3777 +die:
3778 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3779 inf->name, ifsr, addr);
3780
3781 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3782 index cf08bdf..772656c 100644
3783 --- a/arch/arm/mm/fault.h
3784 +++ b/arch/arm/mm/fault.h
3785 @@ -3,6 +3,7 @@
3786
3787 /*
3788 * Fault status register encodings. We steal bit 31 for our own purposes.
3789 + * Set when the FSR value is from an instruction fault.
3790 */
3791 #define FSR_LNX_PF (1 << 31)
3792 #define FSR_WRITE (1 << 11)
3793 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3794 }
3795 #endif
3796
3797 +/* valid for LPAE and !LPAE */
3798 +static inline int is_xn_fault(unsigned int fsr)
3799 +{
3800 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3801 +}
3802 +
3803 +static inline int is_domain_fault(unsigned int fsr)
3804 +{
3805 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3806 +}
3807 +
3808 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3809 unsigned long search_exception_table(unsigned long addr);
3810
3811 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3812 index 0ecc43f..190b956 100644
3813 --- a/arch/arm/mm/init.c
3814 +++ b/arch/arm/mm/init.c
3815 @@ -30,6 +30,8 @@
3816 #include <asm/setup.h>
3817 #include <asm/tlb.h>
3818 #include <asm/fixmap.h>
3819 +#include <asm/system_info.h>
3820 +#include <asm/cp15.h>
3821
3822 #include <asm/mach/arch.h>
3823 #include <asm/mach/map.h>
3824 @@ -726,7 +728,46 @@ void free_initmem(void)
3825 {
3826 #ifdef CONFIG_HAVE_TCM
3827 extern char __tcm_start, __tcm_end;
3828 +#endif
3829
3830 +#ifdef CONFIG_PAX_KERNEXEC
3831 + unsigned long addr;
3832 + pgd_t *pgd;
3833 + pud_t *pud;
3834 + pmd_t *pmd;
3835 + int cpu_arch = cpu_architecture();
3836 + unsigned int cr = get_cr();
3837 +
3838 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3839 + /* make pages tables, etc before .text NX */
3840 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3841 + pgd = pgd_offset_k(addr);
3842 + pud = pud_offset(pgd, addr);
3843 + pmd = pmd_offset(pud, addr);
3844 + __section_update(pmd, addr, PMD_SECT_XN);
3845 + }
3846 + /* make init NX */
3847 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3848 + pgd = pgd_offset_k(addr);
3849 + pud = pud_offset(pgd, addr);
3850 + pmd = pmd_offset(pud, addr);
3851 + __section_update(pmd, addr, PMD_SECT_XN);
3852 + }
3853 + /* make kernel code/rodata RX */
3854 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3855 + pgd = pgd_offset_k(addr);
3856 + pud = pud_offset(pgd, addr);
3857 + pmd = pmd_offset(pud, addr);
3858 +#ifdef CONFIG_ARM_LPAE
3859 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3860 +#else
3861 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3862 +#endif
3863 + }
3864 + }
3865 +#endif
3866 +
3867 +#ifdef CONFIG_HAVE_TCM
3868 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3869 free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
3870 #endif
3871 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3872 index 04d9006..c547d85 100644
3873 --- a/arch/arm/mm/ioremap.c
3874 +++ b/arch/arm/mm/ioremap.c
3875 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3876 unsigned int mtype;
3877
3878 if (cached)
3879 - mtype = MT_MEMORY;
3880 + mtype = MT_MEMORY_RX;
3881 else
3882 - mtype = MT_MEMORY_NONCACHED;
3883 + mtype = MT_MEMORY_NONCACHED_RX;
3884
3885 return __arm_ioremap_caller(phys_addr, size, mtype,
3886 __builtin_return_address(0));
3887 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3888 index 10062ce..8695745 100644
3889 --- a/arch/arm/mm/mmap.c
3890 +++ b/arch/arm/mm/mmap.c
3891 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3892 struct vm_area_struct *vma;
3893 int do_align = 0;
3894 int aliasing = cache_is_vipt_aliasing();
3895 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3896 struct vm_unmapped_area_info info;
3897
3898 /*
3899 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3900 if (len > TASK_SIZE)
3901 return -ENOMEM;
3902
3903 +#ifdef CONFIG_PAX_RANDMMAP
3904 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3905 +#endif
3906 +
3907 if (addr) {
3908 if (do_align)
3909 addr = COLOUR_ALIGN(addr, pgoff);
3910 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3911 addr = PAGE_ALIGN(addr);
3912
3913 vma = find_vma(mm, addr);
3914 - if (TASK_SIZE - len >= addr &&
3915 - (!vma || addr + len <= vma->vm_start))
3916 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3917 return addr;
3918 }
3919
3920 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3921 info.high_limit = TASK_SIZE;
3922 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3923 info.align_offset = pgoff << PAGE_SHIFT;
3924 + info.threadstack_offset = offset;
3925 return vm_unmapped_area(&info);
3926 }
3927
3928 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3929 unsigned long addr = addr0;
3930 int do_align = 0;
3931 int aliasing = cache_is_vipt_aliasing();
3932 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3933 struct vm_unmapped_area_info info;
3934
3935 /*
3936 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3937 return addr;
3938 }
3939
3940 +#ifdef CONFIG_PAX_RANDMMAP
3941 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3942 +#endif
3943 +
3944 /* requesting a specific address */
3945 if (addr) {
3946 if (do_align)
3947 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3948 else
3949 addr = PAGE_ALIGN(addr);
3950 vma = find_vma(mm, addr);
3951 - if (TASK_SIZE - len >= addr &&
3952 - (!vma || addr + len <= vma->vm_start))
3953 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3954 return addr;
3955 }
3956
3957 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3958 info.high_limit = mm->mmap_base;
3959 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3960 info.align_offset = pgoff << PAGE_SHIFT;
3961 + info.threadstack_offset = offset;
3962 addr = vm_unmapped_area(&info);
3963
3964 /*
3965 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3966 {
3967 unsigned long random_factor = 0UL;
3968
3969 +#ifdef CONFIG_PAX_RANDMMAP
3970 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3971 +#endif
3972 +
3973 /* 8 bits of randomness in 20 address space bits */
3974 if ((current->flags & PF_RANDOMIZE) &&
3975 !(current->personality & ADDR_NO_RANDOMIZE))
3976 @@ -180,10 +194,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3977
3978 if (mmap_is_legacy()) {
3979 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3980 +
3981 +#ifdef CONFIG_PAX_RANDMMAP
3982 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3983 + mm->mmap_base += mm->delta_mmap;
3984 +#endif
3985 +
3986 mm->get_unmapped_area = arch_get_unmapped_area;
3987 mm->unmap_area = arch_unmap_area;
3988 } else {
3989 mm->mmap_base = mmap_base(random_factor);
3990 +
3991 +#ifdef CONFIG_PAX_RANDMMAP
3992 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3993 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3994 +#endif
3995 +
3996 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3997 mm->unmap_area = arch_unmap_area_topdown;
3998 }
3999 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4000 index 4d409e6..f375351 100644
4001 --- a/arch/arm/mm/mmu.c
4002 +++ b/arch/arm/mm/mmu.c
4003 @@ -36,6 +36,22 @@
4004 #include "mm.h"
4005 #include "tcm.h"
4006
4007 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4008 +void modify_domain(unsigned int dom, unsigned int type)
4009 +{
4010 + struct thread_info *thread = current_thread_info();
4011 + unsigned int domain = thread->cpu_domain;
4012 + /*
4013 + * DOMAIN_MANAGER might be defined to some other value,
4014 + * use the arch-defined constant
4015 + */
4016 + domain &= ~domain_val(dom, 3);
4017 + thread->cpu_domain = domain | domain_val(dom, type);
4018 + set_domain(thread->cpu_domain);
4019 +}
4020 +EXPORT_SYMBOL(modify_domain);
4021 +#endif
4022 +
4023 /*
4024 * empty_zero_page is a special page that is used for
4025 * zero-initialized data and COW.
4026 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4027
4028 #endif /* ifdef CONFIG_CPU_CP15 / else */
4029
4030 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4031 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4032 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4033
4034 -static struct mem_type mem_types[] = {
4035 +#ifdef CONFIG_PAX_KERNEXEC
4036 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4037 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4038 +#else
4039 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4040 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4041 +#endif
4042 +
4043 +static struct mem_type mem_types[] __read_only = {
4044 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4045 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4046 L_PTE_SHARED,
4047 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4048 [MT_UNCACHED] = {
4049 .prot_pte = PROT_PTE_DEVICE,
4050 .prot_l1 = PMD_TYPE_TABLE,
4051 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4052 + .prot_sect = PROT_SECT_DEVICE,
4053 .domain = DOMAIN_IO,
4054 },
4055 [MT_CACHECLEAN] = {
4056 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4057 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4058 .domain = DOMAIN_KERNEL,
4059 },
4060 #ifndef CONFIG_ARM_LPAE
4061 [MT_MINICLEAN] = {
4062 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4063 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4064 .domain = DOMAIN_KERNEL,
4065 },
4066 #endif
4067 @@ -277,36 +301,65 @@ static struct mem_type mem_types[] = {
4068 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4069 L_PTE_RDONLY,
4070 .prot_l1 = PMD_TYPE_TABLE,
4071 - .domain = DOMAIN_USER,
4072 + .domain = DOMAIN_VECTORS,
4073 },
4074 [MT_HIGH_VECTORS] = {
4075 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4076 - L_PTE_USER | L_PTE_RDONLY,
4077 + /* we always want the vector page to be noaccess for userland on archs with
4078 + XN where we can enforce some reasonable measure of security
4079 + therefore, when kernexec is disabled, instead of L_PTE_USER | L_PTE_RDONLY
4080 + which turns into supervisor rwx, userland rx, we instead omit that entirely,
4081 + leaving it as supervisor rwx only
4082 + */
4083 +#ifdef CONFIG_PAX_KERNEXEC
4084 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_RDONLY,
4085 +#elif __LINUX_ARM_ARCH__ >= 6
4086 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4087 +#else
4088 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_USER | L_PTE_RDONLY,
4089 +#endif
4090 .prot_l1 = PMD_TYPE_TABLE,
4091 - .domain = DOMAIN_USER,
4092 + .domain = DOMAIN_VECTORS,
4093 },
4094 - [MT_MEMORY] = {
4095 + [MT_MEMORY_RWX] = {
4096 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4097 .prot_l1 = PMD_TYPE_TABLE,
4098 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4099 .domain = DOMAIN_KERNEL,
4100 },
4101 + [MT_MEMORY_RW] = {
4102 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4103 + .prot_l1 = PMD_TYPE_TABLE,
4104 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4105 + .domain = DOMAIN_KERNEL,
4106 + },
4107 + [MT_MEMORY_RX] = {
4108 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4109 + .prot_l1 = PMD_TYPE_TABLE,
4110 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4111 + .domain = DOMAIN_KERNEL,
4112 + },
4113 [MT_ROM] = {
4114 - .prot_sect = PMD_TYPE_SECT,
4115 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4116 .domain = DOMAIN_KERNEL,
4117 },
4118 - [MT_MEMORY_NONCACHED] = {
4119 + [MT_MEMORY_NONCACHED_RW] = {
4120 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4121 L_PTE_MT_BUFFERABLE,
4122 .prot_l1 = PMD_TYPE_TABLE,
4123 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4124 .domain = DOMAIN_KERNEL,
4125 },
4126 + [MT_MEMORY_NONCACHED_RX] = {
4127 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4128 + L_PTE_MT_BUFFERABLE,
4129 + .prot_l1 = PMD_TYPE_TABLE,
4130 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4131 + .domain = DOMAIN_KERNEL,
4132 + },
4133 [MT_MEMORY_DTCM] = {
4134 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4135 - L_PTE_XN,
4136 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4137 .prot_l1 = PMD_TYPE_TABLE,
4138 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4139 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4140 .domain = DOMAIN_KERNEL,
4141 },
4142 [MT_MEMORY_ITCM] = {
4143 @@ -316,10 +369,10 @@ static struct mem_type mem_types[] = {
4144 },
4145 [MT_MEMORY_SO] = {
4146 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4147 - L_PTE_MT_UNCACHED | L_PTE_XN,
4148 + L_PTE_MT_UNCACHED,
4149 .prot_l1 = PMD_TYPE_TABLE,
4150 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4151 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4152 + PMD_SECT_UNCACHED,
4153 .domain = DOMAIN_KERNEL,
4154 },
4155 [MT_MEMORY_DMA_READY] = {
4156 @@ -405,9 +458,35 @@ static void __init build_mem_type_table(void)
4157 * to prevent speculative instruction fetches.
4158 */
4159 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4160 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4161 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4162 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4163 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4164 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4165 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4166 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4167 +
4168 + /* Mark other regions on ARMv6+ as execute-never */
4169 +
4170 +#ifdef CONFIG_PAX_KERNEXEC
4171 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4172 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4173 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4174 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4175 +#ifndef CONFIG_ARM_LPAE
4176 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4177 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4178 +#endif
4179 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4180 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4181 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4182 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4183 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4184 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4185 +#endif
4186 +
4187 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4188 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4189 }
4190 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4191 /*
4192 @@ -468,6 +547,9 @@ static void __init build_mem_type_table(void)
4193 * from SVC mode and no access from userspace.
4194 */
4195 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4196 +#ifdef CONFIG_PAX_KERNEXEC
4197 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4198 +#endif
4199 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4200 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4201 #endif
4202 @@ -485,11 +567,17 @@ static void __init build_mem_type_table(void)
4203 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4204 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4205 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4206 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4207 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4208 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4209 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4210 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4211 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4212 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4213 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4214 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4215 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4216 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4217 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4218 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4219 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4220 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4221 }
4222 }
4223
4224 @@ -500,15 +588,20 @@ static void __init build_mem_type_table(void)
4225 if (cpu_arch >= CPU_ARCH_ARMv6) {
4226 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4227 /* Non-cacheable Normal is XCB = 001 */
4228 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4229 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4230 + PMD_SECT_BUFFERED;
4231 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4232 PMD_SECT_BUFFERED;
4233 } else {
4234 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4235 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4236 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4237 + PMD_SECT_TEX(1);
4238 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4239 PMD_SECT_TEX(1);
4240 }
4241 } else {
4242 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4243 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4244 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4245 }
4246
4247 #ifdef CONFIG_ARM_LPAE
4248 @@ -524,6 +617,8 @@ static void __init build_mem_type_table(void)
4249 vecs_pgprot |= PTE_EXT_AF;
4250 #endif
4251
4252 + user_pgprot |= __supported_pte_mask;
4253 +
4254 for (i = 0; i < 16; i++) {
4255 pteval_t v = pgprot_val(protection_map[i]);
4256 protection_map[i] = __pgprot(v | user_pgprot);
4257 @@ -541,10 +636,15 @@ static void __init build_mem_type_table(void)
4258
4259 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4260 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4261 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4262 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4263 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4264 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4265 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4266 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4267 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4268 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4269 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4270 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4271 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4272 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4273 mem_types[MT_ROM].prot_sect |= cp->pmd;
4274
4275 switch (cp->pmd) {
4276 @@ -1166,18 +1266,15 @@ void __init arm_mm_memblock_reserve(void)
4277 * called function. This means you can't use any function or debugging
4278 * method which may touch any device, otherwise the kernel _will_ crash.
4279 */
4280 +
4281 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4282 +
4283 static void __init devicemaps_init(struct machine_desc *mdesc)
4284 {
4285 struct map_desc map;
4286 unsigned long addr;
4287 - void *vectors;
4288
4289 - /*
4290 - * Allocate the vector page early.
4291 - */
4292 - vectors = early_alloc(PAGE_SIZE);
4293 -
4294 - early_trap_init(vectors);
4295 + early_trap_init(&vectors);
4296
4297 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4298 pmd_clear(pmd_off_k(addr));
4299 @@ -1217,7 +1314,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4300 * location (0xffff0000). If we aren't using high-vectors, also
4301 * create a mapping at the low-vectors virtual address.
4302 */
4303 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4304 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4305 map.virtual = 0xffff0000;
4306 map.length = PAGE_SIZE;
4307 map.type = MT_HIGH_VECTORS;
4308 @@ -1275,8 +1372,39 @@ static void __init map_lowmem(void)
4309 map.pfn = __phys_to_pfn(start);
4310 map.virtual = __phys_to_virt(start);
4311 map.length = end - start;
4312 - map.type = MT_MEMORY;
4313
4314 +#ifdef CONFIG_PAX_KERNEXEC
4315 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4316 + struct map_desc kernel;
4317 + struct map_desc initmap;
4318 +
4319 + /* when freeing initmem we will make this RW */
4320 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4321 + initmap.virtual = (unsigned long)__init_begin;
4322 + initmap.length = _sdata - __init_begin;
4323 + initmap.type = MT_MEMORY_RWX;
4324 + create_mapping(&initmap);
4325 +
4326 + /* when freeing initmem we will make this RX */
4327 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4328 + kernel.virtual = (unsigned long)_stext;
4329 + kernel.length = __init_begin - _stext;
4330 + kernel.type = MT_MEMORY_RWX;
4331 + create_mapping(&kernel);
4332 +
4333 + if (map.virtual < (unsigned long)_stext) {
4334 + map.length = (unsigned long)_stext - map.virtual;
4335 + map.type = MT_MEMORY_RWX;
4336 + create_mapping(&map);
4337 + }
4338 +
4339 + map.pfn = __phys_to_pfn(__pa(_sdata));
4340 + map.virtual = (unsigned long)_sdata;
4341 + map.length = end - __pa(_sdata);
4342 + }
4343 +#endif
4344 +
4345 + map.type = MT_MEMORY_RW;
4346 create_mapping(&map);
4347 }
4348 }
4349 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4350 index 9704097..3e36dde 100644
4351 --- a/arch/arm/mm/proc-v7-2level.S
4352 +++ b/arch/arm/mm/proc-v7-2level.S
4353 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4354 tst r1, #L_PTE_XN
4355 orrne r3, r3, #PTE_EXT_XN
4356
4357 + tst r1, #L_PTE_PXN
4358 + orrne r3, r3, #PTE_EXT_PXN
4359 +
4360 tst r1, #L_PTE_YOUNG
4361 tstne r1, #L_PTE_VALID
4362 #ifndef CONFIG_CPU_USE_DOMAINS
4363 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4364 index a5bc92d..0bb4730 100644
4365 --- a/arch/arm/plat-omap/sram.c
4366 +++ b/arch/arm/plat-omap/sram.c
4367 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4368 * Looks like we need to preserve some bootloader code at the
4369 * beginning of SRAM for jumping to flash for reboot to work...
4370 */
4371 + pax_open_kernel();
4372 memset_io(omap_sram_base + omap_sram_skip, 0,
4373 omap_sram_size - omap_sram_skip);
4374 + pax_close_kernel();
4375 }
4376 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4377 index ce6d763..cfea917 100644
4378 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4379 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4380 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4381 int (*started)(unsigned ch);
4382 int (*flush)(unsigned ch);
4383 int (*stop)(unsigned ch);
4384 -};
4385 +} __no_const;
4386
4387 extern void *samsung_dmadev_get_ops(void);
4388 extern void *s3c_dma_get_ops(void);
4389 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4390 index f4726dc..39ed646 100644
4391 --- a/arch/arm64/kernel/debug-monitors.c
4392 +++ b/arch/arm64/kernel/debug-monitors.c
4393 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4394 return NOTIFY_OK;
4395 }
4396
4397 -static struct notifier_block __cpuinitdata os_lock_nb = {
4398 +static struct notifier_block os_lock_nb = {
4399 .notifier_call = os_lock_notify,
4400 };
4401
4402 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4403 index 5ab825c..96aaec8 100644
4404 --- a/arch/arm64/kernel/hw_breakpoint.c
4405 +++ b/arch/arm64/kernel/hw_breakpoint.c
4406 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4407 return NOTIFY_OK;
4408 }
4409
4410 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4411 +static struct notifier_block hw_breakpoint_reset_nb = {
4412 .notifier_call = hw_breakpoint_reset_notify,
4413 };
4414
4415 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4416 index c3a58a1..78fbf54 100644
4417 --- a/arch/avr32/include/asm/cache.h
4418 +++ b/arch/avr32/include/asm/cache.h
4419 @@ -1,8 +1,10 @@
4420 #ifndef __ASM_AVR32_CACHE_H
4421 #define __ASM_AVR32_CACHE_H
4422
4423 +#include <linux/const.h>
4424 +
4425 #define L1_CACHE_SHIFT 5
4426 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4427 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4428
4429 /*
4430 * Memory returned by kmalloc() may be used for DMA, so we must make
4431 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4432 index d232888..87c8df1 100644
4433 --- a/arch/avr32/include/asm/elf.h
4434 +++ b/arch/avr32/include/asm/elf.h
4435 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4436 the loader. We need to make sure that it is out of the way of the program
4437 that it will "exec", and that there is sufficient room for the brk. */
4438
4439 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4440 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4441
4442 +#ifdef CONFIG_PAX_ASLR
4443 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4444 +
4445 +#define PAX_DELTA_MMAP_LEN 15
4446 +#define PAX_DELTA_STACK_LEN 15
4447 +#endif
4448
4449 /* This yields a mask that user programs can use to figure out what
4450 instruction set this CPU supports. This could be done in user space,
4451 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4452 index 479330b..53717a8 100644
4453 --- a/arch/avr32/include/asm/kmap_types.h
4454 +++ b/arch/avr32/include/asm/kmap_types.h
4455 @@ -2,9 +2,9 @@
4456 #define __ASM_AVR32_KMAP_TYPES_H
4457
4458 #ifdef CONFIG_DEBUG_HIGHMEM
4459 -# define KM_TYPE_NR 29
4460 +# define KM_TYPE_NR 30
4461 #else
4462 -# define KM_TYPE_NR 14
4463 +# define KM_TYPE_NR 15
4464 #endif
4465
4466 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4467 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4468 index b2f2d2d..d1c85cb 100644
4469 --- a/arch/avr32/mm/fault.c
4470 +++ b/arch/avr32/mm/fault.c
4471 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4472
4473 int exception_trace = 1;
4474
4475 +#ifdef CONFIG_PAX_PAGEEXEC
4476 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4477 +{
4478 + unsigned long i;
4479 +
4480 + printk(KERN_ERR "PAX: bytes at PC: ");
4481 + for (i = 0; i < 20; i++) {
4482 + unsigned char c;
4483 + if (get_user(c, (unsigned char *)pc+i))
4484 + printk(KERN_CONT "???????? ");
4485 + else
4486 + printk(KERN_CONT "%02x ", c);
4487 + }
4488 + printk("\n");
4489 +}
4490 +#endif
4491 +
4492 /*
4493 * This routine handles page faults. It determines the address and the
4494 * problem, and then passes it off to one of the appropriate routines.
4495 @@ -174,6 +191,16 @@ bad_area:
4496 up_read(&mm->mmap_sem);
4497
4498 if (user_mode(regs)) {
4499 +
4500 +#ifdef CONFIG_PAX_PAGEEXEC
4501 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4502 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4503 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4504 + do_group_exit(SIGKILL);
4505 + }
4506 + }
4507 +#endif
4508 +
4509 if (exception_trace && printk_ratelimit())
4510 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4511 "sp %08lx ecr %lu\n",
4512 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4513 index 568885a..f8008df 100644
4514 --- a/arch/blackfin/include/asm/cache.h
4515 +++ b/arch/blackfin/include/asm/cache.h
4516 @@ -7,6 +7,7 @@
4517 #ifndef __ARCH_BLACKFIN_CACHE_H
4518 #define __ARCH_BLACKFIN_CACHE_H
4519
4520 +#include <linux/const.h>
4521 #include <linux/linkage.h> /* for asmlinkage */
4522
4523 /*
4524 @@ -14,7 +15,7 @@
4525 * Blackfin loads 32 bytes for cache
4526 */
4527 #define L1_CACHE_SHIFT 5
4528 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4529 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4530 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4531
4532 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4533 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4534 index aea2718..3639a60 100644
4535 --- a/arch/cris/include/arch-v10/arch/cache.h
4536 +++ b/arch/cris/include/arch-v10/arch/cache.h
4537 @@ -1,8 +1,9 @@
4538 #ifndef _ASM_ARCH_CACHE_H
4539 #define _ASM_ARCH_CACHE_H
4540
4541 +#include <linux/const.h>
4542 /* Etrax 100LX have 32-byte cache-lines. */
4543 -#define L1_CACHE_BYTES 32
4544 #define L1_CACHE_SHIFT 5
4545 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4546
4547 #endif /* _ASM_ARCH_CACHE_H */
4548 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4549 index 7caf25d..ee65ac5 100644
4550 --- a/arch/cris/include/arch-v32/arch/cache.h
4551 +++ b/arch/cris/include/arch-v32/arch/cache.h
4552 @@ -1,11 +1,12 @@
4553 #ifndef _ASM_CRIS_ARCH_CACHE_H
4554 #define _ASM_CRIS_ARCH_CACHE_H
4555
4556 +#include <linux/const.h>
4557 #include <arch/hwregs/dma.h>
4558
4559 /* A cache-line is 32 bytes. */
4560 -#define L1_CACHE_BYTES 32
4561 #define L1_CACHE_SHIFT 5
4562 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4563
4564 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4565
4566 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4567 index b86329d..6709906 100644
4568 --- a/arch/frv/include/asm/atomic.h
4569 +++ b/arch/frv/include/asm/atomic.h
4570 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4571 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4572 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
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 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4585 {
4586 int c, old;
4587 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4588 index 2797163..c2a401d 100644
4589 --- a/arch/frv/include/asm/cache.h
4590 +++ b/arch/frv/include/asm/cache.h
4591 @@ -12,10 +12,11 @@
4592 #ifndef __ASM_CACHE_H
4593 #define __ASM_CACHE_H
4594
4595 +#include <linux/const.h>
4596
4597 /* bytes per L1 cache line */
4598 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4599 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4600 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4601
4602 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4603 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4604 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4605 index 43901f2..0d8b865 100644
4606 --- a/arch/frv/include/asm/kmap_types.h
4607 +++ b/arch/frv/include/asm/kmap_types.h
4608 @@ -2,6 +2,6 @@
4609 #ifndef _ASM_KMAP_TYPES_H
4610 #define _ASM_KMAP_TYPES_H
4611
4612 -#define KM_TYPE_NR 17
4613 +#define KM_TYPE_NR 18
4614
4615 #endif
4616 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4617 index 836f147..4cf23f5 100644
4618 --- a/arch/frv/mm/elf-fdpic.c
4619 +++ b/arch/frv/mm/elf-fdpic.c
4620 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4621 {
4622 struct vm_area_struct *vma;
4623 struct vm_unmapped_area_info info;
4624 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4625
4626 if (len > TASK_SIZE)
4627 return -ENOMEM;
4628 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4629 if (addr) {
4630 addr = PAGE_ALIGN(addr);
4631 vma = find_vma(current->mm, addr);
4632 - if (TASK_SIZE - len >= addr &&
4633 - (!vma || addr + len <= vma->vm_start))
4634 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4635 goto success;
4636 }
4637
4638 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4639 info.high_limit = (current->mm->start_stack - 0x00200000);
4640 info.align_mask = 0;
4641 info.align_offset = 0;
4642 + info.threadstack_offset = offset;
4643 addr = vm_unmapped_area(&info);
4644 if (!(addr & ~PAGE_MASK))
4645 goto success;
4646 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4647 index f4ca594..adc72fd6 100644
4648 --- a/arch/hexagon/include/asm/cache.h
4649 +++ b/arch/hexagon/include/asm/cache.h
4650 @@ -21,9 +21,11 @@
4651 #ifndef __ASM_CACHE_H
4652 #define __ASM_CACHE_H
4653
4654 +#include <linux/const.h>
4655 +
4656 /* Bytes per L1 cache line */
4657 -#define L1_CACHE_SHIFT (5)
4658 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4659 +#define L1_CACHE_SHIFT 5
4660 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4661
4662 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4663 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4664 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4665 index 6e6fe18..a6ae668 100644
4666 --- a/arch/ia64/include/asm/atomic.h
4667 +++ b/arch/ia64/include/asm/atomic.h
4668 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4669 #define atomic64_inc(v) atomic64_add(1, (v))
4670 #define atomic64_dec(v) atomic64_sub(1, (v))
4671
4672 +#define atomic64_read_unchecked(v) atomic64_read(v)
4673 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4674 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4675 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4676 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4677 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4678 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4679 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4680 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4681 +
4682 /* Atomic operations are already serializing */
4683 #define smp_mb__before_atomic_dec() barrier()
4684 #define smp_mb__after_atomic_dec() barrier()
4685 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4686 index 988254a..e1ee885 100644
4687 --- a/arch/ia64/include/asm/cache.h
4688 +++ b/arch/ia64/include/asm/cache.h
4689 @@ -1,6 +1,7 @@
4690 #ifndef _ASM_IA64_CACHE_H
4691 #define _ASM_IA64_CACHE_H
4692
4693 +#include <linux/const.h>
4694
4695 /*
4696 * Copyright (C) 1998-2000 Hewlett-Packard Co
4697 @@ -9,7 +10,7 @@
4698
4699 /* Bytes per L1 (data) cache line. */
4700 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4701 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4702 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4703
4704 #ifdef CONFIG_SMP
4705 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4706 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4707 index 5a83c5c..4d7f553 100644
4708 --- a/arch/ia64/include/asm/elf.h
4709 +++ b/arch/ia64/include/asm/elf.h
4710 @@ -42,6 +42,13 @@
4711 */
4712 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4713
4714 +#ifdef CONFIG_PAX_ASLR
4715 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4716 +
4717 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4718 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4719 +#endif
4720 +
4721 #define PT_IA_64_UNWIND 0x70000001
4722
4723 /* IA-64 relocations: */
4724 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4725 index 96a8d92..617a1cf 100644
4726 --- a/arch/ia64/include/asm/pgalloc.h
4727 +++ b/arch/ia64/include/asm/pgalloc.h
4728 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4729 pgd_val(*pgd_entry) = __pa(pud);
4730 }
4731
4732 +static inline void
4733 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4734 +{
4735 + pgd_populate(mm, pgd_entry, pud);
4736 +}
4737 +
4738 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4739 {
4740 return quicklist_alloc(0, GFP_KERNEL, NULL);
4741 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4742 pud_val(*pud_entry) = __pa(pmd);
4743 }
4744
4745 +static inline void
4746 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4747 +{
4748 + pud_populate(mm, pud_entry, pmd);
4749 +}
4750 +
4751 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4752 {
4753 return quicklist_alloc(0, GFP_KERNEL, NULL);
4754 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4755 index 815810c..d60bd4c 100644
4756 --- a/arch/ia64/include/asm/pgtable.h
4757 +++ b/arch/ia64/include/asm/pgtable.h
4758 @@ -12,7 +12,7 @@
4759 * David Mosberger-Tang <davidm@hpl.hp.com>
4760 */
4761
4762 -
4763 +#include <linux/const.h>
4764 #include <asm/mman.h>
4765 #include <asm/page.h>
4766 #include <asm/processor.h>
4767 @@ -142,6 +142,17 @@
4768 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4769 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4770 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4771 +
4772 +#ifdef CONFIG_PAX_PAGEEXEC
4773 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4774 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4775 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4776 +#else
4777 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4778 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4779 +# define PAGE_COPY_NOEXEC PAGE_COPY
4780 +#endif
4781 +
4782 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4783 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4784 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4785 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4786 index 54ff557..70c88b7 100644
4787 --- a/arch/ia64/include/asm/spinlock.h
4788 +++ b/arch/ia64/include/asm/spinlock.h
4789 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4790 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4791
4792 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4793 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4794 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4795 }
4796
4797 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4798 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4799 index 449c8c0..18965fb 100644
4800 --- a/arch/ia64/include/asm/uaccess.h
4801 +++ b/arch/ia64/include/asm/uaccess.h
4802 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4803 static inline unsigned long
4804 __copy_to_user (void __user *to, const void *from, unsigned long count)
4805 {
4806 + if (count > INT_MAX)
4807 + return count;
4808 +
4809 + if (!__builtin_constant_p(count))
4810 + check_object_size(from, count, true);
4811 +
4812 return __copy_user(to, (__force void __user *) from, count);
4813 }
4814
4815 static inline unsigned long
4816 __copy_from_user (void *to, const void __user *from, unsigned long count)
4817 {
4818 + if (count > INT_MAX)
4819 + return count;
4820 +
4821 + if (!__builtin_constant_p(count))
4822 + check_object_size(to, count, false);
4823 +
4824 return __copy_user((__force void __user *) to, from, count);
4825 }
4826
4827 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4828 ({ \
4829 void __user *__cu_to = (to); \
4830 const void *__cu_from = (from); \
4831 - long __cu_len = (n); \
4832 + unsigned long __cu_len = (n); \
4833 \
4834 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4835 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4836 + if (!__builtin_constant_p(n)) \
4837 + check_object_size(__cu_from, __cu_len, true); \
4838 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4839 + } \
4840 __cu_len; \
4841 })
4842
4843 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4844 ({ \
4845 void *__cu_to = (to); \
4846 const void __user *__cu_from = (from); \
4847 - long __cu_len = (n); \
4848 + unsigned long __cu_len = (n); \
4849 \
4850 __chk_user_ptr(__cu_from); \
4851 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4852 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4853 + if (!__builtin_constant_p(n)) \
4854 + check_object_size(__cu_to, __cu_len, false); \
4855 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4856 + } \
4857 __cu_len; \
4858 })
4859
4860 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4861 index 2d67317..07d8bfa 100644
4862 --- a/arch/ia64/kernel/err_inject.c
4863 +++ b/arch/ia64/kernel/err_inject.c
4864 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4865 return NOTIFY_OK;
4866 }
4867
4868 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4869 +static struct notifier_block err_inject_cpu_notifier =
4870 {
4871 .notifier_call = err_inject_cpu_callback,
4872 };
4873 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4874 index d7396db..b33e873 100644
4875 --- a/arch/ia64/kernel/mca.c
4876 +++ b/arch/ia64/kernel/mca.c
4877 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4878 return NOTIFY_OK;
4879 }
4880
4881 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4882 +static struct notifier_block mca_cpu_notifier = {
4883 .notifier_call = mca_cpu_callback
4884 };
4885
4886 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4887 index 24603be..948052d 100644
4888 --- a/arch/ia64/kernel/module.c
4889 +++ b/arch/ia64/kernel/module.c
4890 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4891 void
4892 module_free (struct module *mod, void *module_region)
4893 {
4894 - if (mod && mod->arch.init_unw_table &&
4895 - module_region == mod->module_init) {
4896 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4897 unw_remove_unwind_table(mod->arch.init_unw_table);
4898 mod->arch.init_unw_table = NULL;
4899 }
4900 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4901 }
4902
4903 static inline int
4904 +in_init_rx (const struct module *mod, uint64_t addr)
4905 +{
4906 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4907 +}
4908 +
4909 +static inline int
4910 +in_init_rw (const struct module *mod, uint64_t addr)
4911 +{
4912 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4913 +}
4914 +
4915 +static inline int
4916 in_init (const struct module *mod, uint64_t addr)
4917 {
4918 - return addr - (uint64_t) mod->module_init < mod->init_size;
4919 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4920 +}
4921 +
4922 +static inline int
4923 +in_core_rx (const struct module *mod, uint64_t addr)
4924 +{
4925 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4926 +}
4927 +
4928 +static inline int
4929 +in_core_rw (const struct module *mod, uint64_t addr)
4930 +{
4931 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4932 }
4933
4934 static inline int
4935 in_core (const struct module *mod, uint64_t addr)
4936 {
4937 - return addr - (uint64_t) mod->module_core < mod->core_size;
4938 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4939 }
4940
4941 static inline int
4942 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4943 break;
4944
4945 case RV_BDREL:
4946 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4947 + if (in_init_rx(mod, val))
4948 + val -= (uint64_t) mod->module_init_rx;
4949 + else if (in_init_rw(mod, val))
4950 + val -= (uint64_t) mod->module_init_rw;
4951 + else if (in_core_rx(mod, val))
4952 + val -= (uint64_t) mod->module_core_rx;
4953 + else if (in_core_rw(mod, val))
4954 + val -= (uint64_t) mod->module_core_rw;
4955 break;
4956
4957 case RV_LTV:
4958 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4959 * addresses have been selected...
4960 */
4961 uint64_t gp;
4962 - if (mod->core_size > MAX_LTOFF)
4963 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4964 /*
4965 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4966 * at the end of the module.
4967 */
4968 - gp = mod->core_size - MAX_LTOFF / 2;
4969 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4970 else
4971 - gp = mod->core_size / 2;
4972 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4973 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4974 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4975 mod->arch.gp = gp;
4976 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4977 }
4978 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4979 index 2b3c2d7..a318d84 100644
4980 --- a/arch/ia64/kernel/palinfo.c
4981 +++ b/arch/ia64/kernel/palinfo.c
4982 @@ -980,7 +980,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4983 return NOTIFY_OK;
4984 }
4985
4986 -static struct notifier_block __refdata palinfo_cpu_notifier =
4987 +static struct notifier_block palinfo_cpu_notifier =
4988 {
4989 .notifier_call = palinfo_cpu_callback,
4990 .priority = 0,
4991 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4992 index 4bc580a..7767f24 100644
4993 --- a/arch/ia64/kernel/salinfo.c
4994 +++ b/arch/ia64/kernel/salinfo.c
4995 @@ -609,7 +609,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4996 return NOTIFY_OK;
4997 }
4998
4999 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5000 +static struct notifier_block salinfo_cpu_notifier =
5001 {
5002 .notifier_call = salinfo_cpu_callback,
5003 .priority = 0,
5004 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5005 index 41e33f8..65180b2 100644
5006 --- a/arch/ia64/kernel/sys_ia64.c
5007 +++ b/arch/ia64/kernel/sys_ia64.c
5008 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5009 unsigned long align_mask = 0;
5010 struct mm_struct *mm = current->mm;
5011 struct vm_unmapped_area_info info;
5012 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5013
5014 if (len > RGN_MAP_LIMIT)
5015 return -ENOMEM;
5016 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5017 if (REGION_NUMBER(addr) == RGN_HPAGE)
5018 addr = 0;
5019 #endif
5020 +
5021 +#ifdef CONFIG_PAX_RANDMMAP
5022 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5023 + addr = mm->free_area_cache;
5024 + else
5025 +#endif
5026 +
5027 if (!addr)
5028 addr = TASK_UNMAPPED_BASE;
5029
5030 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5031 info.high_limit = TASK_SIZE;
5032 info.align_mask = align_mask;
5033 info.align_offset = 0;
5034 + info.threadstack_offset = offset;
5035 return vm_unmapped_area(&info);
5036 }
5037
5038 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5039 index dc00b2c..cce53c2 100644
5040 --- a/arch/ia64/kernel/topology.c
5041 +++ b/arch/ia64/kernel/topology.c
5042 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5043 return NOTIFY_OK;
5044 }
5045
5046 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5047 +static struct notifier_block cache_cpu_notifier =
5048 {
5049 .notifier_call = cache_cpu_callback
5050 };
5051 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5052 index 0ccb28f..8992469 100644
5053 --- a/arch/ia64/kernel/vmlinux.lds.S
5054 +++ b/arch/ia64/kernel/vmlinux.lds.S
5055 @@ -198,7 +198,7 @@ SECTIONS {
5056 /* Per-cpu data: */
5057 . = ALIGN(PERCPU_PAGE_SIZE);
5058 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5059 - __phys_per_cpu_start = __per_cpu_load;
5060 + __phys_per_cpu_start = per_cpu_load;
5061 /*
5062 * ensure percpu data fits
5063 * into percpu page size
5064 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5065 index 6cf0341..d352594 100644
5066 --- a/arch/ia64/mm/fault.c
5067 +++ b/arch/ia64/mm/fault.c
5068 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5069 return pte_present(pte);
5070 }
5071
5072 +#ifdef CONFIG_PAX_PAGEEXEC
5073 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5074 +{
5075 + unsigned long i;
5076 +
5077 + printk(KERN_ERR "PAX: bytes at PC: ");
5078 + for (i = 0; i < 8; i++) {
5079 + unsigned int c;
5080 + if (get_user(c, (unsigned int *)pc+i))
5081 + printk(KERN_CONT "???????? ");
5082 + else
5083 + printk(KERN_CONT "%08x ", c);
5084 + }
5085 + printk("\n");
5086 +}
5087 +#endif
5088 +
5089 # define VM_READ_BIT 0
5090 # define VM_WRITE_BIT 1
5091 # define VM_EXEC_BIT 2
5092 @@ -149,8 +166,21 @@ retry:
5093 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5094 goto bad_area;
5095
5096 - if ((vma->vm_flags & mask) != mask)
5097 + if ((vma->vm_flags & mask) != mask) {
5098 +
5099 +#ifdef CONFIG_PAX_PAGEEXEC
5100 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5101 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5102 + goto bad_area;
5103 +
5104 + up_read(&mm->mmap_sem);
5105 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5106 + do_group_exit(SIGKILL);
5107 + }
5108 +#endif
5109 +
5110 goto bad_area;
5111 + }
5112
5113 /*
5114 * If for any reason at all we couldn't handle the fault, make
5115 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5116 index 76069c1..c2aa816 100644
5117 --- a/arch/ia64/mm/hugetlbpage.c
5118 +++ b/arch/ia64/mm/hugetlbpage.c
5119 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5120 unsigned long pgoff, unsigned long flags)
5121 {
5122 struct vm_unmapped_area_info info;
5123 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5124
5125 if (len > RGN_MAP_LIMIT)
5126 return -ENOMEM;
5127 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5128 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5129 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5130 info.align_offset = 0;
5131 + info.threadstack_offset = offset;
5132 return vm_unmapped_area(&info);
5133 }
5134
5135 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5136 index d1fe4b4..2628f37 100644
5137 --- a/arch/ia64/mm/init.c
5138 +++ b/arch/ia64/mm/init.c
5139 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5140 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5141 vma->vm_end = vma->vm_start + PAGE_SIZE;
5142 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5143 +
5144 +#ifdef CONFIG_PAX_PAGEEXEC
5145 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5146 + vma->vm_flags &= ~VM_EXEC;
5147 +
5148 +#ifdef CONFIG_PAX_MPROTECT
5149 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5150 + vma->vm_flags &= ~VM_MAYEXEC;
5151 +#endif
5152 +
5153 + }
5154 +#endif
5155 +
5156 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5157 down_write(&current->mm->mmap_sem);
5158 if (insert_vm_struct(current->mm, vma)) {
5159 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5160 index 40b3ee9..8c2c112 100644
5161 --- a/arch/m32r/include/asm/cache.h
5162 +++ b/arch/m32r/include/asm/cache.h
5163 @@ -1,8 +1,10 @@
5164 #ifndef _ASM_M32R_CACHE_H
5165 #define _ASM_M32R_CACHE_H
5166
5167 +#include <linux/const.h>
5168 +
5169 /* L1 cache line size */
5170 #define L1_CACHE_SHIFT 4
5171 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5172 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5173
5174 #endif /* _ASM_M32R_CACHE_H */
5175 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5176 index 82abd15..d95ae5d 100644
5177 --- a/arch/m32r/lib/usercopy.c
5178 +++ b/arch/m32r/lib/usercopy.c
5179 @@ -14,6 +14,9 @@
5180 unsigned long
5181 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5182 {
5183 + if ((long)n < 0)
5184 + return n;
5185 +
5186 prefetch(from);
5187 if (access_ok(VERIFY_WRITE, to, n))
5188 __copy_user(to,from,n);
5189 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5190 unsigned long
5191 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5192 {
5193 + if ((long)n < 0)
5194 + return n;
5195 +
5196 prefetchw(to);
5197 if (access_ok(VERIFY_READ, from, n))
5198 __copy_user_zeroing(to,from,n);
5199 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5200 index 0395c51..5f26031 100644
5201 --- a/arch/m68k/include/asm/cache.h
5202 +++ b/arch/m68k/include/asm/cache.h
5203 @@ -4,9 +4,11 @@
5204 #ifndef __ARCH_M68K_CACHE_H
5205 #define __ARCH_M68K_CACHE_H
5206
5207 +#include <linux/const.h>
5208 +
5209 /* bytes per L1 cache line */
5210 #define L1_CACHE_SHIFT 4
5211 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5212 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5213
5214 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5215
5216 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5217 index 3c52fa6..11b2ad8 100644
5218 --- a/arch/metag/mm/hugetlbpage.c
5219 +++ b/arch/metag/mm/hugetlbpage.c
5220 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5221 info.high_limit = TASK_SIZE;
5222 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5223 info.align_offset = 0;
5224 + info.threadstack_offset = 0;
5225 return vm_unmapped_area(&info);
5226 }
5227
5228 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5229 index 4efe96a..60e8699 100644
5230 --- a/arch/microblaze/include/asm/cache.h
5231 +++ b/arch/microblaze/include/asm/cache.h
5232 @@ -13,11 +13,12 @@
5233 #ifndef _ASM_MICROBLAZE_CACHE_H
5234 #define _ASM_MICROBLAZE_CACHE_H
5235
5236 +#include <linux/const.h>
5237 #include <asm/registers.h>
5238
5239 #define L1_CACHE_SHIFT 5
5240 /* word-granular cache in microblaze */
5241 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5242 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5243
5244 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5245
5246 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5247 index 08b6079..eb272cf 100644
5248 --- a/arch/mips/include/asm/atomic.h
5249 +++ b/arch/mips/include/asm/atomic.h
5250 @@ -21,6 +21,10 @@
5251 #include <asm/cmpxchg.h>
5252 #include <asm/war.h>
5253
5254 +#ifdef CONFIG_GENERIC_ATOMIC64
5255 +#include <asm-generic/atomic64.h>
5256 +#endif
5257 +
5258 #define ATOMIC_INIT(i) { (i) }
5259
5260 /*
5261 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5262 */
5263 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5264
5265 +#define atomic64_read_unchecked(v) atomic64_read(v)
5266 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5267 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5268 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5269 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5270 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5271 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5272 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5273 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5274 +
5275 #endif /* CONFIG_64BIT */
5276
5277 /*
5278 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5279 index b4db69f..8f3b093 100644
5280 --- a/arch/mips/include/asm/cache.h
5281 +++ b/arch/mips/include/asm/cache.h
5282 @@ -9,10 +9,11 @@
5283 #ifndef _ASM_CACHE_H
5284 #define _ASM_CACHE_H
5285
5286 +#include <linux/const.h>
5287 #include <kmalloc.h>
5288
5289 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5290 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5291 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5292
5293 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5294 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5295 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5296 index cf3ae24..238d22f 100644
5297 --- a/arch/mips/include/asm/elf.h
5298 +++ b/arch/mips/include/asm/elf.h
5299 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5300 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5301 #endif
5302
5303 +#ifdef CONFIG_PAX_ASLR
5304 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5305 +
5306 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5307 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5308 +#endif
5309 +
5310 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5311 struct linux_binprm;
5312 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5313 int uses_interp);
5314
5315 -struct mm_struct;
5316 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5317 -#define arch_randomize_brk arch_randomize_brk
5318 -
5319 #endif /* _ASM_ELF_H */
5320 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5321 index c1f6afa..38cc6e9 100644
5322 --- a/arch/mips/include/asm/exec.h
5323 +++ b/arch/mips/include/asm/exec.h
5324 @@ -12,6 +12,6 @@
5325 #ifndef _ASM_EXEC_H
5326 #define _ASM_EXEC_H
5327
5328 -extern unsigned long arch_align_stack(unsigned long sp);
5329 +#define arch_align_stack(x) ((x) & ~0xfUL)
5330
5331 #endif /* _ASM_EXEC_H */
5332 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5333 index f59552f..3abe9b9 100644
5334 --- a/arch/mips/include/asm/page.h
5335 +++ b/arch/mips/include/asm/page.h
5336 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5337 #ifdef CONFIG_CPU_MIPS32
5338 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5339 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5340 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5341 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5342 #else
5343 typedef struct { unsigned long long pte; } pte_t;
5344 #define pte_val(x) ((x).pte)
5345 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5346 index 881d18b..cea38bc 100644
5347 --- a/arch/mips/include/asm/pgalloc.h
5348 +++ b/arch/mips/include/asm/pgalloc.h
5349 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5350 {
5351 set_pud(pud, __pud((unsigned long)pmd));
5352 }
5353 +
5354 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5355 +{
5356 + pud_populate(mm, pud, pmd);
5357 +}
5358 #endif
5359
5360 /*
5361 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5362 index 895320e..bf63e10 100644
5363 --- a/arch/mips/include/asm/thread_info.h
5364 +++ b/arch/mips/include/asm/thread_info.h
5365 @@ -115,6 +115,8 @@ static inline struct thread_info *current_thread_info(void)
5366 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5367 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5368 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5369 +/* li takes a 32bit immediate */
5370 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5371 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5372
5373 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5374 @@ -130,15 +132,18 @@ static inline struct thread_info *current_thread_info(void)
5375 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5376 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5377 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5378 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5379 +
5380 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5381
5382 /* work to do in syscall_trace_leave() */
5383 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5384 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5385
5386 /* work to do on interrupt/exception return */
5387 #define _TIF_WORK_MASK \
5388 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5389 /* work to do on any return to u-space */
5390 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5391 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5392
5393 #endif /* __KERNEL__ */
5394
5395 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5396 index 1188e00..41cf144 100644
5397 --- a/arch/mips/kernel/binfmt_elfn32.c
5398 +++ b/arch/mips/kernel/binfmt_elfn32.c
5399 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5400 #undef ELF_ET_DYN_BASE
5401 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5402
5403 +#ifdef CONFIG_PAX_ASLR
5404 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5405 +
5406 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5407 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5408 +#endif
5409 +
5410 #include <asm/processor.h>
5411 #include <linux/module.h>
5412 #include <linux/elfcore.h>
5413 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5414 index 202e581..689ca79 100644
5415 --- a/arch/mips/kernel/binfmt_elfo32.c
5416 +++ b/arch/mips/kernel/binfmt_elfo32.c
5417 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5418 #undef ELF_ET_DYN_BASE
5419 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5420
5421 +#ifdef CONFIG_PAX_ASLR
5422 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5423 +
5424 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5425 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5426 +#endif
5427 +
5428 #include <asm/processor.h>
5429
5430 /*
5431 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5432 index c6a041d..b3e7318 100644
5433 --- a/arch/mips/kernel/process.c
5434 +++ b/arch/mips/kernel/process.c
5435 @@ -563,15 +563,3 @@ unsigned long get_wchan(struct task_struct *task)
5436 out:
5437 return pc;
5438 }
5439 -
5440 -/*
5441 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5442 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5443 - */
5444 -unsigned long arch_align_stack(unsigned long sp)
5445 -{
5446 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5447 - sp -= get_random_int() & ~PAGE_MASK;
5448 -
5449 - return sp & ALMASK;
5450 -}
5451 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5452 index 9c6299c..2fb4c22 100644
5453 --- a/arch/mips/kernel/ptrace.c
5454 +++ b/arch/mips/kernel/ptrace.c
5455 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5456 return arch;
5457 }
5458
5459 +#ifdef CONFIG_GRKERNSEC_SETXID
5460 +extern void gr_delayed_cred_worker(void);
5461 +#endif
5462 +
5463 /*
5464 * Notification of system call entry/exit
5465 * - triggered by current->work.syscall_trace
5466 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5467 /* do the secure computing check first */
5468 secure_computing_strict(regs->regs[2]);
5469
5470 +#ifdef CONFIG_GRKERNSEC_SETXID
5471 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5472 + gr_delayed_cred_worker();
5473 +#endif
5474 +
5475 if (!(current->ptrace & PT_PTRACED))
5476 goto out;
5477
5478 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5479 index 9b36424..e7f4154 100644
5480 --- a/arch/mips/kernel/scall32-o32.S
5481 +++ b/arch/mips/kernel/scall32-o32.S
5482 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5483
5484 stack_done:
5485 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5486 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5487 + li t1, _TIF_SYSCALL_WORK
5488 and t0, t1
5489 bnez t0, syscall_trace_entry # -> yes
5490
5491 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5492 index 97a5909..59622f8 100644
5493 --- a/arch/mips/kernel/scall64-64.S
5494 +++ b/arch/mips/kernel/scall64-64.S
5495 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5496
5497 sd a3, PT_R26(sp) # save a3 for syscall restarting
5498
5499 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5500 + li t1, _TIF_SYSCALL_WORK
5501 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5502 and t0, t1, t0
5503 bnez t0, syscall_trace_entry
5504 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5505 index edcb659..fb2ab09 100644
5506 --- a/arch/mips/kernel/scall64-n32.S
5507 +++ b/arch/mips/kernel/scall64-n32.S
5508 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5509
5510 sd a3, PT_R26(sp) # save a3 for syscall restarting
5511
5512 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5513 + li t1, _TIF_SYSCALL_WORK
5514 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5515 and t0, t1, t0
5516 bnez t0, n32_syscall_trace_entry
5517 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5518 index 74f485d..47d2c38 100644
5519 --- a/arch/mips/kernel/scall64-o32.S
5520 +++ b/arch/mips/kernel/scall64-o32.S
5521 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5522 PTR 4b, bad_stack
5523 .previous
5524
5525 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5526 + li t1, _TIF_SYSCALL_WORK
5527 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5528 and t0, t1, t0
5529 bnez t0, trace_a_syscall
5530 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5531 index 0fead53..a2c0fb5 100644
5532 --- a/arch/mips/mm/fault.c
5533 +++ b/arch/mips/mm/fault.c
5534 @@ -27,6 +27,23 @@
5535 #include <asm/highmem.h> /* For VMALLOC_END */
5536 #include <linux/kdebug.h>
5537
5538 +#ifdef CONFIG_PAX_PAGEEXEC
5539 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5540 +{
5541 + unsigned long i;
5542 +
5543 + printk(KERN_ERR "PAX: bytes at PC: ");
5544 + for (i = 0; i < 5; i++) {
5545 + unsigned int c;
5546 + if (get_user(c, (unsigned int *)pc+i))
5547 + printk(KERN_CONT "???????? ");
5548 + else
5549 + printk(KERN_CONT "%08x ", c);
5550 + }
5551 + printk("\n");
5552 +}
5553 +#endif
5554 +
5555 /*
5556 * This routine handles page faults. It determines the address,
5557 * and the problem, and then passes it off to one of the appropriate
5558 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5559 index 7e5fe27..9656513 100644
5560 --- a/arch/mips/mm/mmap.c
5561 +++ b/arch/mips/mm/mmap.c
5562 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5563 struct vm_area_struct *vma;
5564 unsigned long addr = addr0;
5565 int do_color_align;
5566 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5567 struct vm_unmapped_area_info info;
5568
5569 if (unlikely(len > TASK_SIZE))
5570 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5571 do_color_align = 1;
5572
5573 /* requesting a specific address */
5574 +
5575 +#ifdef CONFIG_PAX_RANDMMAP
5576 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5577 +#endif
5578 +
5579 if (addr) {
5580 if (do_color_align)
5581 addr = COLOUR_ALIGN(addr, pgoff);
5582 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5583 addr = PAGE_ALIGN(addr);
5584
5585 vma = find_vma(mm, addr);
5586 - if (TASK_SIZE - len >= addr &&
5587 - (!vma || addr + len <= vma->vm_start))
5588 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5589 return addr;
5590 }
5591
5592 info.length = len;
5593 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5594 info.align_offset = pgoff << PAGE_SHIFT;
5595 + info.threadstack_offset = offset;
5596
5597 if (dir == DOWN) {
5598 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5599 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5600 {
5601 unsigned long random_factor = 0UL;
5602
5603 +#ifdef CONFIG_PAX_RANDMMAP
5604 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5605 +#endif
5606 +
5607 if (current->flags & PF_RANDOMIZE) {
5608 random_factor = get_random_int();
5609 random_factor = random_factor << PAGE_SHIFT;
5610 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5611
5612 if (mmap_is_legacy()) {
5613 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5614 +
5615 +#ifdef CONFIG_PAX_RANDMMAP
5616 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5617 + mm->mmap_base += mm->delta_mmap;
5618 +#endif
5619 +
5620 mm->get_unmapped_area = arch_get_unmapped_area;
5621 mm->unmap_area = arch_unmap_area;
5622 } else {
5623 mm->mmap_base = mmap_base(random_factor);
5624 +
5625 +#ifdef CONFIG_PAX_RANDMMAP
5626 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5627 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5628 +#endif
5629 +
5630 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5631 mm->unmap_area = arch_unmap_area_topdown;
5632 }
5633 }
5634
5635 -static inline unsigned long brk_rnd(void)
5636 -{
5637 - unsigned long rnd = get_random_int();
5638 -
5639 - rnd = rnd << PAGE_SHIFT;
5640 - /* 8MB for 32bit, 256MB for 64bit */
5641 - if (TASK_IS_32BIT_ADDR)
5642 - rnd = rnd & 0x7ffffful;
5643 - else
5644 - rnd = rnd & 0xffffffful;
5645 -
5646 - return rnd;
5647 -}
5648 -
5649 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5650 -{
5651 - unsigned long base = mm->brk;
5652 - unsigned long ret;
5653 -
5654 - ret = PAGE_ALIGN(base + brk_rnd());
5655 -
5656 - if (ret < mm->brk)
5657 - return mm->brk;
5658 -
5659 - return ret;
5660 -}
5661 -
5662 int __virt_addr_valid(const volatile void *kaddr)
5663 {
5664 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5665 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5666 index 967d144..db12197 100644
5667 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5668 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5669 @@ -11,12 +11,14 @@
5670 #ifndef _ASM_PROC_CACHE_H
5671 #define _ASM_PROC_CACHE_H
5672
5673 +#include <linux/const.h>
5674 +
5675 /* L1 cache */
5676
5677 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5678 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5679 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5680 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5681 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5682 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5683
5684 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5685 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5686 index bcb5df2..84fabd2 100644
5687 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5688 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5689 @@ -16,13 +16,15 @@
5690 #ifndef _ASM_PROC_CACHE_H
5691 #define _ASM_PROC_CACHE_H
5692
5693 +#include <linux/const.h>
5694 +
5695 /*
5696 * L1 cache
5697 */
5698 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5699 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5700 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5701 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5702 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5703 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5704
5705 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5706 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5707 index 4ce7a01..449202a 100644
5708 --- a/arch/openrisc/include/asm/cache.h
5709 +++ b/arch/openrisc/include/asm/cache.h
5710 @@ -19,11 +19,13 @@
5711 #ifndef __ASM_OPENRISC_CACHE_H
5712 #define __ASM_OPENRISC_CACHE_H
5713
5714 +#include <linux/const.h>
5715 +
5716 /* FIXME: How can we replace these with values from the CPU...
5717 * they shouldn't be hard-coded!
5718 */
5719
5720 -#define L1_CACHE_BYTES 16
5721 #define L1_CACHE_SHIFT 4
5722 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5723
5724 #endif /* __ASM_OPENRISC_CACHE_H */
5725 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5726 index 472886c..00e7df9 100644
5727 --- a/arch/parisc/include/asm/atomic.h
5728 +++ b/arch/parisc/include/asm/atomic.h
5729 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
5730 return dec;
5731 }
5732
5733 +#define atomic64_read_unchecked(v) atomic64_read(v)
5734 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5735 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5736 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5737 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5738 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5739 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5740 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5741 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5742 +
5743 #endif /* !CONFIG_64BIT */
5744
5745
5746 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5747 index 47f11c7..3420df2 100644
5748 --- a/arch/parisc/include/asm/cache.h
5749 +++ b/arch/parisc/include/asm/cache.h
5750 @@ -5,6 +5,7 @@
5751 #ifndef __ARCH_PARISC_CACHE_H
5752 #define __ARCH_PARISC_CACHE_H
5753
5754 +#include <linux/const.h>
5755
5756 /*
5757 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5758 @@ -15,13 +16,13 @@
5759 * just ruin performance.
5760 */
5761 #ifdef CONFIG_PA20
5762 -#define L1_CACHE_BYTES 64
5763 #define L1_CACHE_SHIFT 6
5764 #else
5765 -#define L1_CACHE_BYTES 32
5766 #define L1_CACHE_SHIFT 5
5767 #endif
5768
5769 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5770 +
5771 #ifndef __ASSEMBLY__
5772
5773 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5774 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5775 index ad2b503..bdf1651 100644
5776 --- a/arch/parisc/include/asm/elf.h
5777 +++ b/arch/parisc/include/asm/elf.h
5778 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5779
5780 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5781
5782 +#ifdef CONFIG_PAX_ASLR
5783 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5784 +
5785 +#define PAX_DELTA_MMAP_LEN 16
5786 +#define PAX_DELTA_STACK_LEN 16
5787 +#endif
5788 +
5789 /* This yields a mask that user programs can use to figure out what
5790 instruction set this CPU supports. This could be done in user space,
5791 but it's not easy, and we've already done it here. */
5792 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5793 index fc987a1..6e068ef 100644
5794 --- a/arch/parisc/include/asm/pgalloc.h
5795 +++ b/arch/parisc/include/asm/pgalloc.h
5796 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5797 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5798 }
5799
5800 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5801 +{
5802 + pgd_populate(mm, pgd, pmd);
5803 +}
5804 +
5805 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5806 {
5807 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5808 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5809 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5810 #define pmd_free(mm, x) do { } while (0)
5811 #define pgd_populate(mm, pmd, pte) BUG()
5812 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5813
5814 #endif
5815
5816 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5817 index 1e40d7f..a3eb445 100644
5818 --- a/arch/parisc/include/asm/pgtable.h
5819 +++ b/arch/parisc/include/asm/pgtable.h
5820 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5821 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5822 #define PAGE_COPY PAGE_EXECREAD
5823 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5824 +
5825 +#ifdef CONFIG_PAX_PAGEEXEC
5826 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5827 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5828 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5829 +#else
5830 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5831 +# define PAGE_COPY_NOEXEC PAGE_COPY
5832 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5833 +#endif
5834 +
5835 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5836 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5837 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5838 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5839 index e0a8235..ce2f1e1 100644
5840 --- a/arch/parisc/include/asm/uaccess.h
5841 +++ b/arch/parisc/include/asm/uaccess.h
5842 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5843 const void __user *from,
5844 unsigned long n)
5845 {
5846 - int sz = __compiletime_object_size(to);
5847 + size_t sz = __compiletime_object_size(to);
5848 int ret = -EFAULT;
5849
5850 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5851 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5852 ret = __copy_from_user(to, from, n);
5853 else
5854 copy_from_user_overflow();
5855 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5856 index 2a625fb..9908930 100644
5857 --- a/arch/parisc/kernel/module.c
5858 +++ b/arch/parisc/kernel/module.c
5859 @@ -98,16 +98,38 @@
5860
5861 /* three functions to determine where in the module core
5862 * or init pieces the location is */
5863 +static inline int in_init_rx(struct module *me, void *loc)
5864 +{
5865 + return (loc >= me->module_init_rx &&
5866 + loc < (me->module_init_rx + me->init_size_rx));
5867 +}
5868 +
5869 +static inline int in_init_rw(struct module *me, void *loc)
5870 +{
5871 + return (loc >= me->module_init_rw &&
5872 + loc < (me->module_init_rw + me->init_size_rw));
5873 +}
5874 +
5875 static inline int in_init(struct module *me, void *loc)
5876 {
5877 - return (loc >= me->module_init &&
5878 - loc <= (me->module_init + me->init_size));
5879 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5880 +}
5881 +
5882 +static inline int in_core_rx(struct module *me, void *loc)
5883 +{
5884 + return (loc >= me->module_core_rx &&
5885 + loc < (me->module_core_rx + me->core_size_rx));
5886 +}
5887 +
5888 +static inline int in_core_rw(struct module *me, void *loc)
5889 +{
5890 + return (loc >= me->module_core_rw &&
5891 + loc < (me->module_core_rw + me->core_size_rw));
5892 }
5893
5894 static inline int in_core(struct module *me, void *loc)
5895 {
5896 - return (loc >= me->module_core &&
5897 - loc <= (me->module_core + me->core_size));
5898 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5899 }
5900
5901 static inline int in_local(struct module *me, void *loc)
5902 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5903 }
5904
5905 /* align things a bit */
5906 - me->core_size = ALIGN(me->core_size, 16);
5907 - me->arch.got_offset = me->core_size;
5908 - me->core_size += gots * sizeof(struct got_entry);
5909 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5910 + me->arch.got_offset = me->core_size_rw;
5911 + me->core_size_rw += gots * sizeof(struct got_entry);
5912
5913 - me->core_size = ALIGN(me->core_size, 16);
5914 - me->arch.fdesc_offset = me->core_size;
5915 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5916 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5917 + me->arch.fdesc_offset = me->core_size_rw;
5918 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5919
5920 me->arch.got_max = gots;
5921 me->arch.fdesc_max = fdescs;
5922 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5923
5924 BUG_ON(value == 0);
5925
5926 - got = me->module_core + me->arch.got_offset;
5927 + got = me->module_core_rw + me->arch.got_offset;
5928 for (i = 0; got[i].addr; i++)
5929 if (got[i].addr == value)
5930 goto out;
5931 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5932 #ifdef CONFIG_64BIT
5933 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5934 {
5935 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5936 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5937
5938 if (!value) {
5939 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5940 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5941
5942 /* Create new one */
5943 fdesc->addr = value;
5944 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5945 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5946 return (Elf_Addr)fdesc;
5947 }
5948 #endif /* CONFIG_64BIT */
5949 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5950
5951 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5952 end = table + sechdrs[me->arch.unwind_section].sh_size;
5953 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5954 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5955
5956 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5957 me->arch.unwind_section, table, end, gp);
5958 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5959 index 5dfd248..64914ac 100644
5960 --- a/arch/parisc/kernel/sys_parisc.c
5961 +++ b/arch/parisc/kernel/sys_parisc.c
5962 @@ -33,9 +33,11 @@
5963 #include <linux/utsname.h>
5964 #include <linux/personality.h>
5965
5966 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5967 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5968 + unsigned long flags)
5969 {
5970 struct vm_unmapped_area_info info;
5971 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5972
5973 info.flags = 0;
5974 info.length = len;
5975 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5976 info.high_limit = TASK_SIZE;
5977 info.align_mask = 0;
5978 info.align_offset = 0;
5979 + info.threadstack_offset = offset;
5980 return vm_unmapped_area(&info);
5981 }
5982
5983 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5984 return (unsigned long) mapping >> 8;
5985 }
5986
5987 -static unsigned long get_shared_area(struct address_space *mapping,
5988 - unsigned long addr, unsigned long len, unsigned long pgoff)
5989 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5990 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5991 {
5992 struct vm_unmapped_area_info info;
5993 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5994
5995 info.flags = 0;
5996 info.length = len;
5997 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5998 info.high_limit = TASK_SIZE;
5999 info.align_mask = PAGE_MASK & (SHMLBA - 1);
6000 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
6001 + info.threadstack_offset = offset;
6002 return vm_unmapped_area(&info);
6003 }
6004
6005 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6006 return -EINVAL;
6007 return addr;
6008 }
6009 - if (!addr)
6010 + if (!addr) {
6011 addr = TASK_UNMAPPED_BASE;
6012
6013 +#ifdef CONFIG_PAX_RANDMMAP
6014 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
6015 + addr += current->mm->delta_mmap;
6016 +#endif
6017 +
6018 + }
6019 +
6020 if (filp) {
6021 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6022 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6023 } else if(flags & MAP_SHARED) {
6024 - addr = get_shared_area(NULL, addr, len, pgoff);
6025 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6026 } else {
6027 - addr = get_unshared_area(addr, len);
6028 + addr = get_unshared_area(filp, addr, len, flags);
6029 }
6030 return addr;
6031 }
6032 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6033 index 04e47c6..7a8faf6 100644
6034 --- a/arch/parisc/kernel/traps.c
6035 +++ b/arch/parisc/kernel/traps.c
6036 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6037
6038 down_read(&current->mm->mmap_sem);
6039 vma = find_vma(current->mm,regs->iaoq[0]);
6040 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6041 - && (vma->vm_flags & VM_EXEC)) {
6042 -
6043 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6044 fault_address = regs->iaoq[0];
6045 fault_space = regs->iasq[0];
6046
6047 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6048 index f247a34..dc0f219 100644
6049 --- a/arch/parisc/mm/fault.c
6050 +++ b/arch/parisc/mm/fault.c
6051 @@ -15,6 +15,7 @@
6052 #include <linux/sched.h>
6053 #include <linux/interrupt.h>
6054 #include <linux/module.h>
6055 +#include <linux/unistd.h>
6056
6057 #include <asm/uaccess.h>
6058 #include <asm/traps.h>
6059 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6060 static unsigned long
6061 parisc_acctyp(unsigned long code, unsigned int inst)
6062 {
6063 - if (code == 6 || code == 16)
6064 + if (code == 6 || code == 7 || code == 16)
6065 return VM_EXEC;
6066
6067 switch (inst & 0xf0000000) {
6068 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6069 }
6070 #endif
6071
6072 +#ifdef CONFIG_PAX_PAGEEXEC
6073 +/*
6074 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6075 + *
6076 + * returns 1 when task should be killed
6077 + * 2 when rt_sigreturn trampoline was detected
6078 + * 3 when unpatched PLT trampoline was detected
6079 + */
6080 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6081 +{
6082 +
6083 +#ifdef CONFIG_PAX_EMUPLT
6084 + int err;
6085 +
6086 + do { /* PaX: unpatched PLT emulation */
6087 + unsigned int bl, depwi;
6088 +
6089 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6090 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6091 +
6092 + if (err)
6093 + break;
6094 +
6095 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6096 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6097 +
6098 + err = get_user(ldw, (unsigned int *)addr);
6099 + err |= get_user(bv, (unsigned int *)(addr+4));
6100 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6101 +
6102 + if (err)
6103 + break;
6104 +
6105 + if (ldw == 0x0E801096U &&
6106 + bv == 0xEAC0C000U &&
6107 + ldw2 == 0x0E881095U)
6108 + {
6109 + unsigned int resolver, map;
6110 +
6111 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6112 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6113 + if (err)
6114 + break;
6115 +
6116 + regs->gr[20] = instruction_pointer(regs)+8;
6117 + regs->gr[21] = map;
6118 + regs->gr[22] = resolver;
6119 + regs->iaoq[0] = resolver | 3UL;
6120 + regs->iaoq[1] = regs->iaoq[0] + 4;
6121 + return 3;
6122 + }
6123 + }
6124 + } while (0);
6125 +#endif
6126 +
6127 +#ifdef CONFIG_PAX_EMUTRAMP
6128 +
6129 +#ifndef CONFIG_PAX_EMUSIGRT
6130 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6131 + return 1;
6132 +#endif
6133 +
6134 + do { /* PaX: rt_sigreturn emulation */
6135 + unsigned int ldi1, ldi2, bel, nop;
6136 +
6137 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6138 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6139 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6140 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6141 +
6142 + if (err)
6143 + break;
6144 +
6145 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6146 + ldi2 == 0x3414015AU &&
6147 + bel == 0xE4008200U &&
6148 + nop == 0x08000240U)
6149 + {
6150 + regs->gr[25] = (ldi1 & 2) >> 1;
6151 + regs->gr[20] = __NR_rt_sigreturn;
6152 + regs->gr[31] = regs->iaoq[1] + 16;
6153 + regs->sr[0] = regs->iasq[1];
6154 + regs->iaoq[0] = 0x100UL;
6155 + regs->iaoq[1] = regs->iaoq[0] + 4;
6156 + regs->iasq[0] = regs->sr[2];
6157 + regs->iasq[1] = regs->sr[2];
6158 + return 2;
6159 + }
6160 + } while (0);
6161 +#endif
6162 +
6163 + return 1;
6164 +}
6165 +
6166 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6167 +{
6168 + unsigned long i;
6169 +
6170 + printk(KERN_ERR "PAX: bytes at PC: ");
6171 + for (i = 0; i < 5; i++) {
6172 + unsigned int c;
6173 + if (get_user(c, (unsigned int *)pc+i))
6174 + printk(KERN_CONT "???????? ");
6175 + else
6176 + printk(KERN_CONT "%08x ", c);
6177 + }
6178 + printk("\n");
6179 +}
6180 +#endif
6181 +
6182 int fixup_exception(struct pt_regs *regs)
6183 {
6184 const struct exception_table_entry *fix;
6185 @@ -194,8 +305,33 @@ good_area:
6186
6187 acc_type = parisc_acctyp(code,regs->iir);
6188
6189 - if ((vma->vm_flags & acc_type) != acc_type)
6190 + if ((vma->vm_flags & acc_type) != acc_type) {
6191 +
6192 +#ifdef CONFIG_PAX_PAGEEXEC
6193 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6194 + (address & ~3UL) == instruction_pointer(regs))
6195 + {
6196 + up_read(&mm->mmap_sem);
6197 + switch (pax_handle_fetch_fault(regs)) {
6198 +
6199 +#ifdef CONFIG_PAX_EMUPLT
6200 + case 3:
6201 + return;
6202 +#endif
6203 +
6204 +#ifdef CONFIG_PAX_EMUTRAMP
6205 + case 2:
6206 + return;
6207 +#endif
6208 +
6209 + }
6210 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6211 + do_group_exit(SIGKILL);
6212 + }
6213 +#endif
6214 +
6215 goto bad_area;
6216 + }
6217
6218 /*
6219 * If for any reason at all we couldn't handle the fault, make
6220 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6221 index e3b1d41..8e81edf 100644
6222 --- a/arch/powerpc/include/asm/atomic.h
6223 +++ b/arch/powerpc/include/asm/atomic.h
6224 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6225 return t1;
6226 }
6227
6228 +#define atomic64_read_unchecked(v) atomic64_read(v)
6229 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6230 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6231 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6232 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6233 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6234 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6235 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6236 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6237 +
6238 #endif /* __powerpc64__ */
6239
6240 #endif /* __KERNEL__ */
6241 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6242 index 9e495c9..b6878e5 100644
6243 --- a/arch/powerpc/include/asm/cache.h
6244 +++ b/arch/powerpc/include/asm/cache.h
6245 @@ -3,6 +3,7 @@
6246
6247 #ifdef __KERNEL__
6248
6249 +#include <linux/const.h>
6250
6251 /* bytes per L1 cache line */
6252 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6253 @@ -22,7 +23,7 @@
6254 #define L1_CACHE_SHIFT 7
6255 #endif
6256
6257 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6258 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6259
6260 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6261
6262 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6263 index cc0655a..13eac2e 100644
6264 --- a/arch/powerpc/include/asm/elf.h
6265 +++ b/arch/powerpc/include/asm/elf.h
6266 @@ -28,8 +28,19 @@
6267 the loader. We need to make sure that it is out of the way of the program
6268 that it will "exec", and that there is sufficient room for the brk. */
6269
6270 -extern unsigned long randomize_et_dyn(unsigned long base);
6271 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6272 +#define ELF_ET_DYN_BASE (0x20000000)
6273 +
6274 +#ifdef CONFIG_PAX_ASLR
6275 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6276 +
6277 +#ifdef __powerpc64__
6278 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6279 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6280 +#else
6281 +#define PAX_DELTA_MMAP_LEN 15
6282 +#define PAX_DELTA_STACK_LEN 15
6283 +#endif
6284 +#endif
6285
6286 /*
6287 * Our registers are always unsigned longs, whether we're a 32 bit
6288 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6289 (0x7ff >> (PAGE_SHIFT - 12)) : \
6290 (0x3ffff >> (PAGE_SHIFT - 12)))
6291
6292 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6293 -#define arch_randomize_brk arch_randomize_brk
6294 -
6295 -
6296 #ifdef CONFIG_SPU_BASE
6297 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6298 #define NT_SPU 1
6299 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6300 index 8196e9c..d83a9f3 100644
6301 --- a/arch/powerpc/include/asm/exec.h
6302 +++ b/arch/powerpc/include/asm/exec.h
6303 @@ -4,6 +4,6 @@
6304 #ifndef _ASM_POWERPC_EXEC_H
6305 #define _ASM_POWERPC_EXEC_H
6306
6307 -extern unsigned long arch_align_stack(unsigned long sp);
6308 +#define arch_align_stack(x) ((x) & ~0xfUL)
6309
6310 #endif /* _ASM_POWERPC_EXEC_H */
6311 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6312 index 5acabbd..7ea14fa 100644
6313 --- a/arch/powerpc/include/asm/kmap_types.h
6314 +++ b/arch/powerpc/include/asm/kmap_types.h
6315 @@ -10,7 +10,7 @@
6316 * 2 of the License, or (at your option) any later version.
6317 */
6318
6319 -#define KM_TYPE_NR 16
6320 +#define KM_TYPE_NR 17
6321
6322 #endif /* __KERNEL__ */
6323 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6324 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6325 index 8565c25..2865190 100644
6326 --- a/arch/powerpc/include/asm/mman.h
6327 +++ b/arch/powerpc/include/asm/mman.h
6328 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6329 }
6330 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6331
6332 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6333 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6334 {
6335 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6336 }
6337 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6338 index 988c812..63c7d70 100644
6339 --- a/arch/powerpc/include/asm/page.h
6340 +++ b/arch/powerpc/include/asm/page.h
6341 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6342 * and needs to be executable. This means the whole heap ends
6343 * up being executable.
6344 */
6345 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6346 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6347 +#define VM_DATA_DEFAULT_FLAGS32 \
6348 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6349 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6350
6351 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6352 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6353 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6354 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6355 #endif
6356
6357 +#define ktla_ktva(addr) (addr)
6358 +#define ktva_ktla(addr) (addr)
6359 +
6360 #ifndef CONFIG_PPC_BOOK3S_64
6361 /*
6362 * Use the top bit of the higher-level page table entries to indicate whether
6363 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6364 index 88693ce..ac6f9ab 100644
6365 --- a/arch/powerpc/include/asm/page_64.h
6366 +++ b/arch/powerpc/include/asm/page_64.h
6367 @@ -153,15 +153,18 @@ do { \
6368 * stack by default, so in the absence of a PT_GNU_STACK program header
6369 * we turn execute permission off.
6370 */
6371 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6372 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6373 +#define VM_STACK_DEFAULT_FLAGS32 \
6374 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6375 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6376
6377 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6378 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6379
6380 +#ifndef CONFIG_PAX_PAGEEXEC
6381 #define VM_STACK_DEFAULT_FLAGS \
6382 (is_32bit_task() ? \
6383 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6384 +#endif
6385
6386 #include <asm-generic/getorder.h>
6387
6388 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6389 index b66ae72..4a378cd 100644
6390 --- a/arch/powerpc/include/asm/pgalloc-64.h
6391 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6392 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6393 #ifndef CONFIG_PPC_64K_PAGES
6394
6395 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6396 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6397
6398 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6399 {
6400 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6401 pud_set(pud, (unsigned long)pmd);
6402 }
6403
6404 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6405 +{
6406 + pud_populate(mm, pud, pmd);
6407 +}
6408 +
6409 #define pmd_populate(mm, pmd, pte_page) \
6410 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6411 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6412 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
6413 #endif
6414
6415 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6416 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6417
6418 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6419 pte_t *pte)
6420 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6421 index 7aeb955..19f748e 100644
6422 --- a/arch/powerpc/include/asm/pgtable.h
6423 +++ b/arch/powerpc/include/asm/pgtable.h
6424 @@ -2,6 +2,7 @@
6425 #define _ASM_POWERPC_PGTABLE_H
6426 #ifdef __KERNEL__
6427
6428 +#include <linux/const.h>
6429 #ifndef __ASSEMBLY__
6430 #include <asm/processor.h> /* For TASK_SIZE */
6431 #include <asm/mmu.h>
6432 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6433 index 4aad413..85d86bf 100644
6434 --- a/arch/powerpc/include/asm/pte-hash32.h
6435 +++ b/arch/powerpc/include/asm/pte-hash32.h
6436 @@ -21,6 +21,7 @@
6437 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6438 #define _PAGE_USER 0x004 /* usermode access allowed */
6439 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6440 +#define _PAGE_EXEC _PAGE_GUARDED
6441 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6442 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6443 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6444 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6445 index 362142b..8b22c1b 100644
6446 --- a/arch/powerpc/include/asm/reg.h
6447 +++ b/arch/powerpc/include/asm/reg.h
6448 @@ -234,6 +234,7 @@
6449 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6450 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6451 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6452 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6453 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6454 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6455 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6456 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6457 index ffbaabe..eabe843 100644
6458 --- a/arch/powerpc/include/asm/smp.h
6459 +++ b/arch/powerpc/include/asm/smp.h
6460 @@ -50,7 +50,7 @@ struct smp_ops_t {
6461 int (*cpu_disable)(void);
6462 void (*cpu_die)(unsigned int nr);
6463 int (*cpu_bootable)(unsigned int nr);
6464 -};
6465 +} __no_const;
6466
6467 extern void smp_send_debugger_break(void);
6468 extern void start_secondary_resume(void);
6469 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6470 index ba7b197..d292e26 100644
6471 --- a/arch/powerpc/include/asm/thread_info.h
6472 +++ b/arch/powerpc/include/asm/thread_info.h
6473 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
6474 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
6475 TIF_NEED_RESCHED */
6476 #define TIF_32BIT 4 /* 32 bit binary */
6477 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
6478 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6479 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6480 #define TIF_SINGLESTEP 8 /* singlestepping active */
6481 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
6482 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6483 for stack store? */
6484 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6485 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
6486 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6487 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
6488
6489 /* as above, but as bit values */
6490 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6491 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
6492 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6493 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6494 #define _TIF_NOHZ (1<<TIF_NOHZ)
6495 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6496 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6497 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6498 - _TIF_NOHZ)
6499 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
6500
6501 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6502 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6503 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6504 index 4db4959..aba5c41 100644
6505 --- a/arch/powerpc/include/asm/uaccess.h
6506 +++ b/arch/powerpc/include/asm/uaccess.h
6507 @@ -318,52 +318,6 @@ do { \
6508 extern unsigned long __copy_tofrom_user(void __user *to,
6509 const void __user *from, unsigned long size);
6510
6511 -#ifndef __powerpc64__
6512 -
6513 -static inline unsigned long copy_from_user(void *to,
6514 - const void __user *from, unsigned long n)
6515 -{
6516 - unsigned long over;
6517 -
6518 - if (access_ok(VERIFY_READ, from, n))
6519 - return __copy_tofrom_user((__force void __user *)to, from, n);
6520 - if ((unsigned long)from < TASK_SIZE) {
6521 - over = (unsigned long)from + n - TASK_SIZE;
6522 - return __copy_tofrom_user((__force void __user *)to, from,
6523 - n - over) + over;
6524 - }
6525 - return n;
6526 -}
6527 -
6528 -static inline unsigned long copy_to_user(void __user *to,
6529 - const void *from, unsigned long n)
6530 -{
6531 - unsigned long over;
6532 -
6533 - if (access_ok(VERIFY_WRITE, to, n))
6534 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6535 - if ((unsigned long)to < TASK_SIZE) {
6536 - over = (unsigned long)to + n - TASK_SIZE;
6537 - return __copy_tofrom_user(to, (__force void __user *)from,
6538 - n - over) + over;
6539 - }
6540 - return n;
6541 -}
6542 -
6543 -#else /* __powerpc64__ */
6544 -
6545 -#define __copy_in_user(to, from, size) \
6546 - __copy_tofrom_user((to), (from), (size))
6547 -
6548 -extern unsigned long copy_from_user(void *to, const void __user *from,
6549 - unsigned long n);
6550 -extern unsigned long copy_to_user(void __user *to, const void *from,
6551 - unsigned long n);
6552 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6553 - unsigned long n);
6554 -
6555 -#endif /* __powerpc64__ */
6556 -
6557 static inline unsigned long __copy_from_user_inatomic(void *to,
6558 const void __user *from, unsigned long n)
6559 {
6560 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6561 if (ret == 0)
6562 return 0;
6563 }
6564 +
6565 + if (!__builtin_constant_p(n))
6566 + check_object_size(to, n, false);
6567 +
6568 return __copy_tofrom_user((__force void __user *)to, from, n);
6569 }
6570
6571 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6572 if (ret == 0)
6573 return 0;
6574 }
6575 +
6576 + if (!__builtin_constant_p(n))
6577 + check_object_size(from, n, true);
6578 +
6579 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6580 }
6581
6582 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6583 return __copy_to_user_inatomic(to, from, size);
6584 }
6585
6586 +#ifndef __powerpc64__
6587 +
6588 +static inline unsigned long __must_check copy_from_user(void *to,
6589 + const void __user *from, unsigned long n)
6590 +{
6591 + unsigned long over;
6592 +
6593 + if ((long)n < 0)
6594 + return n;
6595 +
6596 + if (access_ok(VERIFY_READ, from, n)) {
6597 + if (!__builtin_constant_p(n))
6598 + check_object_size(to, n, false);
6599 + return __copy_tofrom_user((__force void __user *)to, from, n);
6600 + }
6601 + if ((unsigned long)from < TASK_SIZE) {
6602 + over = (unsigned long)from + n - TASK_SIZE;
6603 + if (!__builtin_constant_p(n - over))
6604 + check_object_size(to, n - over, false);
6605 + return __copy_tofrom_user((__force void __user *)to, from,
6606 + n - over) + over;
6607 + }
6608 + return n;
6609 +}
6610 +
6611 +static inline unsigned long __must_check copy_to_user(void __user *to,
6612 + const void *from, unsigned long n)
6613 +{
6614 + unsigned long over;
6615 +
6616 + if ((long)n < 0)
6617 + return n;
6618 +
6619 + if (access_ok(VERIFY_WRITE, to, n)) {
6620 + if (!__builtin_constant_p(n))
6621 + check_object_size(from, n, true);
6622 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6623 + }
6624 + if ((unsigned long)to < TASK_SIZE) {
6625 + over = (unsigned long)to + n - TASK_SIZE;
6626 + if (!__builtin_constant_p(n))
6627 + check_object_size(from, n - over, true);
6628 + return __copy_tofrom_user(to, (__force void __user *)from,
6629 + n - over) + over;
6630 + }
6631 + return n;
6632 +}
6633 +
6634 +#else /* __powerpc64__ */
6635 +
6636 +#define __copy_in_user(to, from, size) \
6637 + __copy_tofrom_user((to), (from), (size))
6638 +
6639 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6640 +{
6641 + if ((long)n < 0 || n > INT_MAX)
6642 + return n;
6643 +
6644 + if (!__builtin_constant_p(n))
6645 + check_object_size(to, n, false);
6646 +
6647 + if (likely(access_ok(VERIFY_READ, from, n)))
6648 + n = __copy_from_user(to, from, n);
6649 + else
6650 + memset(to, 0, n);
6651 + return n;
6652 +}
6653 +
6654 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6655 +{
6656 + if ((long)n < 0 || n > INT_MAX)
6657 + return n;
6658 +
6659 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6660 + if (!__builtin_constant_p(n))
6661 + check_object_size(from, n, true);
6662 + n = __copy_to_user(to, from, n);
6663 + }
6664 + return n;
6665 +}
6666 +
6667 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6668 + unsigned long n);
6669 +
6670 +#endif /* __powerpc64__ */
6671 +
6672 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6673
6674 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6675 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6676 index 645170a..6cf0271 100644
6677 --- a/arch/powerpc/kernel/exceptions-64e.S
6678 +++ b/arch/powerpc/kernel/exceptions-64e.S
6679 @@ -757,6 +757,7 @@ storage_fault_common:
6680 std r14,_DAR(r1)
6681 std r15,_DSISR(r1)
6682 addi r3,r1,STACK_FRAME_OVERHEAD
6683 + bl .save_nvgprs
6684 mr r4,r14
6685 mr r5,r15
6686 ld r14,PACA_EXGEN+EX_R14(r13)
6687 @@ -765,8 +766,7 @@ storage_fault_common:
6688 cmpdi r3,0
6689 bne- 1f
6690 b .ret_from_except_lite
6691 -1: bl .save_nvgprs
6692 - mr r5,r3
6693 +1: mr r5,r3
6694 addi r3,r1,STACK_FRAME_OVERHEAD
6695 ld r4,_DAR(r1)
6696 bl .bad_page_fault
6697 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6698 index 4e00d22..b26abcc 100644
6699 --- a/arch/powerpc/kernel/exceptions-64s.S
6700 +++ b/arch/powerpc/kernel/exceptions-64s.S
6701 @@ -1356,10 +1356,10 @@ handle_page_fault:
6702 11: ld r4,_DAR(r1)
6703 ld r5,_DSISR(r1)
6704 addi r3,r1,STACK_FRAME_OVERHEAD
6705 + bl .save_nvgprs
6706 bl .do_page_fault
6707 cmpdi r3,0
6708 beq+ 12f
6709 - bl .save_nvgprs
6710 mr r5,r3
6711 addi r3,r1,STACK_FRAME_OVERHEAD
6712 lwz r4,_DAR(r1)
6713 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6714 index 2e3200c..72095ce 100644
6715 --- a/arch/powerpc/kernel/module_32.c
6716 +++ b/arch/powerpc/kernel/module_32.c
6717 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6718 me->arch.core_plt_section = i;
6719 }
6720 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6721 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6722 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6723 return -ENOEXEC;
6724 }
6725
6726 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6727
6728 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6729 /* Init, or core PLT? */
6730 - if (location >= mod->module_core
6731 - && location < mod->module_core + mod->core_size)
6732 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6733 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6734 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6735 - else
6736 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6737 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6738 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6739 + else {
6740 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6741 + return ~0UL;
6742 + }
6743
6744 /* Find this entry, or if that fails, the next avail. entry */
6745 while (entry->jump[0]) {
6746 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6747 index 076d124..6cb2cbf 100644
6748 --- a/arch/powerpc/kernel/process.c
6749 +++ b/arch/powerpc/kernel/process.c
6750 @@ -874,8 +874,8 @@ void show_regs(struct pt_regs * regs)
6751 * Lookup NIP late so we have the best change of getting the
6752 * above info out without failing
6753 */
6754 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6755 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6756 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6757 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6758 #endif
6759 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6760 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6761 @@ -1335,10 +1335,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6762 newsp = stack[0];
6763 ip = stack[STACK_FRAME_LR_SAVE];
6764 if (!firstframe || ip != lr) {
6765 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6766 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6767 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6768 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6769 - printk(" (%pS)",
6770 + printk(" (%pA)",
6771 (void *)current->ret_stack[curr_frame].ret);
6772 curr_frame--;
6773 }
6774 @@ -1358,7 +1358,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6775 struct pt_regs *regs = (struct pt_regs *)
6776 (sp + STACK_FRAME_OVERHEAD);
6777 lr = regs->link;
6778 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6779 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6780 regs->trap, (void *)regs->nip, (void *)lr);
6781 firstframe = 1;
6782 }
6783 @@ -1394,58 +1394,3 @@ void notrace __ppc64_runlatch_off(void)
6784 mtspr(SPRN_CTRLT, ctrl);
6785 }
6786 #endif /* CONFIG_PPC64 */
6787 -
6788 -unsigned long arch_align_stack(unsigned long sp)
6789 -{
6790 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6791 - sp -= get_random_int() & ~PAGE_MASK;
6792 - return sp & ~0xf;
6793 -}
6794 -
6795 -static inline unsigned long brk_rnd(void)
6796 -{
6797 - unsigned long rnd = 0;
6798 -
6799 - /* 8MB for 32bit, 1GB for 64bit */
6800 - if (is_32bit_task())
6801 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6802 - else
6803 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6804 -
6805 - return rnd << PAGE_SHIFT;
6806 -}
6807 -
6808 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6809 -{
6810 - unsigned long base = mm->brk;
6811 - unsigned long ret;
6812 -
6813 -#ifdef CONFIG_PPC_STD_MMU_64
6814 - /*
6815 - * If we are using 1TB segments and we are allowed to randomise
6816 - * the heap, we can put it above 1TB so it is backed by a 1TB
6817 - * segment. Otherwise the heap will be in the bottom 1TB
6818 - * which always uses 256MB segments and this may result in a
6819 - * performance penalty.
6820 - */
6821 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6822 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6823 -#endif
6824 -
6825 - ret = PAGE_ALIGN(base + brk_rnd());
6826 -
6827 - if (ret < mm->brk)
6828 - return mm->brk;
6829 -
6830 - return ret;
6831 -}
6832 -
6833 -unsigned long randomize_et_dyn(unsigned long base)
6834 -{
6835 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6836 -
6837 - if (ret < base)
6838 - return base;
6839 -
6840 - return ret;
6841 -}
6842 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6843 index 64f7bd5..8dd550f 100644
6844 --- a/arch/powerpc/kernel/ptrace.c
6845 +++ b/arch/powerpc/kernel/ptrace.c
6846 @@ -1783,6 +1783,10 @@ long arch_ptrace(struct task_struct *child, long request,
6847 return ret;
6848 }
6849
6850 +#ifdef CONFIG_GRKERNSEC_SETXID
6851 +extern void gr_delayed_cred_worker(void);
6852 +#endif
6853 +
6854 /*
6855 * We must return the syscall number to actually look up in the table.
6856 * This can be -1L to skip running any syscall at all.
6857 @@ -1795,6 +1799,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6858
6859 secure_computing_strict(regs->gpr[0]);
6860
6861 +#ifdef CONFIG_GRKERNSEC_SETXID
6862 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6863 + gr_delayed_cred_worker();
6864 +#endif
6865 +
6866 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6867 tracehook_report_syscall_entry(regs))
6868 /*
6869 @@ -1829,6 +1838,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6870 {
6871 int step;
6872
6873 +#ifdef CONFIG_GRKERNSEC_SETXID
6874 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6875 + gr_delayed_cred_worker();
6876 +#endif
6877 +
6878 audit_syscall_exit(regs);
6879
6880 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6881 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6882 index 0f83122..c0aca6a 100644
6883 --- a/arch/powerpc/kernel/signal_32.c
6884 +++ b/arch/powerpc/kernel/signal_32.c
6885 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6886 /* Save user registers on the stack */
6887 frame = &rt_sf->uc.uc_mcontext;
6888 addr = frame;
6889 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6890 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6891 sigret = 0;
6892 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6893 } else {
6894 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6895 index 887e99d..310bc11 100644
6896 --- a/arch/powerpc/kernel/signal_64.c
6897 +++ b/arch/powerpc/kernel/signal_64.c
6898 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6899 #endif
6900
6901 /* Set up to return from userspace. */
6902 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6903 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6904 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6905 } else {
6906 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6907 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6908 index e68a845..8b140e6 100644
6909 --- a/arch/powerpc/kernel/sysfs.c
6910 +++ b/arch/powerpc/kernel/sysfs.c
6911 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6912 return NOTIFY_OK;
6913 }
6914
6915 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6916 +static struct notifier_block sysfs_cpu_nb = {
6917 .notifier_call = sysfs_cpu_notify,
6918 };
6919
6920 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6921 index e4f205a..8bfffb8 100644
6922 --- a/arch/powerpc/kernel/traps.c
6923 +++ b/arch/powerpc/kernel/traps.c
6924 @@ -143,6 +143,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6925 return flags;
6926 }
6927
6928 +extern void gr_handle_kernel_exploit(void);
6929 +
6930 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6931 int signr)
6932 {
6933 @@ -192,6 +194,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6934 panic("Fatal exception in interrupt");
6935 if (panic_on_oops)
6936 panic("Fatal exception");
6937 +
6938 + gr_handle_kernel_exploit();
6939 +
6940 do_exit(signr);
6941 }
6942
6943 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6944 index d4f463a..8fb7431 100644
6945 --- a/arch/powerpc/kernel/vdso.c
6946 +++ b/arch/powerpc/kernel/vdso.c
6947 @@ -34,6 +34,7 @@
6948 #include <asm/firmware.h>
6949 #include <asm/vdso.h>
6950 #include <asm/vdso_datapage.h>
6951 +#include <asm/mman.h>
6952
6953 #include "setup.h"
6954
6955 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6956 vdso_base = VDSO32_MBASE;
6957 #endif
6958
6959 - current->mm->context.vdso_base = 0;
6960 + current->mm->context.vdso_base = ~0UL;
6961
6962 /* vDSO has a problem and was disabled, just don't "enable" it for the
6963 * process
6964 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6965 vdso_base = get_unmapped_area(NULL, vdso_base,
6966 (vdso_pages << PAGE_SHIFT) +
6967 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6968 - 0, 0);
6969 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6970 if (IS_ERR_VALUE(vdso_base)) {
6971 rc = vdso_base;
6972 goto fail_mmapsem;
6973 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6974 index 5eea6f3..5d10396 100644
6975 --- a/arch/powerpc/lib/usercopy_64.c
6976 +++ b/arch/powerpc/lib/usercopy_64.c
6977 @@ -9,22 +9,6 @@
6978 #include <linux/module.h>
6979 #include <asm/uaccess.h>
6980
6981 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6982 -{
6983 - if (likely(access_ok(VERIFY_READ, from, n)))
6984 - n = __copy_from_user(to, from, n);
6985 - else
6986 - memset(to, 0, n);
6987 - return n;
6988 -}
6989 -
6990 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6991 -{
6992 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6993 - n = __copy_to_user(to, from, n);
6994 - return n;
6995 -}
6996 -
6997 unsigned long copy_in_user(void __user *to, const void __user *from,
6998 unsigned long n)
6999 {
7000 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7001 return n;
7002 }
7003
7004 -EXPORT_SYMBOL(copy_from_user);
7005 -EXPORT_SYMBOL(copy_to_user);
7006 EXPORT_SYMBOL(copy_in_user);
7007
7008 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7009 index 8726779..a33c512 100644
7010 --- a/arch/powerpc/mm/fault.c
7011 +++ b/arch/powerpc/mm/fault.c
7012 @@ -33,6 +33,10 @@
7013 #include <linux/magic.h>
7014 #include <linux/ratelimit.h>
7015 #include <linux/context_tracking.h>
7016 +#include <linux/slab.h>
7017 +#include <linux/pagemap.h>
7018 +#include <linux/compiler.h>
7019 +#include <linux/unistd.h>
7020
7021 #include <asm/firmware.h>
7022 #include <asm/page.h>
7023 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7024 }
7025 #endif
7026
7027 +#ifdef CONFIG_PAX_PAGEEXEC
7028 +/*
7029 + * PaX: decide what to do with offenders (regs->nip = fault address)
7030 + *
7031 + * returns 1 when task should be killed
7032 + */
7033 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7034 +{
7035 + return 1;
7036 +}
7037 +
7038 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7039 +{
7040 + unsigned long i;
7041 +
7042 + printk(KERN_ERR "PAX: bytes at PC: ");
7043 + for (i = 0; i < 5; i++) {
7044 + unsigned int c;
7045 + if (get_user(c, (unsigned int __user *)pc+i))
7046 + printk(KERN_CONT "???????? ");
7047 + else
7048 + printk(KERN_CONT "%08x ", c);
7049 + }
7050 + printk("\n");
7051 +}
7052 +#endif
7053 +
7054 /*
7055 * Check whether the instruction at regs->nip is a store using
7056 * an update addressing form which will update r1.
7057 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7058 * indicate errors in DSISR but can validly be set in SRR1.
7059 */
7060 if (trap == 0x400)
7061 - error_code &= 0x48200000;
7062 + error_code &= 0x58200000;
7063 else
7064 is_write = error_code & DSISR_ISSTORE;
7065 #else
7066 @@ -371,7 +402,7 @@ good_area:
7067 * "undefined". Of those that can be set, this is the only
7068 * one which seems bad.
7069 */
7070 - if (error_code & 0x10000000)
7071 + if (error_code & DSISR_GUARDED)
7072 /* Guarded storage error. */
7073 goto bad_area;
7074 #endif /* CONFIG_8xx */
7075 @@ -386,7 +417,7 @@ good_area:
7076 * processors use the same I/D cache coherency mechanism
7077 * as embedded.
7078 */
7079 - if (error_code & DSISR_PROTFAULT)
7080 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7081 goto bad_area;
7082 #endif /* CONFIG_PPC_STD_MMU */
7083
7084 @@ -471,6 +502,23 @@ bad_area:
7085 bad_area_nosemaphore:
7086 /* User mode accesses cause a SIGSEGV */
7087 if (user_mode(regs)) {
7088 +
7089 +#ifdef CONFIG_PAX_PAGEEXEC
7090 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7091 +#ifdef CONFIG_PPC_STD_MMU
7092 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7093 +#else
7094 + if (is_exec && regs->nip == address) {
7095 +#endif
7096 + switch (pax_handle_fetch_fault(regs)) {
7097 + }
7098 +
7099 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7100 + do_group_exit(SIGKILL);
7101 + }
7102 + }
7103 +#endif
7104 +
7105 _exception(SIGSEGV, regs, code, address);
7106 goto bail;
7107 }
7108 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7109 index 67a42ed..cd463e0 100644
7110 --- a/arch/powerpc/mm/mmap_64.c
7111 +++ b/arch/powerpc/mm/mmap_64.c
7112 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7113 {
7114 unsigned long rnd = 0;
7115
7116 +#ifdef CONFIG_PAX_RANDMMAP
7117 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7118 +#endif
7119 +
7120 if (current->flags & PF_RANDOMIZE) {
7121 /* 8MB for 32bit, 1GB for 64bit */
7122 if (is_32bit_task())
7123 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7124 */
7125 if (mmap_is_legacy()) {
7126 mm->mmap_base = TASK_UNMAPPED_BASE;
7127 +
7128 +#ifdef CONFIG_PAX_RANDMMAP
7129 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7130 + mm->mmap_base += mm->delta_mmap;
7131 +#endif
7132 +
7133 mm->get_unmapped_area = arch_get_unmapped_area;
7134 mm->unmap_area = arch_unmap_area;
7135 } else {
7136 mm->mmap_base = mmap_base();
7137 +
7138 +#ifdef CONFIG_PAX_RANDMMAP
7139 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7140 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7141 +#endif
7142 +
7143 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7144 mm->unmap_area = arch_unmap_area_topdown;
7145 }
7146 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7147 index e779642..e5bb889 100644
7148 --- a/arch/powerpc/mm/mmu_context_nohash.c
7149 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7150 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7151 return NOTIFY_OK;
7152 }
7153
7154 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7155 +static struct notifier_block mmu_context_cpu_nb = {
7156 .notifier_call = mmu_context_cpu_notify,
7157 };
7158
7159 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7160 index 2859a1f..74f9a6e 100644
7161 --- a/arch/powerpc/mm/numa.c
7162 +++ b/arch/powerpc/mm/numa.c
7163 @@ -919,7 +919,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7164 return ret;
7165 }
7166
7167 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7168 +static struct notifier_block ppc64_numa_nb = {
7169 .notifier_call = cpu_numa_callback,
7170 .priority = 1 /* Must run before sched domains notifier. */
7171 };
7172 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7173 index 3e99c14..f00953c 100644
7174 --- a/arch/powerpc/mm/slice.c
7175 +++ b/arch/powerpc/mm/slice.c
7176 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7177 if ((mm->task_size - len) < addr)
7178 return 0;
7179 vma = find_vma(mm, addr);
7180 - return (!vma || (addr + len) <= vma->vm_start);
7181 + return check_heap_stack_gap(vma, addr, len, 0);
7182 }
7183
7184 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7185 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
7186 info.align_offset = 0;
7187
7188 addr = TASK_UNMAPPED_BASE;
7189 +
7190 +#ifdef CONFIG_PAX_RANDMMAP
7191 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7192 + addr += mm->delta_mmap;
7193 +#endif
7194 +
7195 while (addr < TASK_SIZE) {
7196 info.low_limit = addr;
7197 if (!slice_scan_available(addr, available, 1, &addr))
7198 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7199 if (fixed && addr > (mm->task_size - len))
7200 return -EINVAL;
7201
7202 +#ifdef CONFIG_PAX_RANDMMAP
7203 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7204 + addr = 0;
7205 +#endif
7206 +
7207 /* If hint, make sure it matches our alignment restrictions */
7208 if (!fixed && addr) {
7209 addr = _ALIGN_UP(addr, 1ul << pshift);
7210 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7211 index 9098692..3d54cd1 100644
7212 --- a/arch/powerpc/platforms/cell/spufs/file.c
7213 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7214 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7215 return VM_FAULT_NOPAGE;
7216 }
7217
7218 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7219 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7220 unsigned long address,
7221 - void *buf, int len, int write)
7222 + void *buf, size_t len, int write)
7223 {
7224 struct spu_context *ctx = vma->vm_file->private_data;
7225 unsigned long offset = address - vma->vm_start;
7226 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7227 index bdb738a..49c9f95 100644
7228 --- a/arch/powerpc/platforms/powermac/smp.c
7229 +++ b/arch/powerpc/platforms/powermac/smp.c
7230 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7231 return NOTIFY_OK;
7232 }
7233
7234 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7235 +static struct notifier_block smp_core99_cpu_nb = {
7236 .notifier_call = smp_core99_cpu_notify,
7237 };
7238 #endif /* CONFIG_HOTPLUG_CPU */
7239 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7240 index c797832..ce575c8 100644
7241 --- a/arch/s390/include/asm/atomic.h
7242 +++ b/arch/s390/include/asm/atomic.h
7243 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7244 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7245 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7246
7247 +#define atomic64_read_unchecked(v) atomic64_read(v)
7248 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7249 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7250 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7251 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7252 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7253 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7254 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7255 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7256 +
7257 #define smp_mb__before_atomic_dec() smp_mb()
7258 #define smp_mb__after_atomic_dec() smp_mb()
7259 #define smp_mb__before_atomic_inc() smp_mb()
7260 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7261 index 4d7ccac..d03d0ad 100644
7262 --- a/arch/s390/include/asm/cache.h
7263 +++ b/arch/s390/include/asm/cache.h
7264 @@ -9,8 +9,10 @@
7265 #ifndef __ARCH_S390_CACHE_H
7266 #define __ARCH_S390_CACHE_H
7267
7268 -#define L1_CACHE_BYTES 256
7269 +#include <linux/const.h>
7270 +
7271 #define L1_CACHE_SHIFT 8
7272 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7273 #define NET_SKB_PAD 32
7274
7275 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7276 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7277 index 78f4f87..598ce39 100644
7278 --- a/arch/s390/include/asm/elf.h
7279 +++ b/arch/s390/include/asm/elf.h
7280 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
7281 the loader. We need to make sure that it is out of the way of the program
7282 that it will "exec", and that there is sufficient room for the brk. */
7283
7284 -extern unsigned long randomize_et_dyn(unsigned long base);
7285 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7286 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7287 +
7288 +#ifdef CONFIG_PAX_ASLR
7289 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7290 +
7291 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7292 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7293 +#endif
7294
7295 /* This yields a mask that user programs can use to figure out what
7296 instruction set this CPU supports. */
7297 @@ -222,9 +228,6 @@ struct linux_binprm;
7298 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7299 int arch_setup_additional_pages(struct linux_binprm *, int);
7300
7301 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7302 -#define arch_randomize_brk arch_randomize_brk
7303 -
7304 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7305
7306 #endif
7307 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7308 index c4a93d6..4d2a9b4 100644
7309 --- a/arch/s390/include/asm/exec.h
7310 +++ b/arch/s390/include/asm/exec.h
7311 @@ -7,6 +7,6 @@
7312 #ifndef __ASM_EXEC_H
7313 #define __ASM_EXEC_H
7314
7315 -extern unsigned long arch_align_stack(unsigned long sp);
7316 +#define arch_align_stack(x) ((x) & ~0xfUL)
7317
7318 #endif /* __ASM_EXEC_H */
7319 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7320 index 9c33ed4..e40cbef 100644
7321 --- a/arch/s390/include/asm/uaccess.h
7322 +++ b/arch/s390/include/asm/uaccess.h
7323 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7324 copy_to_user(void __user *to, const void *from, unsigned long n)
7325 {
7326 might_fault();
7327 +
7328 + if ((long)n < 0)
7329 + return n;
7330 +
7331 return __copy_to_user(to, from, n);
7332 }
7333
7334 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7335 static inline unsigned long __must_check
7336 __copy_from_user(void *to, const void __user *from, unsigned long n)
7337 {
7338 + if ((long)n < 0)
7339 + return n;
7340 +
7341 if (__builtin_constant_p(n) && (n <= 256))
7342 return uaccess.copy_from_user_small(n, from, to);
7343 else
7344 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7345 static inline unsigned long __must_check
7346 copy_from_user(void *to, const void __user *from, unsigned long n)
7347 {
7348 - unsigned int sz = __compiletime_object_size(to);
7349 + size_t sz = __compiletime_object_size(to);
7350
7351 might_fault();
7352 - if (unlikely(sz != -1 && sz < n)) {
7353 +
7354 + if ((long)n < 0)
7355 + return n;
7356 +
7357 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7358 copy_from_user_overflow();
7359 return n;
7360 }
7361 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7362 index 7845e15..59c4353 100644
7363 --- a/arch/s390/kernel/module.c
7364 +++ b/arch/s390/kernel/module.c
7365 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7366
7367 /* Increase core size by size of got & plt and set start
7368 offsets for got and plt. */
7369 - me->core_size = ALIGN(me->core_size, 4);
7370 - me->arch.got_offset = me->core_size;
7371 - me->core_size += me->arch.got_size;
7372 - me->arch.plt_offset = me->core_size;
7373 - me->core_size += me->arch.plt_size;
7374 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7375 + me->arch.got_offset = me->core_size_rw;
7376 + me->core_size_rw += me->arch.got_size;
7377 + me->arch.plt_offset = me->core_size_rx;
7378 + me->core_size_rx += me->arch.plt_size;
7379 return 0;
7380 }
7381
7382 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7383 if (info->got_initialized == 0) {
7384 Elf_Addr *gotent;
7385
7386 - gotent = me->module_core + me->arch.got_offset +
7387 + gotent = me->module_core_rw + me->arch.got_offset +
7388 info->got_offset;
7389 *gotent = val;
7390 info->got_initialized = 1;
7391 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7392 rc = apply_rela_bits(loc, val, 0, 64, 0);
7393 else if (r_type == R_390_GOTENT ||
7394 r_type == R_390_GOTPLTENT) {
7395 - val += (Elf_Addr) me->module_core - loc;
7396 + val += (Elf_Addr) me->module_core_rw - loc;
7397 rc = apply_rela_bits(loc, val, 1, 32, 1);
7398 }
7399 break;
7400 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7401 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7402 if (info->plt_initialized == 0) {
7403 unsigned int *ip;
7404 - ip = me->module_core + me->arch.plt_offset +
7405 + ip = me->module_core_rx + me->arch.plt_offset +
7406 info->plt_offset;
7407 #ifndef CONFIG_64BIT
7408 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7409 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7410 val - loc + 0xffffUL < 0x1ffffeUL) ||
7411 (r_type == R_390_PLT32DBL &&
7412 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7413 - val = (Elf_Addr) me->module_core +
7414 + val = (Elf_Addr) me->module_core_rx +
7415 me->arch.plt_offset +
7416 info->plt_offset;
7417 val += rela->r_addend - loc;
7418 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7419 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7420 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7421 val = val + rela->r_addend -
7422 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7423 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7424 if (r_type == R_390_GOTOFF16)
7425 rc = apply_rela_bits(loc, val, 0, 16, 0);
7426 else if (r_type == R_390_GOTOFF32)
7427 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7428 break;
7429 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7430 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7431 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7432 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7433 rela->r_addend - loc;
7434 if (r_type == R_390_GOTPC)
7435 rc = apply_rela_bits(loc, val, 1, 32, 0);
7436 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7437 index 2bc3edd..ab9d598 100644
7438 --- a/arch/s390/kernel/process.c
7439 +++ b/arch/s390/kernel/process.c
7440 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
7441 }
7442 return 0;
7443 }
7444 -
7445 -unsigned long arch_align_stack(unsigned long sp)
7446 -{
7447 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7448 - sp -= get_random_int() & ~PAGE_MASK;
7449 - return sp & ~0xf;
7450 -}
7451 -
7452 -static inline unsigned long brk_rnd(void)
7453 -{
7454 - /* 8MB for 32bit, 1GB for 64bit */
7455 - if (is_32bit_task())
7456 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7457 - else
7458 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7459 -}
7460 -
7461 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7462 -{
7463 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7464 -
7465 - if (ret < mm->brk)
7466 - return mm->brk;
7467 - return ret;
7468 -}
7469 -
7470 -unsigned long randomize_et_dyn(unsigned long base)
7471 -{
7472 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7473 -
7474 - if (!(current->flags & PF_RANDOMIZE))
7475 - return base;
7476 - if (ret < base)
7477 - return base;
7478 - return ret;
7479 -}
7480 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7481 index 06bafec..2bca531 100644
7482 --- a/arch/s390/mm/mmap.c
7483 +++ b/arch/s390/mm/mmap.c
7484 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7485 */
7486 if (mmap_is_legacy()) {
7487 mm->mmap_base = TASK_UNMAPPED_BASE;
7488 +
7489 +#ifdef CONFIG_PAX_RANDMMAP
7490 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7491 + mm->mmap_base += mm->delta_mmap;
7492 +#endif
7493 +
7494 mm->get_unmapped_area = arch_get_unmapped_area;
7495 mm->unmap_area = arch_unmap_area;
7496 } else {
7497 mm->mmap_base = mmap_base();
7498 +
7499 +#ifdef CONFIG_PAX_RANDMMAP
7500 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7501 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7502 +#endif
7503 +
7504 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7505 mm->unmap_area = arch_unmap_area_topdown;
7506 }
7507 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7508 */
7509 if (mmap_is_legacy()) {
7510 mm->mmap_base = TASK_UNMAPPED_BASE;
7511 +
7512 +#ifdef CONFIG_PAX_RANDMMAP
7513 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7514 + mm->mmap_base += mm->delta_mmap;
7515 +#endif
7516 +
7517 mm->get_unmapped_area = s390_get_unmapped_area;
7518 mm->unmap_area = arch_unmap_area;
7519 } else {
7520 mm->mmap_base = mmap_base();
7521 +
7522 +#ifdef CONFIG_PAX_RANDMMAP
7523 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7524 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7525 +#endif
7526 +
7527 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7528 mm->unmap_area = arch_unmap_area_topdown;
7529 }
7530 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7531 index ae3d59f..f65f075 100644
7532 --- a/arch/score/include/asm/cache.h
7533 +++ b/arch/score/include/asm/cache.h
7534 @@ -1,7 +1,9 @@
7535 #ifndef _ASM_SCORE_CACHE_H
7536 #define _ASM_SCORE_CACHE_H
7537
7538 +#include <linux/const.h>
7539 +
7540 #define L1_CACHE_SHIFT 4
7541 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7543
7544 #endif /* _ASM_SCORE_CACHE_H */
7545 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7546 index f9f3cd5..58ff438 100644
7547 --- a/arch/score/include/asm/exec.h
7548 +++ b/arch/score/include/asm/exec.h
7549 @@ -1,6 +1,6 @@
7550 #ifndef _ASM_SCORE_EXEC_H
7551 #define _ASM_SCORE_EXEC_H
7552
7553 -extern unsigned long arch_align_stack(unsigned long sp);
7554 +#define arch_align_stack(x) (x)
7555
7556 #endif /* _ASM_SCORE_EXEC_H */
7557 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7558 index f4c6d02..e9355c3 100644
7559 --- a/arch/score/kernel/process.c
7560 +++ b/arch/score/kernel/process.c
7561 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
7562
7563 return task_pt_regs(task)->cp0_epc;
7564 }
7565 -
7566 -unsigned long arch_align_stack(unsigned long sp)
7567 -{
7568 - return sp;
7569 -}
7570 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7571 index ef9e555..331bd29 100644
7572 --- a/arch/sh/include/asm/cache.h
7573 +++ b/arch/sh/include/asm/cache.h
7574 @@ -9,10 +9,11 @@
7575 #define __ASM_SH_CACHE_H
7576 #ifdef __KERNEL__
7577
7578 +#include <linux/const.h>
7579 #include <linux/init.h>
7580 #include <cpu/cache.h>
7581
7582 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7583 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7584
7585 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7586
7587 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7588 index 03f2b55..b0270327 100644
7589 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7590 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7591 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7592 return NOTIFY_OK;
7593 }
7594
7595 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7596 +static struct notifier_block shx3_cpu_notifier = {
7597 .notifier_call = shx3_cpu_callback,
7598 };
7599
7600 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7601 index 6777177..cb5e44f 100644
7602 --- a/arch/sh/mm/mmap.c
7603 +++ b/arch/sh/mm/mmap.c
7604 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7605 struct mm_struct *mm = current->mm;
7606 struct vm_area_struct *vma;
7607 int do_colour_align;
7608 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7609 struct vm_unmapped_area_info info;
7610
7611 if (flags & MAP_FIXED) {
7612 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7613 if (filp || (flags & MAP_SHARED))
7614 do_colour_align = 1;
7615
7616 +#ifdef CONFIG_PAX_RANDMMAP
7617 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7618 +#endif
7619 +
7620 if (addr) {
7621 if (do_colour_align)
7622 addr = COLOUR_ALIGN(addr, pgoff);
7623 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7624 addr = PAGE_ALIGN(addr);
7625
7626 vma = find_vma(mm, addr);
7627 - if (TASK_SIZE - len >= addr &&
7628 - (!vma || addr + len <= vma->vm_start))
7629 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7630 return addr;
7631 }
7632
7633 info.flags = 0;
7634 info.length = len;
7635 - info.low_limit = TASK_UNMAPPED_BASE;
7636 + info.low_limit = mm->mmap_base;
7637 info.high_limit = TASK_SIZE;
7638 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7639 info.align_offset = pgoff << PAGE_SHIFT;
7640 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7641 struct mm_struct *mm = current->mm;
7642 unsigned long addr = addr0;
7643 int do_colour_align;
7644 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7645 struct vm_unmapped_area_info info;
7646
7647 if (flags & MAP_FIXED) {
7648 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7649 if (filp || (flags & MAP_SHARED))
7650 do_colour_align = 1;
7651
7652 +#ifdef CONFIG_PAX_RANDMMAP
7653 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7654 +#endif
7655 +
7656 /* requesting a specific address */
7657 if (addr) {
7658 if (do_colour_align)
7659 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7660 addr = PAGE_ALIGN(addr);
7661
7662 vma = find_vma(mm, addr);
7663 - if (TASK_SIZE - len >= addr &&
7664 - (!vma || addr + len <= vma->vm_start))
7665 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7666 return addr;
7667 }
7668
7669 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7670 VM_BUG_ON(addr != -ENOMEM);
7671 info.flags = 0;
7672 info.low_limit = TASK_UNMAPPED_BASE;
7673 +
7674 +#ifdef CONFIG_PAX_RANDMMAP
7675 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7676 + info.low_limit += mm->delta_mmap;
7677 +#endif
7678 +
7679 info.high_limit = TASK_SIZE;
7680 addr = vm_unmapped_area(&info);
7681 }
7682 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7683 index be56a24..443328f 100644
7684 --- a/arch/sparc/include/asm/atomic_64.h
7685 +++ b/arch/sparc/include/asm/atomic_64.h
7686 @@ -14,18 +14,40 @@
7687 #define ATOMIC64_INIT(i) { (i) }
7688
7689 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7690 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7691 +{
7692 + return v->counter;
7693 +}
7694 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7695 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7696 +{
7697 + return v->counter;
7698 +}
7699
7700 #define atomic_set(v, i) (((v)->counter) = i)
7701 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7702 +{
7703 + v->counter = i;
7704 +}
7705 #define atomic64_set(v, i) (((v)->counter) = i)
7706 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7707 +{
7708 + v->counter = i;
7709 +}
7710
7711 extern void atomic_add(int, atomic_t *);
7712 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7713 extern void atomic64_add(long, atomic64_t *);
7714 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7715 extern void atomic_sub(int, atomic_t *);
7716 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7717 extern void atomic64_sub(long, atomic64_t *);
7718 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7719
7720 extern int atomic_add_ret(int, atomic_t *);
7721 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7722 extern long atomic64_add_ret(long, atomic64_t *);
7723 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7724 extern int atomic_sub_ret(int, atomic_t *);
7725 extern long atomic64_sub_ret(long, atomic64_t *);
7726
7727 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7728 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7729
7730 #define atomic_inc_return(v) atomic_add_ret(1, v)
7731 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7732 +{
7733 + return atomic_add_ret_unchecked(1, v);
7734 +}
7735 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7736 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7737 +{
7738 + return atomic64_add_ret_unchecked(1, v);
7739 +}
7740
7741 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7742 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7743
7744 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7745 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7746 +{
7747 + return atomic_add_ret_unchecked(i, v);
7748 +}
7749 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7750 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7751 +{
7752 + return atomic64_add_ret_unchecked(i, v);
7753 +}
7754
7755 /*
7756 * atomic_inc_and_test - increment and test
7757 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7758 * other cases.
7759 */
7760 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7761 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7762 +{
7763 + return atomic_inc_return_unchecked(v) == 0;
7764 +}
7765 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7766
7767 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7768 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7769 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7770
7771 #define atomic_inc(v) atomic_add(1, v)
7772 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7773 +{
7774 + atomic_add_unchecked(1, v);
7775 +}
7776 #define atomic64_inc(v) atomic64_add(1, v)
7777 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7778 +{
7779 + atomic64_add_unchecked(1, v);
7780 +}
7781
7782 #define atomic_dec(v) atomic_sub(1, v)
7783 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7784 +{
7785 + atomic_sub_unchecked(1, v);
7786 +}
7787 #define atomic64_dec(v) atomic64_sub(1, v)
7788 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7789 +{
7790 + atomic64_sub_unchecked(1, v);
7791 +}
7792
7793 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7794 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7795
7796 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7797 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7798 +{
7799 + return cmpxchg(&v->counter, old, new);
7800 +}
7801 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7802 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7803 +{
7804 + return xchg(&v->counter, new);
7805 +}
7806
7807 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7808 {
7809 - int c, old;
7810 + int c, old, new;
7811 c = atomic_read(v);
7812 for (;;) {
7813 - if (unlikely(c == (u)))
7814 + if (unlikely(c == u))
7815 break;
7816 - old = atomic_cmpxchg((v), c, c + (a));
7817 +
7818 + asm volatile("addcc %2, %0, %0\n"
7819 +
7820 +#ifdef CONFIG_PAX_REFCOUNT
7821 + "tvs %%icc, 6\n"
7822 +#endif
7823 +
7824 + : "=r" (new)
7825 + : "0" (c), "ir" (a)
7826 + : "cc");
7827 +
7828 + old = atomic_cmpxchg(v, c, new);
7829 if (likely(old == c))
7830 break;
7831 c = old;
7832 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7833 #define atomic64_cmpxchg(v, o, n) \
7834 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7835 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7836 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7837 +{
7838 + return xchg(&v->counter, new);
7839 +}
7840
7841 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7842 {
7843 - long c, old;
7844 + long c, old, new;
7845 c = atomic64_read(v);
7846 for (;;) {
7847 - if (unlikely(c == (u)))
7848 + if (unlikely(c == u))
7849 break;
7850 - old = atomic64_cmpxchg((v), c, c + (a));
7851 +
7852 + asm volatile("addcc %2, %0, %0\n"
7853 +
7854 +#ifdef CONFIG_PAX_REFCOUNT
7855 + "tvs %%xcc, 6\n"
7856 +#endif
7857 +
7858 + : "=r" (new)
7859 + : "0" (c), "ir" (a)
7860 + : "cc");
7861 +
7862 + old = atomic64_cmpxchg(v, c, new);
7863 if (likely(old == c))
7864 break;
7865 c = old;
7866 }
7867 - return c != (u);
7868 + return c != u;
7869 }
7870
7871 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7872 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7873 index 5bb6991..5c2132e 100644
7874 --- a/arch/sparc/include/asm/cache.h
7875 +++ b/arch/sparc/include/asm/cache.h
7876 @@ -7,10 +7,12 @@
7877 #ifndef _SPARC_CACHE_H
7878 #define _SPARC_CACHE_H
7879
7880 +#include <linux/const.h>
7881 +
7882 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7883
7884 #define L1_CACHE_SHIFT 5
7885 -#define L1_CACHE_BYTES 32
7886 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7887
7888 #ifdef CONFIG_SPARC32
7889 #define SMP_CACHE_BYTES_SHIFT 5
7890 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7891 index a24e41f..47677ff 100644
7892 --- a/arch/sparc/include/asm/elf_32.h
7893 +++ b/arch/sparc/include/asm/elf_32.h
7894 @@ -114,6 +114,13 @@ typedef struct {
7895
7896 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7897
7898 +#ifdef CONFIG_PAX_ASLR
7899 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7900 +
7901 +#define PAX_DELTA_MMAP_LEN 16
7902 +#define PAX_DELTA_STACK_LEN 16
7903 +#endif
7904 +
7905 /* This yields a mask that user programs can use to figure out what
7906 instruction set this cpu supports. This can NOT be done in userspace
7907 on Sparc. */
7908 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7909 index 370ca1e..d4f4a98 100644
7910 --- a/arch/sparc/include/asm/elf_64.h
7911 +++ b/arch/sparc/include/asm/elf_64.h
7912 @@ -189,6 +189,13 @@ typedef struct {
7913 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7914 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7915
7916 +#ifdef CONFIG_PAX_ASLR
7917 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7918 +
7919 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7920 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7921 +#endif
7922 +
7923 extern unsigned long sparc64_elf_hwcap;
7924 #define ELF_HWCAP sparc64_elf_hwcap
7925
7926 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7927 index 9b1c36d..209298b 100644
7928 --- a/arch/sparc/include/asm/pgalloc_32.h
7929 +++ b/arch/sparc/include/asm/pgalloc_32.h
7930 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7931 }
7932
7933 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7934 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7935
7936 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7937 unsigned long address)
7938 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7939 index bcfe063..b333142 100644
7940 --- a/arch/sparc/include/asm/pgalloc_64.h
7941 +++ b/arch/sparc/include/asm/pgalloc_64.h
7942 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7943 }
7944
7945 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7946 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7947
7948 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7949 {
7950 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7951 index 6fc1348..390c50a 100644
7952 --- a/arch/sparc/include/asm/pgtable_32.h
7953 +++ b/arch/sparc/include/asm/pgtable_32.h
7954 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7955 #define PAGE_SHARED SRMMU_PAGE_SHARED
7956 #define PAGE_COPY SRMMU_PAGE_COPY
7957 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7958 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7959 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7960 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7961 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7962
7963 /* Top-level page directory - dummy used by init-mm.
7964 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7965
7966 /* xwr */
7967 #define __P000 PAGE_NONE
7968 -#define __P001 PAGE_READONLY
7969 -#define __P010 PAGE_COPY
7970 -#define __P011 PAGE_COPY
7971 +#define __P001 PAGE_READONLY_NOEXEC
7972 +#define __P010 PAGE_COPY_NOEXEC
7973 +#define __P011 PAGE_COPY_NOEXEC
7974 #define __P100 PAGE_READONLY
7975 #define __P101 PAGE_READONLY
7976 #define __P110 PAGE_COPY
7977 #define __P111 PAGE_COPY
7978
7979 #define __S000 PAGE_NONE
7980 -#define __S001 PAGE_READONLY
7981 -#define __S010 PAGE_SHARED
7982 -#define __S011 PAGE_SHARED
7983 +#define __S001 PAGE_READONLY_NOEXEC
7984 +#define __S010 PAGE_SHARED_NOEXEC
7985 +#define __S011 PAGE_SHARED_NOEXEC
7986 #define __S100 PAGE_READONLY
7987 #define __S101 PAGE_READONLY
7988 #define __S110 PAGE_SHARED
7989 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7990 index 79da178..c2eede8 100644
7991 --- a/arch/sparc/include/asm/pgtsrmmu.h
7992 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7993 @@ -115,6 +115,11 @@
7994 SRMMU_EXEC | SRMMU_REF)
7995 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7996 SRMMU_EXEC | SRMMU_REF)
7997 +
7998 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7999 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8000 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8001 +
8002 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8003 SRMMU_DIRTY | SRMMU_REF)
8004
8005 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8006 index 9689176..63c18ea 100644
8007 --- a/arch/sparc/include/asm/spinlock_64.h
8008 +++ b/arch/sparc/include/asm/spinlock_64.h
8009 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8010
8011 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8012
8013 -static void inline arch_read_lock(arch_rwlock_t *lock)
8014 +static inline void arch_read_lock(arch_rwlock_t *lock)
8015 {
8016 unsigned long tmp1, tmp2;
8017
8018 __asm__ __volatile__ (
8019 "1: ldsw [%2], %0\n"
8020 " brlz,pn %0, 2f\n"
8021 -"4: add %0, 1, %1\n"
8022 +"4: addcc %0, 1, %1\n"
8023 +
8024 +#ifdef CONFIG_PAX_REFCOUNT
8025 +" tvs %%icc, 6\n"
8026 +#endif
8027 +
8028 " cas [%2], %0, %1\n"
8029 " cmp %0, %1\n"
8030 " bne,pn %%icc, 1b\n"
8031 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8032 " .previous"
8033 : "=&r" (tmp1), "=&r" (tmp2)
8034 : "r" (lock)
8035 - : "memory");
8036 + : "memory", "cc");
8037 }
8038
8039 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8040 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8041 {
8042 int tmp1, tmp2;
8043
8044 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8045 "1: ldsw [%2], %0\n"
8046 " brlz,a,pn %0, 2f\n"
8047 " mov 0, %0\n"
8048 -" add %0, 1, %1\n"
8049 +" addcc %0, 1, %1\n"
8050 +
8051 +#ifdef CONFIG_PAX_REFCOUNT
8052 +" tvs %%icc, 6\n"
8053 +#endif
8054 +
8055 " cas [%2], %0, %1\n"
8056 " cmp %0, %1\n"
8057 " bne,pn %%icc, 1b\n"
8058 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8059 return tmp1;
8060 }
8061
8062 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8063 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8064 {
8065 unsigned long tmp1, tmp2;
8066
8067 __asm__ __volatile__(
8068 "1: lduw [%2], %0\n"
8069 -" sub %0, 1, %1\n"
8070 +" subcc %0, 1, %1\n"
8071 +
8072 +#ifdef CONFIG_PAX_REFCOUNT
8073 +" tvs %%icc, 6\n"
8074 +#endif
8075 +
8076 " cas [%2], %0, %1\n"
8077 " cmp %0, %1\n"
8078 " bne,pn %%xcc, 1b\n"
8079 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8080 : "memory");
8081 }
8082
8083 -static void inline arch_write_lock(arch_rwlock_t *lock)
8084 +static inline void arch_write_lock(arch_rwlock_t *lock)
8085 {
8086 unsigned long mask, tmp1, tmp2;
8087
8088 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8089 : "memory");
8090 }
8091
8092 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8093 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8094 {
8095 __asm__ __volatile__(
8096 " stw %%g0, [%0]"
8097 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8098 : "memory");
8099 }
8100
8101 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8102 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8103 {
8104 unsigned long mask, tmp1, tmp2, result;
8105
8106 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8107 index dd38075..e7cac83 100644
8108 --- a/arch/sparc/include/asm/thread_info_32.h
8109 +++ b/arch/sparc/include/asm/thread_info_32.h
8110 @@ -49,6 +49,8 @@ struct thread_info {
8111 unsigned long w_saved;
8112
8113 struct restart_block restart_block;
8114 +
8115 + unsigned long lowest_stack;
8116 };
8117
8118 /*
8119 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8120 index d5e5042..9bfee76 100644
8121 --- a/arch/sparc/include/asm/thread_info_64.h
8122 +++ b/arch/sparc/include/asm/thread_info_64.h
8123 @@ -63,6 +63,8 @@ struct thread_info {
8124 struct pt_regs *kern_una_regs;
8125 unsigned int kern_una_insn;
8126
8127 + unsigned long lowest_stack;
8128 +
8129 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8130 };
8131
8132 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8133 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8134 /* flag bit 6 is available */
8135 #define TIF_32BIT 7 /* 32-bit binary */
8136 -/* flag bit 8 is available */
8137 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8138 #define TIF_SECCOMP 9 /* secure computing */
8139 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8140 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8141 +
8142 /* NOTE: Thread flags >= 12 should be ones we have no interest
8143 * in using in assembly, else we can't use the mask as
8144 * an immediate value in instructions such as andcc.
8145 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8146 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8147 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8148 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8149 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8150
8151 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8152 _TIF_DO_NOTIFY_RESUME_MASK | \
8153 _TIF_NEED_RESCHED)
8154 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8155
8156 +#define _TIF_WORK_SYSCALL \
8157 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8158 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8159 +
8160 +
8161 /*
8162 * Thread-synchronous status.
8163 *
8164 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8165 index 0167d26..767bb0c 100644
8166 --- a/arch/sparc/include/asm/uaccess.h
8167 +++ b/arch/sparc/include/asm/uaccess.h
8168 @@ -1,5 +1,6 @@
8169 #ifndef ___ASM_SPARC_UACCESS_H
8170 #define ___ASM_SPARC_UACCESS_H
8171 +
8172 #if defined(__sparc__) && defined(__arch64__)
8173 #include <asm/uaccess_64.h>
8174 #else
8175 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8176 index 53a28dd..50c38c3 100644
8177 --- a/arch/sparc/include/asm/uaccess_32.h
8178 +++ b/arch/sparc/include/asm/uaccess_32.h
8179 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8180
8181 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8182 {
8183 - if (n && __access_ok((unsigned long) to, n))
8184 + if ((long)n < 0)
8185 + return n;
8186 +
8187 + if (n && __access_ok((unsigned long) to, n)) {
8188 + if (!__builtin_constant_p(n))
8189 + check_object_size(from, n, true);
8190 return __copy_user(to, (__force void __user *) from, n);
8191 - else
8192 + } else
8193 return n;
8194 }
8195
8196 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8197 {
8198 + if ((long)n < 0)
8199 + return n;
8200 +
8201 + if (!__builtin_constant_p(n))
8202 + check_object_size(from, n, true);
8203 +
8204 return __copy_user(to, (__force void __user *) from, n);
8205 }
8206
8207 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8208 {
8209 - if (n && __access_ok((unsigned long) from, n))
8210 + if ((long)n < 0)
8211 + return n;
8212 +
8213 + if (n && __access_ok((unsigned long) from, n)) {
8214 + if (!__builtin_constant_p(n))
8215 + check_object_size(to, n, false);
8216 return __copy_user((__force void __user *) to, from, n);
8217 - else
8218 + } else
8219 return n;
8220 }
8221
8222 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8223 {
8224 + if ((long)n < 0)
8225 + return n;
8226 +
8227 return __copy_user((__force void __user *) to, from, n);
8228 }
8229
8230 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8231 index e562d3c..191f176 100644
8232 --- a/arch/sparc/include/asm/uaccess_64.h
8233 +++ b/arch/sparc/include/asm/uaccess_64.h
8234 @@ -10,6 +10,7 @@
8235 #include <linux/compiler.h>
8236 #include <linux/string.h>
8237 #include <linux/thread_info.h>
8238 +#include <linux/kernel.h>
8239 #include <asm/asi.h>
8240 #include <asm/spitfire.h>
8241 #include <asm-generic/uaccess-unaligned.h>
8242 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8243 static inline unsigned long __must_check
8244 copy_from_user(void *to, const void __user *from, unsigned long size)
8245 {
8246 - unsigned long ret = ___copy_from_user(to, from, size);
8247 + unsigned long ret;
8248
8249 + if ((long)size < 0 || size > INT_MAX)
8250 + return size;
8251 +
8252 + if (!__builtin_constant_p(size))
8253 + check_object_size(to, size, false);
8254 +
8255 + ret = ___copy_from_user(to, from, size);
8256 if (unlikely(ret))
8257 ret = copy_from_user_fixup(to, from, size);
8258
8259 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8260 static inline unsigned long __must_check
8261 copy_to_user(void __user *to, const void *from, unsigned long size)
8262 {
8263 - unsigned long ret = ___copy_to_user(to, from, size);
8264 + unsigned long ret;
8265
8266 + if ((long)size < 0 || size > INT_MAX)
8267 + return size;
8268 +
8269 + if (!__builtin_constant_p(size))
8270 + check_object_size(from, size, true);
8271 +
8272 + ret = ___copy_to_user(to, from, size);
8273 if (unlikely(ret))
8274 ret = copy_to_user_fixup(to, from, size);
8275 return ret;
8276 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8277 index d432fb2..6056af1 100644
8278 --- a/arch/sparc/kernel/Makefile
8279 +++ b/arch/sparc/kernel/Makefile
8280 @@ -3,7 +3,7 @@
8281 #
8282
8283 asflags-y := -ansi
8284 -ccflags-y := -Werror
8285 +#ccflags-y := -Werror
8286
8287 extra-y := head_$(BITS).o
8288
8289 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
8290 index 5ef48da..11d460f 100644
8291 --- a/arch/sparc/kernel/ds.c
8292 +++ b/arch/sparc/kernel/ds.c
8293 @@ -783,6 +783,16 @@ void ldom_set_var(const char *var, const char *value)
8294 char *base, *p;
8295 int msg_len, loops;
8296
8297 + if (strlen(var) + strlen(value) + 2 >
8298 + sizeof(pkt) - sizeof(pkt.header)) {
8299 + printk(KERN_ERR PFX
8300 + "contents length: %zu, which more than max: %lu,"
8301 + "so could not set (%s) variable to (%s).\n",
8302 + strlen(var) + strlen(value) + 2,
8303 + sizeof(pkt) - sizeof(pkt.header), var, value);
8304 + return;
8305 + }
8306 +
8307 memset(&pkt, 0, sizeof(pkt));
8308 pkt.header.data.tag.type = DS_DATA;
8309 pkt.header.data.handle = cp->handle;
8310 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8311 index fdd819d..5af08c8 100644
8312 --- a/arch/sparc/kernel/process_32.c
8313 +++ b/arch/sparc/kernel/process_32.c
8314 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
8315
8316 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8317 r->psr, r->pc, r->npc, r->y, print_tainted());
8318 - printk("PC: <%pS>\n", (void *) r->pc);
8319 + printk("PC: <%pA>\n", (void *) r->pc);
8320 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8321 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8322 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8323 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8324 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8325 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8326 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8327 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8328
8329 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8330 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8331 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8332 rw = (struct reg_window32 *) fp;
8333 pc = rw->ins[7];
8334 printk("[%08lx : ", pc);
8335 - printk("%pS ] ", (void *) pc);
8336 + printk("%pA ] ", (void *) pc);
8337 fp = rw->ins[6];
8338 } while (++count < 16);
8339 printk("\n");
8340 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8341 index baebab2..9cd13b1 100644
8342 --- a/arch/sparc/kernel/process_64.c
8343 +++ b/arch/sparc/kernel/process_64.c
8344 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
8345 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8346 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8347 if (regs->tstate & TSTATE_PRIV)
8348 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8349 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8350 }
8351
8352 void show_regs(struct pt_regs *regs)
8353 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
8354
8355 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8356 regs->tpc, regs->tnpc, regs->y, print_tainted());
8357 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8358 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8359 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8360 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8361 regs->u_regs[3]);
8362 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
8363 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8364 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8365 regs->u_regs[15]);
8366 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8367 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8368 show_regwindow(regs);
8369 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8370 }
8371 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
8372 ((tp && tp->task) ? tp->task->pid : -1));
8373
8374 if (gp->tstate & TSTATE_PRIV) {
8375 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8376 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8377 (void *) gp->tpc,
8378 (void *) gp->o7,
8379 (void *) gp->i7,
8380 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8381 index 79cc0d1..ec62734 100644
8382 --- a/arch/sparc/kernel/prom_common.c
8383 +++ b/arch/sparc/kernel/prom_common.c
8384 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8385
8386 unsigned int prom_early_allocated __initdata;
8387
8388 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8389 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8390 .nextprop = prom_common_nextprop,
8391 .getproplen = prom_getproplen,
8392 .getproperty = prom_getproperty,
8393 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8394 index 7ff45e4..a58f271 100644
8395 --- a/arch/sparc/kernel/ptrace_64.c
8396 +++ b/arch/sparc/kernel/ptrace_64.c
8397 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8398 return ret;
8399 }
8400
8401 +#ifdef CONFIG_GRKERNSEC_SETXID
8402 +extern void gr_delayed_cred_worker(void);
8403 +#endif
8404 +
8405 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8406 {
8407 int ret = 0;
8408 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8409 /* do the secure computing check first */
8410 secure_computing_strict(regs->u_regs[UREG_G1]);
8411
8412 +#ifdef CONFIG_GRKERNSEC_SETXID
8413 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8414 + gr_delayed_cred_worker();
8415 +#endif
8416 +
8417 if (test_thread_flag(TIF_SYSCALL_TRACE))
8418 ret = tracehook_report_syscall_entry(regs);
8419
8420 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8421
8422 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8423 {
8424 +#ifdef CONFIG_GRKERNSEC_SETXID
8425 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8426 + gr_delayed_cred_worker();
8427 +#endif
8428 +
8429 audit_syscall_exit(regs);
8430
8431 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8432 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8433 index 3a8d184..49498a8 100644
8434 --- a/arch/sparc/kernel/sys_sparc_32.c
8435 +++ b/arch/sparc/kernel/sys_sparc_32.c
8436 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8437 if (len > TASK_SIZE - PAGE_SIZE)
8438 return -ENOMEM;
8439 if (!addr)
8440 - addr = TASK_UNMAPPED_BASE;
8441 + addr = current->mm->mmap_base;
8442
8443 info.flags = 0;
8444 info.length = len;
8445 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8446 index 2daaaa6..4fb84dc 100644
8447 --- a/arch/sparc/kernel/sys_sparc_64.c
8448 +++ b/arch/sparc/kernel/sys_sparc_64.c
8449 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8450 struct vm_area_struct * vma;
8451 unsigned long task_size = TASK_SIZE;
8452 int do_color_align;
8453 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8454 struct vm_unmapped_area_info info;
8455
8456 if (flags & MAP_FIXED) {
8457 /* We do not accept a shared mapping if it would violate
8458 * cache aliasing constraints.
8459 */
8460 - if ((flags & MAP_SHARED) &&
8461 + if ((filp || (flags & MAP_SHARED)) &&
8462 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8463 return -EINVAL;
8464 return addr;
8465 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8466 if (filp || (flags & MAP_SHARED))
8467 do_color_align = 1;
8468
8469 +#ifdef CONFIG_PAX_RANDMMAP
8470 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8471 +#endif
8472 +
8473 if (addr) {
8474 if (do_color_align)
8475 addr = COLOR_ALIGN(addr, pgoff);
8476 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8477 addr = PAGE_ALIGN(addr);
8478
8479 vma = find_vma(mm, addr);
8480 - if (task_size - len >= addr &&
8481 - (!vma || addr + len <= vma->vm_start))
8482 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8483 return addr;
8484 }
8485
8486 info.flags = 0;
8487 info.length = len;
8488 - info.low_limit = TASK_UNMAPPED_BASE;
8489 + info.low_limit = mm->mmap_base;
8490 info.high_limit = min(task_size, VA_EXCLUDE_START);
8491 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8492 info.align_offset = pgoff << PAGE_SHIFT;
8493 + info.threadstack_offset = offset;
8494 addr = vm_unmapped_area(&info);
8495
8496 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8497 VM_BUG_ON(addr != -ENOMEM);
8498 info.low_limit = VA_EXCLUDE_END;
8499 +
8500 +#ifdef CONFIG_PAX_RANDMMAP
8501 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8502 + info.low_limit += mm->delta_mmap;
8503 +#endif
8504 +
8505 info.high_limit = task_size;
8506 addr = vm_unmapped_area(&info);
8507 }
8508 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8509 unsigned long task_size = STACK_TOP32;
8510 unsigned long addr = addr0;
8511 int do_color_align;
8512 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8513 struct vm_unmapped_area_info info;
8514
8515 /* This should only ever run for 32-bit processes. */
8516 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8517 /* We do not accept a shared mapping if it would violate
8518 * cache aliasing constraints.
8519 */
8520 - if ((flags & MAP_SHARED) &&
8521 + if ((filp || (flags & MAP_SHARED)) &&
8522 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8523 return -EINVAL;
8524 return addr;
8525 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8526 if (filp || (flags & MAP_SHARED))
8527 do_color_align = 1;
8528
8529 +#ifdef CONFIG_PAX_RANDMMAP
8530 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8531 +#endif
8532 +
8533 /* requesting a specific address */
8534 if (addr) {
8535 if (do_color_align)
8536 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8537 addr = PAGE_ALIGN(addr);
8538
8539 vma = find_vma(mm, addr);
8540 - if (task_size - len >= addr &&
8541 - (!vma || addr + len <= vma->vm_start))
8542 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8543 return addr;
8544 }
8545
8546 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8547 info.high_limit = mm->mmap_base;
8548 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8549 info.align_offset = pgoff << PAGE_SHIFT;
8550 + info.threadstack_offset = offset;
8551 addr = vm_unmapped_area(&info);
8552
8553 /*
8554 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8555 VM_BUG_ON(addr != -ENOMEM);
8556 info.flags = 0;
8557 info.low_limit = TASK_UNMAPPED_BASE;
8558 +
8559 +#ifdef CONFIG_PAX_RANDMMAP
8560 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8561 + info.low_limit += mm->delta_mmap;
8562 +#endif
8563 +
8564 info.high_limit = STACK_TOP32;
8565 addr = vm_unmapped_area(&info);
8566 }
8567 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
8568 EXPORT_SYMBOL(get_fb_unmapped_area);
8569
8570 /* Essentially the same as PowerPC. */
8571 -static unsigned long mmap_rnd(void)
8572 +static unsigned long mmap_rnd(struct mm_struct *mm)
8573 {
8574 unsigned long rnd = 0UL;
8575
8576 +#ifdef CONFIG_PAX_RANDMMAP
8577 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8578 +#endif
8579 +
8580 if (current->flags & PF_RANDOMIZE) {
8581 unsigned long val = get_random_int();
8582 if (test_thread_flag(TIF_32BIT))
8583 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
8584
8585 void arch_pick_mmap_layout(struct mm_struct *mm)
8586 {
8587 - unsigned long random_factor = mmap_rnd();
8588 + unsigned long random_factor = mmap_rnd(mm);
8589 unsigned long gap;
8590
8591 /*
8592 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8593 gap == RLIM_INFINITY ||
8594 sysctl_legacy_va_layout) {
8595 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8596 +
8597 +#ifdef CONFIG_PAX_RANDMMAP
8598 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8599 + mm->mmap_base += mm->delta_mmap;
8600 +#endif
8601 +
8602 mm->get_unmapped_area = arch_get_unmapped_area;
8603 mm->unmap_area = arch_unmap_area;
8604 } else {
8605 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8606 gap = (task_size / 6 * 5);
8607
8608 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8609 +
8610 +#ifdef CONFIG_PAX_RANDMMAP
8611 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8612 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8613 +#endif
8614 +
8615 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8616 mm->unmap_area = arch_unmap_area_topdown;
8617 }
8618 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8619 index 22a1098..6255eb9 100644
8620 --- a/arch/sparc/kernel/syscalls.S
8621 +++ b/arch/sparc/kernel/syscalls.S
8622 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8623 #endif
8624 .align 32
8625 1: ldx [%g6 + TI_FLAGS], %l5
8626 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8627 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8628 be,pt %icc, rtrap
8629 nop
8630 call syscall_trace_leave
8631 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8632
8633 srl %i5, 0, %o5 ! IEU1
8634 srl %i2, 0, %o2 ! IEU0 Group
8635 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8636 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8637 bne,pn %icc, linux_syscall_trace32 ! CTI
8638 mov %i0, %l5 ! IEU1
8639 call %l7 ! CTI Group brk forced
8640 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8641
8642 mov %i3, %o3 ! IEU1
8643 mov %i4, %o4 ! IEU0 Group
8644 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8645 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8646 bne,pn %icc, linux_syscall_trace ! CTI Group
8647 mov %i0, %l5 ! IEU0
8648 2: call %l7 ! CTI Group brk forced
8649 @@ -223,7 +223,7 @@ ret_sys_call:
8650
8651 cmp %o0, -ERESTART_RESTARTBLOCK
8652 bgeu,pn %xcc, 1f
8653 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8654 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8655 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8656
8657 2:
8658 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8659 index 654e8aa..45f431b 100644
8660 --- a/arch/sparc/kernel/sysfs.c
8661 +++ b/arch/sparc/kernel/sysfs.c
8662 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8663 return NOTIFY_OK;
8664 }
8665
8666 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8667 +static struct notifier_block sysfs_cpu_nb = {
8668 .notifier_call = sysfs_cpu_notify,
8669 };
8670
8671 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8672 index 6629829..036032d 100644
8673 --- a/arch/sparc/kernel/traps_32.c
8674 +++ b/arch/sparc/kernel/traps_32.c
8675 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8676 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8677 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8678
8679 +extern void gr_handle_kernel_exploit(void);
8680 +
8681 void die_if_kernel(char *str, struct pt_regs *regs)
8682 {
8683 static int die_counter;
8684 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8685 count++ < 30 &&
8686 (((unsigned long) rw) >= PAGE_OFFSET) &&
8687 !(((unsigned long) rw) & 0x7)) {
8688 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8689 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8690 (void *) rw->ins[7]);
8691 rw = (struct reg_window32 *)rw->ins[6];
8692 }
8693 }
8694 printk("Instruction DUMP:");
8695 instruction_dump ((unsigned long *) regs->pc);
8696 - if(regs->psr & PSR_PS)
8697 + if(regs->psr & PSR_PS) {
8698 + gr_handle_kernel_exploit();
8699 do_exit(SIGKILL);
8700 + }
8701 do_exit(SIGSEGV);
8702 }
8703
8704 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8705 index b3f833a..ac74b2d 100644
8706 --- a/arch/sparc/kernel/traps_64.c
8707 +++ b/arch/sparc/kernel/traps_64.c
8708 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8709 i + 1,
8710 p->trapstack[i].tstate, p->trapstack[i].tpc,
8711 p->trapstack[i].tnpc, p->trapstack[i].tt);
8712 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8713 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8714 }
8715 }
8716
8717 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8718
8719 lvl -= 0x100;
8720 if (regs->tstate & TSTATE_PRIV) {
8721 +
8722 +#ifdef CONFIG_PAX_REFCOUNT
8723 + if (lvl == 6)
8724 + pax_report_refcount_overflow(regs);
8725 +#endif
8726 +
8727 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8728 die_if_kernel(buffer, regs);
8729 }
8730 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8731 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8732 {
8733 char buffer[32];
8734 -
8735 +
8736 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8737 0, lvl, SIGTRAP) == NOTIFY_STOP)
8738 return;
8739
8740 +#ifdef CONFIG_PAX_REFCOUNT
8741 + if (lvl == 6)
8742 + pax_report_refcount_overflow(regs);
8743 +#endif
8744 +
8745 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8746
8747 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8748 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8749 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8750 printk("%s" "ERROR(%d): ",
8751 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8752 - printk("TPC<%pS>\n", (void *) regs->tpc);
8753 + printk("TPC<%pA>\n", (void *) regs->tpc);
8754 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8755 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8756 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8757 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8758 smp_processor_id(),
8759 (type & 0x1) ? 'I' : 'D',
8760 regs->tpc);
8761 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8762 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8763 panic("Irrecoverable Cheetah+ parity error.");
8764 }
8765
8766 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8767 smp_processor_id(),
8768 (type & 0x1) ? 'I' : 'D',
8769 regs->tpc);
8770 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8771 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8772 }
8773
8774 struct sun4v_error_entry {
8775 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8776
8777 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8778 regs->tpc, tl);
8779 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8780 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8781 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8782 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8783 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8784 (void *) regs->u_regs[UREG_I7]);
8785 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8786 "pte[%lx] error[%lx]\n",
8787 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8788
8789 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8790 regs->tpc, tl);
8791 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8792 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8793 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8794 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8795 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8796 (void *) regs->u_regs[UREG_I7]);
8797 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8798 "pte[%lx] error[%lx]\n",
8799 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8800 fp = (unsigned long)sf->fp + STACK_BIAS;
8801 }
8802
8803 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8804 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8805 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8806 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8807 int index = tsk->curr_ret_stack;
8808 if (tsk->ret_stack && index >= graph) {
8809 pc = tsk->ret_stack[index - graph].ret;
8810 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8811 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8812 graph++;
8813 }
8814 }
8815 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8816 return (struct reg_window *) (fp + STACK_BIAS);
8817 }
8818
8819 +extern void gr_handle_kernel_exploit(void);
8820 +
8821 void die_if_kernel(char *str, struct pt_regs *regs)
8822 {
8823 static int die_counter;
8824 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8825 while (rw &&
8826 count++ < 30 &&
8827 kstack_valid(tp, (unsigned long) rw)) {
8828 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8829 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8830 (void *) rw->ins[7]);
8831
8832 rw = kernel_stack_up(rw);
8833 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8834 }
8835 user_instruction_dump ((unsigned int __user *) regs->tpc);
8836 }
8837 - if (regs->tstate & TSTATE_PRIV)
8838 + if (regs->tstate & TSTATE_PRIV) {
8839 + gr_handle_kernel_exploit();
8840 do_exit(SIGKILL);
8841 + }
8842 do_exit(SIGSEGV);
8843 }
8844 EXPORT_SYMBOL(die_if_kernel);
8845 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8846 index 8201c25e..072a2a7 100644
8847 --- a/arch/sparc/kernel/unaligned_64.c
8848 +++ b/arch/sparc/kernel/unaligned_64.c
8849 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8850 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8851
8852 if (__ratelimit(&ratelimit)) {
8853 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8854 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8855 regs->tpc, (void *) regs->tpc);
8856 }
8857 }
8858 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8859 index dbe119b..089c7c1 100644
8860 --- a/arch/sparc/lib/Makefile
8861 +++ b/arch/sparc/lib/Makefile
8862 @@ -2,7 +2,7 @@
8863 #
8864
8865 asflags-y := -ansi -DST_DIV0=0x02
8866 -ccflags-y := -Werror
8867 +#ccflags-y := -Werror
8868
8869 lib-$(CONFIG_SPARC32) += ashrdi3.o
8870 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8871 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8872 index 85c233d..68500e0 100644
8873 --- a/arch/sparc/lib/atomic_64.S
8874 +++ b/arch/sparc/lib/atomic_64.S
8875 @@ -17,7 +17,12 @@
8876 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8877 BACKOFF_SETUP(%o2)
8878 1: lduw [%o1], %g1
8879 - add %g1, %o0, %g7
8880 + addcc %g1, %o0, %g7
8881 +
8882 +#ifdef CONFIG_PAX_REFCOUNT
8883 + tvs %icc, 6
8884 +#endif
8885 +
8886 cas [%o1], %g1, %g7
8887 cmp %g1, %g7
8888 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8889 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8890 2: BACKOFF_SPIN(%o2, %o3, 1b)
8891 ENDPROC(atomic_add)
8892
8893 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8894 + BACKOFF_SETUP(%o2)
8895 +1: lduw [%o1], %g1
8896 + add %g1, %o0, %g7
8897 + cas [%o1], %g1, %g7
8898 + cmp %g1, %g7
8899 + bne,pn %icc, 2f
8900 + nop
8901 + retl
8902 + nop
8903 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8904 +ENDPROC(atomic_add_unchecked)
8905 +
8906 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8907 BACKOFF_SETUP(%o2)
8908 1: lduw [%o1], %g1
8909 - sub %g1, %o0, %g7
8910 + subcc %g1, %o0, %g7
8911 +
8912 +#ifdef CONFIG_PAX_REFCOUNT
8913 + tvs %icc, 6
8914 +#endif
8915 +
8916 cas [%o1], %g1, %g7
8917 cmp %g1, %g7
8918 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8919 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8920 2: BACKOFF_SPIN(%o2, %o3, 1b)
8921 ENDPROC(atomic_sub)
8922
8923 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8924 + BACKOFF_SETUP(%o2)
8925 +1: lduw [%o1], %g1
8926 + sub %g1, %o0, %g7
8927 + cas [%o1], %g1, %g7
8928 + cmp %g1, %g7
8929 + bne,pn %icc, 2f
8930 + nop
8931 + retl
8932 + nop
8933 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8934 +ENDPROC(atomic_sub_unchecked)
8935 +
8936 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8937 BACKOFF_SETUP(%o2)
8938 1: lduw [%o1], %g1
8939 - add %g1, %o0, %g7
8940 + addcc %g1, %o0, %g7
8941 +
8942 +#ifdef CONFIG_PAX_REFCOUNT
8943 + tvs %icc, 6
8944 +#endif
8945 +
8946 cas [%o1], %g1, %g7
8947 cmp %g1, %g7
8948 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8949 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8950 2: BACKOFF_SPIN(%o2, %o3, 1b)
8951 ENDPROC(atomic_add_ret)
8952
8953 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8954 + BACKOFF_SETUP(%o2)
8955 +1: lduw [%o1], %g1
8956 + addcc %g1, %o0, %g7
8957 + cas [%o1], %g1, %g7
8958 + cmp %g1, %g7
8959 + bne,pn %icc, 2f
8960 + add %g7, %o0, %g7
8961 + sra %g7, 0, %o0
8962 + retl
8963 + nop
8964 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8965 +ENDPROC(atomic_add_ret_unchecked)
8966 +
8967 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8968 BACKOFF_SETUP(%o2)
8969 1: lduw [%o1], %g1
8970 - sub %g1, %o0, %g7
8971 + subcc %g1, %o0, %g7
8972 +
8973 +#ifdef CONFIG_PAX_REFCOUNT
8974 + tvs %icc, 6
8975 +#endif
8976 +
8977 cas [%o1], %g1, %g7
8978 cmp %g1, %g7
8979 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8980 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8981 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8982 BACKOFF_SETUP(%o2)
8983 1: ldx [%o1], %g1
8984 - add %g1, %o0, %g7
8985 + addcc %g1, %o0, %g7
8986 +
8987 +#ifdef CONFIG_PAX_REFCOUNT
8988 + tvs %xcc, 6
8989 +#endif
8990 +
8991 casx [%o1], %g1, %g7
8992 cmp %g1, %g7
8993 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8994 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8995 2: BACKOFF_SPIN(%o2, %o3, 1b)
8996 ENDPROC(atomic64_add)
8997
8998 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8999 + BACKOFF_SETUP(%o2)
9000 +1: ldx [%o1], %g1
9001 + addcc %g1, %o0, %g7
9002 + casx [%o1], %g1, %g7
9003 + cmp %g1, %g7
9004 + bne,pn %xcc, 2f
9005 + nop
9006 + retl
9007 + nop
9008 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9009 +ENDPROC(atomic64_add_unchecked)
9010 +
9011 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9012 BACKOFF_SETUP(%o2)
9013 1: ldx [%o1], %g1
9014 - sub %g1, %o0, %g7
9015 + subcc %g1, %o0, %g7
9016 +
9017 +#ifdef CONFIG_PAX_REFCOUNT
9018 + tvs %xcc, 6
9019 +#endif
9020 +
9021 casx [%o1], %g1, %g7
9022 cmp %g1, %g7
9023 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9024 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9025 2: BACKOFF_SPIN(%o2, %o3, 1b)
9026 ENDPROC(atomic64_sub)
9027
9028 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9029 + BACKOFF_SETUP(%o2)
9030 +1: ldx [%o1], %g1
9031 + subcc %g1, %o0, %g7
9032 + casx [%o1], %g1, %g7
9033 + cmp %g1, %g7
9034 + bne,pn %xcc, 2f
9035 + nop
9036 + retl
9037 + nop
9038 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9039 +ENDPROC(atomic64_sub_unchecked)
9040 +
9041 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9042 BACKOFF_SETUP(%o2)
9043 1: ldx [%o1], %g1
9044 - add %g1, %o0, %g7
9045 + addcc %g1, %o0, %g7
9046 +
9047 +#ifdef CONFIG_PAX_REFCOUNT
9048 + tvs %xcc, 6
9049 +#endif
9050 +
9051 casx [%o1], %g1, %g7
9052 cmp %g1, %g7
9053 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9054 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9055 2: BACKOFF_SPIN(%o2, %o3, 1b)
9056 ENDPROC(atomic64_add_ret)
9057
9058 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9059 + BACKOFF_SETUP(%o2)
9060 +1: ldx [%o1], %g1
9061 + addcc %g1, %o0, %g7
9062 + casx [%o1], %g1, %g7
9063 + cmp %g1, %g7
9064 + bne,pn %xcc, 2f
9065 + add %g7, %o0, %g7
9066 + mov %g7, %o0
9067 + retl
9068 + nop
9069 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9070 +ENDPROC(atomic64_add_ret_unchecked)
9071 +
9072 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9073 BACKOFF_SETUP(%o2)
9074 1: ldx [%o1], %g1
9075 - sub %g1, %o0, %g7
9076 + subcc %g1, %o0, %g7
9077 +
9078 +#ifdef CONFIG_PAX_REFCOUNT
9079 + tvs %xcc, 6
9080 +#endif
9081 +
9082 casx [%o1], %g1, %g7
9083 cmp %g1, %g7
9084 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9085 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9086 index 0c4e35e..745d3e4 100644
9087 --- a/arch/sparc/lib/ksyms.c
9088 +++ b/arch/sparc/lib/ksyms.c
9089 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9090
9091 /* Atomic counter implementation. */
9092 EXPORT_SYMBOL(atomic_add);
9093 +EXPORT_SYMBOL(atomic_add_unchecked);
9094 EXPORT_SYMBOL(atomic_add_ret);
9095 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9096 EXPORT_SYMBOL(atomic_sub);
9097 +EXPORT_SYMBOL(atomic_sub_unchecked);
9098 EXPORT_SYMBOL(atomic_sub_ret);
9099 EXPORT_SYMBOL(atomic64_add);
9100 +EXPORT_SYMBOL(atomic64_add_unchecked);
9101 EXPORT_SYMBOL(atomic64_add_ret);
9102 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9103 EXPORT_SYMBOL(atomic64_sub);
9104 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9105 EXPORT_SYMBOL(atomic64_sub_ret);
9106 EXPORT_SYMBOL(atomic64_dec_if_positive);
9107
9108 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9109 index 30c3ecc..736f015 100644
9110 --- a/arch/sparc/mm/Makefile
9111 +++ b/arch/sparc/mm/Makefile
9112 @@ -2,7 +2,7 @@
9113 #
9114
9115 asflags-y := -ansi
9116 -ccflags-y := -Werror
9117 +#ccflags-y := -Werror
9118
9119 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9120 obj-y += fault_$(BITS).o
9121 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9122 index e98bfda..ea8d221 100644
9123 --- a/arch/sparc/mm/fault_32.c
9124 +++ b/arch/sparc/mm/fault_32.c
9125 @@ -21,6 +21,9 @@
9126 #include <linux/perf_event.h>
9127 #include <linux/interrupt.h>
9128 #include <linux/kdebug.h>
9129 +#include <linux/slab.h>
9130 +#include <linux/pagemap.h>
9131 +#include <linux/compiler.h>
9132
9133 #include <asm/page.h>
9134 #include <asm/pgtable.h>
9135 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9136 return safe_compute_effective_address(regs, insn);
9137 }
9138
9139 +#ifdef CONFIG_PAX_PAGEEXEC
9140 +#ifdef CONFIG_PAX_DLRESOLVE
9141 +static void pax_emuplt_close(struct vm_area_struct *vma)
9142 +{
9143 + vma->vm_mm->call_dl_resolve = 0UL;
9144 +}
9145 +
9146 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9147 +{
9148 + unsigned int *kaddr;
9149 +
9150 + vmf->page = alloc_page(GFP_HIGHUSER);
9151 + if (!vmf->page)
9152 + return VM_FAULT_OOM;
9153 +
9154 + kaddr = kmap(vmf->page);
9155 + memset(kaddr, 0, PAGE_SIZE);
9156 + kaddr[0] = 0x9DE3BFA8U; /* save */
9157 + flush_dcache_page(vmf->page);
9158 + kunmap(vmf->page);
9159 + return VM_FAULT_MAJOR;
9160 +}
9161 +
9162 +static const struct vm_operations_struct pax_vm_ops = {
9163 + .close = pax_emuplt_close,
9164 + .fault = pax_emuplt_fault
9165 +};
9166 +
9167 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9168 +{
9169 + int ret;
9170 +
9171 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9172 + vma->vm_mm = current->mm;
9173 + vma->vm_start = addr;
9174 + vma->vm_end = addr + PAGE_SIZE;
9175 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9176 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9177 + vma->vm_ops = &pax_vm_ops;
9178 +
9179 + ret = insert_vm_struct(current->mm, vma);
9180 + if (ret)
9181 + return ret;
9182 +
9183 + ++current->mm->total_vm;
9184 + return 0;
9185 +}
9186 +#endif
9187 +
9188 +/*
9189 + * PaX: decide what to do with offenders (regs->pc = fault address)
9190 + *
9191 + * returns 1 when task should be killed
9192 + * 2 when patched PLT trampoline was detected
9193 + * 3 when unpatched PLT trampoline was detected
9194 + */
9195 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9196 +{
9197 +
9198 +#ifdef CONFIG_PAX_EMUPLT
9199 + int err;
9200 +
9201 + do { /* PaX: patched PLT emulation #1 */
9202 + unsigned int sethi1, sethi2, jmpl;
9203 +
9204 + err = get_user(sethi1, (unsigned int *)regs->pc);
9205 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9206 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9207 +
9208 + if (err)
9209 + break;
9210 +
9211 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9212 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9213 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9214 + {
9215 + unsigned int addr;
9216 +
9217 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9218 + addr = regs->u_regs[UREG_G1];
9219 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9220 + regs->pc = addr;
9221 + regs->npc = addr+4;
9222 + return 2;
9223 + }
9224 + } while (0);
9225 +
9226 + do { /* PaX: patched PLT emulation #2 */
9227 + unsigned int ba;
9228 +
9229 + err = get_user(ba, (unsigned int *)regs->pc);
9230 +
9231 + if (err)
9232 + break;
9233 +
9234 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9235 + unsigned int addr;
9236 +
9237 + if ((ba & 0xFFC00000U) == 0x30800000U)
9238 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9239 + else
9240 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9241 + regs->pc = addr;
9242 + regs->npc = addr+4;
9243 + return 2;
9244 + }
9245 + } while (0);
9246 +
9247 + do { /* PaX: patched PLT emulation #3 */
9248 + unsigned int sethi, bajmpl, nop;
9249 +
9250 + err = get_user(sethi, (unsigned int *)regs->pc);
9251 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9252 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9253 +
9254 + if (err)
9255 + break;
9256 +
9257 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9258 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9259 + nop == 0x01000000U)
9260 + {
9261 + unsigned int addr;
9262 +
9263 + addr = (sethi & 0x003FFFFFU) << 10;
9264 + regs->u_regs[UREG_G1] = addr;
9265 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9266 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9267 + else
9268 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9269 + regs->pc = addr;
9270 + regs->npc = addr+4;
9271 + return 2;
9272 + }
9273 + } while (0);
9274 +
9275 + do { /* PaX: unpatched PLT emulation step 1 */
9276 + unsigned int sethi, ba, nop;
9277 +
9278 + err = get_user(sethi, (unsigned int *)regs->pc);
9279 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9280 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9281 +
9282 + if (err)
9283 + break;
9284 +
9285 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9286 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9287 + nop == 0x01000000U)
9288 + {
9289 + unsigned int addr, save, call;
9290 +
9291 + if ((ba & 0xFFC00000U) == 0x30800000U)
9292 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9293 + else
9294 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9295 +
9296 + err = get_user(save, (unsigned int *)addr);
9297 + err |= get_user(call, (unsigned int *)(addr+4));
9298 + err |= get_user(nop, (unsigned int *)(addr+8));
9299 + if (err)
9300 + break;
9301 +
9302 +#ifdef CONFIG_PAX_DLRESOLVE
9303 + if (save == 0x9DE3BFA8U &&
9304 + (call & 0xC0000000U) == 0x40000000U &&
9305 + nop == 0x01000000U)
9306 + {
9307 + struct vm_area_struct *vma;
9308 + unsigned long call_dl_resolve;
9309 +
9310 + down_read(&current->mm->mmap_sem);
9311 + call_dl_resolve = current->mm->call_dl_resolve;
9312 + up_read(&current->mm->mmap_sem);
9313 + if (likely(call_dl_resolve))
9314 + goto emulate;
9315 +
9316 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9317 +
9318 + down_write(&current->mm->mmap_sem);
9319 + if (current->mm->call_dl_resolve) {
9320 + call_dl_resolve = current->mm->call_dl_resolve;
9321 + up_write(&current->mm->mmap_sem);
9322 + if (vma)
9323 + kmem_cache_free(vm_area_cachep, vma);
9324 + goto emulate;
9325 + }
9326 +
9327 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9328 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9329 + up_write(&current->mm->mmap_sem);
9330 + if (vma)
9331 + kmem_cache_free(vm_area_cachep, vma);
9332 + return 1;
9333 + }
9334 +
9335 + if (pax_insert_vma(vma, call_dl_resolve)) {
9336 + up_write(&current->mm->mmap_sem);
9337 + kmem_cache_free(vm_area_cachep, vma);
9338 + return 1;
9339 + }
9340 +
9341 + current->mm->call_dl_resolve = call_dl_resolve;
9342 + up_write(&current->mm->mmap_sem);
9343 +
9344 +emulate:
9345 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9346 + regs->pc = call_dl_resolve;
9347 + regs->npc = addr+4;
9348 + return 3;
9349 + }
9350 +#endif
9351 +
9352 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9353 + if ((save & 0xFFC00000U) == 0x05000000U &&
9354 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9355 + nop == 0x01000000U)
9356 + {
9357 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9358 + regs->u_regs[UREG_G2] = addr + 4;
9359 + addr = (save & 0x003FFFFFU) << 10;
9360 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9361 + regs->pc = addr;
9362 + regs->npc = addr+4;
9363 + return 3;
9364 + }
9365 + }
9366 + } while (0);
9367 +
9368 + do { /* PaX: unpatched PLT emulation step 2 */
9369 + unsigned int save, call, nop;
9370 +
9371 + err = get_user(save, (unsigned int *)(regs->pc-4));
9372 + err |= get_user(call, (unsigned int *)regs->pc);
9373 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9374 + if (err)
9375 + break;
9376 +
9377 + if (save == 0x9DE3BFA8U &&
9378 + (call & 0xC0000000U) == 0x40000000U &&
9379 + nop == 0x01000000U)
9380 + {
9381 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9382 +
9383 + regs->u_regs[UREG_RETPC] = regs->pc;
9384 + regs->pc = dl_resolve;
9385 + regs->npc = dl_resolve+4;
9386 + return 3;
9387 + }
9388 + } while (0);
9389 +#endif
9390 +
9391 + return 1;
9392 +}
9393 +
9394 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9395 +{
9396 + unsigned long i;
9397 +
9398 + printk(KERN_ERR "PAX: bytes at PC: ");
9399 + for (i = 0; i < 8; i++) {
9400 + unsigned int c;
9401 + if (get_user(c, (unsigned int *)pc+i))
9402 + printk(KERN_CONT "???????? ");
9403 + else
9404 + printk(KERN_CONT "%08x ", c);
9405 + }
9406 + printk("\n");
9407 +}
9408 +#endif
9409 +
9410 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9411 int text_fault)
9412 {
9413 @@ -230,6 +504,24 @@ good_area:
9414 if (!(vma->vm_flags & VM_WRITE))
9415 goto bad_area;
9416 } else {
9417 +
9418 +#ifdef CONFIG_PAX_PAGEEXEC
9419 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9420 + up_read(&mm->mmap_sem);
9421 + switch (pax_handle_fetch_fault(regs)) {
9422 +
9423 +#ifdef CONFIG_PAX_EMUPLT
9424 + case 2:
9425 + case 3:
9426 + return;
9427 +#endif
9428 +
9429 + }
9430 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9431 + do_group_exit(SIGKILL);
9432 + }
9433 +#endif
9434 +
9435 /* Allow reads even for write-only mappings */
9436 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9437 goto bad_area;
9438 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9439 index 5062ff3..e0b75f3 100644
9440 --- a/arch/sparc/mm/fault_64.c
9441 +++ b/arch/sparc/mm/fault_64.c
9442 @@ -21,6 +21,9 @@
9443 #include <linux/kprobes.h>
9444 #include <linux/kdebug.h>
9445 #include <linux/percpu.h>
9446 +#include <linux/slab.h>
9447 +#include <linux/pagemap.h>
9448 +#include <linux/compiler.h>
9449
9450 #include <asm/page.h>
9451 #include <asm/pgtable.h>
9452 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9453 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9454 regs->tpc);
9455 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9456 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9457 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9458 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9459 dump_stack();
9460 unhandled_fault(regs->tpc, current, regs);
9461 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9462 show_regs(regs);
9463 }
9464
9465 +#ifdef CONFIG_PAX_PAGEEXEC
9466 +#ifdef CONFIG_PAX_DLRESOLVE
9467 +static void pax_emuplt_close(struct vm_area_struct *vma)
9468 +{
9469 + vma->vm_mm->call_dl_resolve = 0UL;
9470 +}
9471 +
9472 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9473 +{
9474 + unsigned int *kaddr;
9475 +
9476 + vmf->page = alloc_page(GFP_HIGHUSER);
9477 + if (!vmf->page)
9478 + return VM_FAULT_OOM;
9479 +
9480 + kaddr = kmap(vmf->page);
9481 + memset(kaddr, 0, PAGE_SIZE);
9482 + kaddr[0] = 0x9DE3BFA8U; /* save */
9483 + flush_dcache_page(vmf->page);
9484 + kunmap(vmf->page);
9485 + return VM_FAULT_MAJOR;
9486 +}
9487 +
9488 +static const struct vm_operations_struct pax_vm_ops = {
9489 + .close = pax_emuplt_close,
9490 + .fault = pax_emuplt_fault
9491 +};
9492 +
9493 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9494 +{
9495 + int ret;
9496 +
9497 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9498 + vma->vm_mm = current->mm;
9499 + vma->vm_start = addr;
9500 + vma->vm_end = addr + PAGE_SIZE;
9501 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9502 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9503 + vma->vm_ops = &pax_vm_ops;
9504 +
9505 + ret = insert_vm_struct(current->mm, vma);
9506 + if (ret)
9507 + return ret;
9508 +
9509 + ++current->mm->total_vm;
9510 + return 0;
9511 +}
9512 +#endif
9513 +
9514 +/*
9515 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9516 + *
9517 + * returns 1 when task should be killed
9518 + * 2 when patched PLT trampoline was detected
9519 + * 3 when unpatched PLT trampoline was detected
9520 + */
9521 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9522 +{
9523 +
9524 +#ifdef CONFIG_PAX_EMUPLT
9525 + int err;
9526 +
9527 + do { /* PaX: patched PLT emulation #1 */
9528 + unsigned int sethi1, sethi2, jmpl;
9529 +
9530 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9531 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9532 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9533 +
9534 + if (err)
9535 + break;
9536 +
9537 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9538 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9539 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9540 + {
9541 + unsigned long addr;
9542 +
9543 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9544 + addr = regs->u_regs[UREG_G1];
9545 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9546 +
9547 + if (test_thread_flag(TIF_32BIT))
9548 + addr &= 0xFFFFFFFFUL;
9549 +
9550 + regs->tpc = addr;
9551 + regs->tnpc = addr+4;
9552 + return 2;
9553 + }
9554 + } while (0);
9555 +
9556 + do { /* PaX: patched PLT emulation #2 */
9557 + unsigned int ba;
9558 +
9559 + err = get_user(ba, (unsigned int *)regs->tpc);
9560 +
9561 + if (err)
9562 + break;
9563 +
9564 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9565 + unsigned long addr;
9566 +
9567 + if ((ba & 0xFFC00000U) == 0x30800000U)
9568 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9569 + else
9570 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9571 +
9572 + if (test_thread_flag(TIF_32BIT))
9573 + addr &= 0xFFFFFFFFUL;
9574 +
9575 + regs->tpc = addr;
9576 + regs->tnpc = addr+4;
9577 + return 2;
9578 + }
9579 + } while (0);
9580 +
9581 + do { /* PaX: patched PLT emulation #3 */
9582 + unsigned int sethi, bajmpl, nop;
9583 +
9584 + err = get_user(sethi, (unsigned int *)regs->tpc);
9585 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9586 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9587 +
9588 + if (err)
9589 + break;
9590 +
9591 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9592 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9593 + nop == 0x01000000U)
9594 + {
9595 + unsigned long addr;
9596 +
9597 + addr = (sethi & 0x003FFFFFU) << 10;
9598 + regs->u_regs[UREG_G1] = addr;
9599 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9600 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9601 + else
9602 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9603 +
9604 + if (test_thread_flag(TIF_32BIT))
9605 + addr &= 0xFFFFFFFFUL;
9606 +
9607 + regs->tpc = addr;
9608 + regs->tnpc = addr+4;
9609 + return 2;
9610 + }
9611 + } while (0);
9612 +
9613 + do { /* PaX: patched PLT emulation #4 */
9614 + unsigned int sethi, mov1, call, mov2;
9615 +
9616 + err = get_user(sethi, (unsigned int *)regs->tpc);
9617 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9618 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9619 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9620 +
9621 + if (err)
9622 + break;
9623 +
9624 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9625 + mov1 == 0x8210000FU &&
9626 + (call & 0xC0000000U) == 0x40000000U &&
9627 + mov2 == 0x9E100001U)
9628 + {
9629 + unsigned long addr;
9630 +
9631 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9632 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9633 +
9634 + if (test_thread_flag(TIF_32BIT))
9635 + addr &= 0xFFFFFFFFUL;
9636 +
9637 + regs->tpc = addr;
9638 + regs->tnpc = addr+4;
9639 + return 2;
9640 + }
9641 + } while (0);
9642 +
9643 + do { /* PaX: patched PLT emulation #5 */
9644 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9645 +
9646 + err = get_user(sethi, (unsigned int *)regs->tpc);
9647 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9648 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9649 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9650 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9651 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9652 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9653 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9654 +
9655 + if (err)
9656 + break;
9657 +
9658 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9659 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9660 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9661 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9662 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9663 + sllx == 0x83287020U &&
9664 + jmpl == 0x81C04005U &&
9665 + nop == 0x01000000U)
9666 + {
9667 + unsigned long addr;
9668 +
9669 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9670 + regs->u_regs[UREG_G1] <<= 32;
9671 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9672 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9673 + regs->tpc = addr;
9674 + regs->tnpc = addr+4;
9675 + return 2;
9676 + }
9677 + } while (0);
9678 +
9679 + do { /* PaX: patched PLT emulation #6 */
9680 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9681 +
9682 + err = get_user(sethi, (unsigned int *)regs->tpc);
9683 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9684 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9685 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9686 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9687 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9688 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9689 +
9690 + if (err)
9691 + break;
9692 +
9693 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9694 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9695 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9696 + sllx == 0x83287020U &&
9697 + (or & 0xFFFFE000U) == 0x8A116000U &&
9698 + jmpl == 0x81C04005U &&
9699 + nop == 0x01000000U)
9700 + {
9701 + unsigned long addr;
9702 +
9703 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9704 + regs->u_regs[UREG_G1] <<= 32;
9705 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
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: unpatched PLT emulation step 1 */
9714 + unsigned int sethi, ba, nop;
9715 +
9716 + err = get_user(sethi, (unsigned int *)regs->tpc);
9717 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9718 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9719 +
9720 + if (err)
9721 + break;
9722 +
9723 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9724 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9725 + nop == 0x01000000U)
9726 + {
9727 + unsigned long addr;
9728 + unsigned int save, call;
9729 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9730 +
9731 + if ((ba & 0xFFC00000U) == 0x30800000U)
9732 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9733 + else
9734 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9735 +
9736 + if (test_thread_flag(TIF_32BIT))
9737 + addr &= 0xFFFFFFFFUL;
9738 +
9739 + err = get_user(save, (unsigned int *)addr);
9740 + err |= get_user(call, (unsigned int *)(addr+4));
9741 + err |= get_user(nop, (unsigned int *)(addr+8));
9742 + if (err)
9743 + break;
9744 +
9745 +#ifdef CONFIG_PAX_DLRESOLVE
9746 + if (save == 0x9DE3BFA8U &&
9747 + (call & 0xC0000000U) == 0x40000000U &&
9748 + nop == 0x01000000U)
9749 + {
9750 + struct vm_area_struct *vma;
9751 + unsigned long call_dl_resolve;
9752 +
9753 + down_read(&current->mm->mmap_sem);
9754 + call_dl_resolve = current->mm->call_dl_resolve;
9755 + up_read(&current->mm->mmap_sem);
9756 + if (likely(call_dl_resolve))
9757 + goto emulate;
9758 +
9759 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9760 +
9761 + down_write(&current->mm->mmap_sem);
9762 + if (current->mm->call_dl_resolve) {
9763 + call_dl_resolve = current->mm->call_dl_resolve;
9764 + up_write(&current->mm->mmap_sem);
9765 + if (vma)
9766 + kmem_cache_free(vm_area_cachep, vma);
9767 + goto emulate;
9768 + }
9769 +
9770 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9771 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9772 + up_write(&current->mm->mmap_sem);
9773 + if (vma)
9774 + kmem_cache_free(vm_area_cachep, vma);
9775 + return 1;
9776 + }
9777 +
9778 + if (pax_insert_vma(vma, call_dl_resolve)) {
9779 + up_write(&current->mm->mmap_sem);
9780 + kmem_cache_free(vm_area_cachep, vma);
9781 + return 1;
9782 + }
9783 +
9784 + current->mm->call_dl_resolve = call_dl_resolve;
9785 + up_write(&current->mm->mmap_sem);
9786 +
9787 +emulate:
9788 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9789 + regs->tpc = call_dl_resolve;
9790 + regs->tnpc = addr+4;
9791 + return 3;
9792 + }
9793 +#endif
9794 +
9795 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9796 + if ((save & 0xFFC00000U) == 0x05000000U &&
9797 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9798 + nop == 0x01000000U)
9799 + {
9800 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9801 + regs->u_regs[UREG_G2] = addr + 4;
9802 + addr = (save & 0x003FFFFFU) << 10;
9803 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9804 +
9805 + if (test_thread_flag(TIF_32BIT))
9806 + addr &= 0xFFFFFFFFUL;
9807 +
9808 + regs->tpc = addr;
9809 + regs->tnpc = addr+4;
9810 + return 3;
9811 + }
9812 +
9813 + /* PaX: 64-bit PLT stub */
9814 + err = get_user(sethi1, (unsigned int *)addr);
9815 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9816 + err |= get_user(or1, (unsigned int *)(addr+8));
9817 + err |= get_user(or2, (unsigned int *)(addr+12));
9818 + err |= get_user(sllx, (unsigned int *)(addr+16));
9819 + err |= get_user(add, (unsigned int *)(addr+20));
9820 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9821 + err |= get_user(nop, (unsigned int *)(addr+28));
9822 + if (err)
9823 + break;
9824 +
9825 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9826 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9827 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9828 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9829 + sllx == 0x89293020U &&
9830 + add == 0x8A010005U &&
9831 + jmpl == 0x89C14000U &&
9832 + nop == 0x01000000U)
9833 + {
9834 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9835 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9836 + regs->u_regs[UREG_G4] <<= 32;
9837 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9838 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9839 + regs->u_regs[UREG_G4] = addr + 24;
9840 + addr = regs->u_regs[UREG_G5];
9841 + regs->tpc = addr;
9842 + regs->tnpc = addr+4;
9843 + return 3;
9844 + }
9845 + }
9846 + } while (0);
9847 +
9848 +#ifdef CONFIG_PAX_DLRESOLVE
9849 + do { /* PaX: unpatched PLT emulation step 2 */
9850 + unsigned int save, call, nop;
9851 +
9852 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9853 + err |= get_user(call, (unsigned int *)regs->tpc);
9854 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9855 + if (err)
9856 + break;
9857 +
9858 + if (save == 0x9DE3BFA8U &&
9859 + (call & 0xC0000000U) == 0x40000000U &&
9860 + nop == 0x01000000U)
9861 + {
9862 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9863 +
9864 + if (test_thread_flag(TIF_32BIT))
9865 + dl_resolve &= 0xFFFFFFFFUL;
9866 +
9867 + regs->u_regs[UREG_RETPC] = regs->tpc;
9868 + regs->tpc = dl_resolve;
9869 + regs->tnpc = dl_resolve+4;
9870 + return 3;
9871 + }
9872 + } while (0);
9873 +#endif
9874 +
9875 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9876 + unsigned int sethi, ba, nop;
9877 +
9878 + err = get_user(sethi, (unsigned int *)regs->tpc);
9879 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9880 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9881 +
9882 + if (err)
9883 + break;
9884 +
9885 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9886 + (ba & 0xFFF00000U) == 0x30600000U &&
9887 + nop == 0x01000000U)
9888 + {
9889 + unsigned long addr;
9890 +
9891 + addr = (sethi & 0x003FFFFFU) << 10;
9892 + regs->u_regs[UREG_G1] = addr;
9893 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9894 +
9895 + if (test_thread_flag(TIF_32BIT))
9896 + addr &= 0xFFFFFFFFUL;
9897 +
9898 + regs->tpc = addr;
9899 + regs->tnpc = addr+4;
9900 + return 2;
9901 + }
9902 + } while (0);
9903 +
9904 +#endif
9905 +
9906 + return 1;
9907 +}
9908 +
9909 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9910 +{
9911 + unsigned long i;
9912 +
9913 + printk(KERN_ERR "PAX: bytes at PC: ");
9914 + for (i = 0; i < 8; i++) {
9915 + unsigned int c;
9916 + if (get_user(c, (unsigned int *)pc+i))
9917 + printk(KERN_CONT "???????? ");
9918 + else
9919 + printk(KERN_CONT "%08x ", c);
9920 + }
9921 + printk("\n");
9922 +}
9923 +#endif
9924 +
9925 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9926 {
9927 struct mm_struct *mm = current->mm;
9928 @@ -341,6 +804,29 @@ retry:
9929 if (!vma)
9930 goto bad_area;
9931
9932 +#ifdef CONFIG_PAX_PAGEEXEC
9933 + /* PaX: detect ITLB misses on non-exec pages */
9934 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9935 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9936 + {
9937 + if (address != regs->tpc)
9938 + goto good_area;
9939 +
9940 + up_read(&mm->mmap_sem);
9941 + switch (pax_handle_fetch_fault(regs)) {
9942 +
9943 +#ifdef CONFIG_PAX_EMUPLT
9944 + case 2:
9945 + case 3:
9946 + return;
9947 +#endif
9948 +
9949 + }
9950 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9951 + do_group_exit(SIGKILL);
9952 + }
9953 +#endif
9954 +
9955 /* Pure DTLB misses do not tell us whether the fault causing
9956 * load/store/atomic was a write or not, it only says that there
9957 * was no match. So in such a case we (carefully) read the
9958 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9959 index d2b5944..bd813f2 100644
9960 --- a/arch/sparc/mm/hugetlbpage.c
9961 +++ b/arch/sparc/mm/hugetlbpage.c
9962 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9963
9964 info.flags = 0;
9965 info.length = len;
9966 - info.low_limit = TASK_UNMAPPED_BASE;
9967 + info.low_limit = mm->mmap_base;
9968 info.high_limit = min(task_size, VA_EXCLUDE_START);
9969 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9970 info.align_offset = 0;
9971 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9972 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9973 VM_BUG_ON(addr != -ENOMEM);
9974 info.low_limit = VA_EXCLUDE_END;
9975 +
9976 +#ifdef CONFIG_PAX_RANDMMAP
9977 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9978 + info.low_limit += mm->delta_mmap;
9979 +#endif
9980 +
9981 info.high_limit = task_size;
9982 addr = vm_unmapped_area(&info);
9983 }
9984 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9985 VM_BUG_ON(addr != -ENOMEM);
9986 info.flags = 0;
9987 info.low_limit = TASK_UNMAPPED_BASE;
9988 +
9989 +#ifdef CONFIG_PAX_RANDMMAP
9990 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9991 + info.low_limit += mm->delta_mmap;
9992 +#endif
9993 +
9994 info.high_limit = STACK_TOP32;
9995 addr = vm_unmapped_area(&info);
9996 }
9997 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9998 struct mm_struct *mm = current->mm;
9999 struct vm_area_struct *vma;
10000 unsigned long task_size = TASK_SIZE;
10001 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10002
10003 if (test_thread_flag(TIF_32BIT))
10004 task_size = STACK_TOP32;
10005 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10006 return addr;
10007 }
10008
10009 +#ifdef CONFIG_PAX_RANDMMAP
10010 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10011 +#endif
10012 +
10013 if (addr) {
10014 addr = ALIGN(addr, HPAGE_SIZE);
10015 vma = find_vma(mm, addr);
10016 - if (task_size - len >= addr &&
10017 - (!vma || addr + len <= vma->vm_start))
10018 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10019 return addr;
10020 }
10021 if (mm->get_unmapped_area == arch_get_unmapped_area)
10022 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10023 index f4500c6..889656c 100644
10024 --- a/arch/tile/include/asm/atomic_64.h
10025 +++ b/arch/tile/include/asm/atomic_64.h
10026 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10027
10028 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10029
10030 +#define atomic64_read_unchecked(v) atomic64_read(v)
10031 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10032 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10033 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10034 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10035 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10036 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10037 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10038 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10039 +
10040 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10041 #define smp_mb__before_atomic_dec() smp_mb()
10042 #define smp_mb__after_atomic_dec() smp_mb()
10043 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10044 index a9a5299..0fce79e 100644
10045 --- a/arch/tile/include/asm/cache.h
10046 +++ b/arch/tile/include/asm/cache.h
10047 @@ -15,11 +15,12 @@
10048 #ifndef _ASM_TILE_CACHE_H
10049 #define _ASM_TILE_CACHE_H
10050
10051 +#include <linux/const.h>
10052 #include <arch/chip.h>
10053
10054 /* bytes per L1 data cache line */
10055 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10056 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10057 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10058
10059 /* bytes per L2 cache line */
10060 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10061 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10062 index 8a082bc..7a6bf87 100644
10063 --- a/arch/tile/include/asm/uaccess.h
10064 +++ b/arch/tile/include/asm/uaccess.h
10065 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10066 const void __user *from,
10067 unsigned long n)
10068 {
10069 - int sz = __compiletime_object_size(to);
10070 + size_t sz = __compiletime_object_size(to);
10071
10072 - if (likely(sz == -1 || sz >= n))
10073 + if (likely(sz == (size_t)-1 || sz >= n))
10074 n = _copy_from_user(to, from, n);
10075 else
10076 copy_from_user_overflow();
10077 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10078 index 650ccff..45fe2d6 100644
10079 --- a/arch/tile/mm/hugetlbpage.c
10080 +++ b/arch/tile/mm/hugetlbpage.c
10081 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10082 info.high_limit = TASK_SIZE;
10083 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10084 info.align_offset = 0;
10085 + info.threadstack_offset = 0;
10086 return vm_unmapped_area(&info);
10087 }
10088
10089 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10090 info.high_limit = current->mm->mmap_base;
10091 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10092 info.align_offset = 0;
10093 + info.threadstack_offset = 0;
10094 addr = vm_unmapped_area(&info);
10095
10096 /*
10097 diff --git a/arch/um/Makefile b/arch/um/Makefile
10098 index 133f7de..1d6f2f1 100644
10099 --- a/arch/um/Makefile
10100 +++ b/arch/um/Makefile
10101 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10102 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10103 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10104
10105 +ifdef CONSTIFY_PLUGIN
10106 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10107 +endif
10108 +
10109 #This will adjust *FLAGS accordingly to the platform.
10110 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10111
10112 diff --git a/arch/um/defconfig b/arch/um/defconfig
10113 index 08107a7..ab22afe 100644
10114 --- a/arch/um/defconfig
10115 +++ b/arch/um/defconfig
10116 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10117 CONFIG_X86_L1_CACHE_SHIFT=5
10118 CONFIG_X86_XADD=y
10119 CONFIG_X86_PPRO_FENCE=y
10120 -CONFIG_X86_WP_WORKS_OK=y
10121 CONFIG_X86_INVLPG=y
10122 CONFIG_X86_BSWAP=y
10123 CONFIG_X86_POPAD_OK=y
10124 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10125 index 19e1bdd..3665b77 100644
10126 --- a/arch/um/include/asm/cache.h
10127 +++ b/arch/um/include/asm/cache.h
10128 @@ -1,6 +1,7 @@
10129 #ifndef __UM_CACHE_H
10130 #define __UM_CACHE_H
10131
10132 +#include <linux/const.h>
10133
10134 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10135 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10136 @@ -12,6 +13,6 @@
10137 # define L1_CACHE_SHIFT 5
10138 #endif
10139
10140 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10141 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10142
10143 #endif
10144 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10145 index 2e0a6b1..a64d0f5 100644
10146 --- a/arch/um/include/asm/kmap_types.h
10147 +++ b/arch/um/include/asm/kmap_types.h
10148 @@ -8,6 +8,6 @@
10149
10150 /* No more #include "asm/arch/kmap_types.h" ! */
10151
10152 -#define KM_TYPE_NR 14
10153 +#define KM_TYPE_NR 15
10154
10155 #endif
10156 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10157 index 5ff53d9..5850cdf 100644
10158 --- a/arch/um/include/asm/page.h
10159 +++ b/arch/um/include/asm/page.h
10160 @@ -14,6 +14,9 @@
10161 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10162 #define PAGE_MASK (~(PAGE_SIZE-1))
10163
10164 +#define ktla_ktva(addr) (addr)
10165 +#define ktva_ktla(addr) (addr)
10166 +
10167 #ifndef __ASSEMBLY__
10168
10169 struct page;
10170 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10171 index 0032f92..cd151e0 100644
10172 --- a/arch/um/include/asm/pgtable-3level.h
10173 +++ b/arch/um/include/asm/pgtable-3level.h
10174 @@ -58,6 +58,7 @@
10175 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10176 #define pud_populate(mm, pud, pmd) \
10177 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10178 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10179
10180 #ifdef CONFIG_64BIT
10181 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10182 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10183 index bbcef52..6a2a483 100644
10184 --- a/arch/um/kernel/process.c
10185 +++ b/arch/um/kernel/process.c
10186 @@ -367,22 +367,6 @@ int singlestepping(void * t)
10187 return 2;
10188 }
10189
10190 -/*
10191 - * Only x86 and x86_64 have an arch_align_stack().
10192 - * All other arches have "#define arch_align_stack(x) (x)"
10193 - * in their asm/system.h
10194 - * As this is included in UML from asm-um/system-generic.h,
10195 - * we can use it to behave as the subarch does.
10196 - */
10197 -#ifndef arch_align_stack
10198 -unsigned long arch_align_stack(unsigned long sp)
10199 -{
10200 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10201 - sp -= get_random_int() % 8192;
10202 - return sp & ~0xf;
10203 -}
10204 -#endif
10205 -
10206 unsigned long get_wchan(struct task_struct *p)
10207 {
10208 unsigned long stack_page, sp, ip;
10209 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10210 index ad8f795..2c7eec6 100644
10211 --- a/arch/unicore32/include/asm/cache.h
10212 +++ b/arch/unicore32/include/asm/cache.h
10213 @@ -12,8 +12,10 @@
10214 #ifndef __UNICORE_CACHE_H__
10215 #define __UNICORE_CACHE_H__
10216
10217 -#define L1_CACHE_SHIFT (5)
10218 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10219 +#include <linux/const.h>
10220 +
10221 +#define L1_CACHE_SHIFT 5
10222 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10223
10224 /*
10225 * Memory returned by kmalloc() may be used for DMA, so we must make
10226 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10227 index fe120da..24177f7 100644
10228 --- a/arch/x86/Kconfig
10229 +++ b/arch/x86/Kconfig
10230 @@ -239,7 +239,7 @@ config X86_HT
10231
10232 config X86_32_LAZY_GS
10233 def_bool y
10234 - depends on X86_32 && !CC_STACKPROTECTOR
10235 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10236
10237 config ARCH_HWEIGHT_CFLAGS
10238 string
10239 @@ -1073,6 +1073,7 @@ config MICROCODE_EARLY
10240
10241 config X86_MSR
10242 tristate "/dev/cpu/*/msr - Model-specific register support"
10243 + depends on !GRKERNSEC_KMEM
10244 ---help---
10245 This device gives privileged processes access to the x86
10246 Model-Specific Registers (MSRs). It is a character device with
10247 @@ -1096,7 +1097,7 @@ choice
10248
10249 config NOHIGHMEM
10250 bool "off"
10251 - depends on !X86_NUMAQ
10252 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10253 ---help---
10254 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10255 However, the address space of 32-bit x86 processors is only 4
10256 @@ -1133,7 +1134,7 @@ config NOHIGHMEM
10257
10258 config HIGHMEM4G
10259 bool "4GB"
10260 - depends on !X86_NUMAQ
10261 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10262 ---help---
10263 Select this if you have a 32-bit processor and between 1 and 4
10264 gigabytes of physical RAM.
10265 @@ -1186,7 +1187,7 @@ config PAGE_OFFSET
10266 hex
10267 default 0xB0000000 if VMSPLIT_3G_OPT
10268 default 0x80000000 if VMSPLIT_2G
10269 - default 0x78000000 if VMSPLIT_2G_OPT
10270 + default 0x70000000 if VMSPLIT_2G_OPT
10271 default 0x40000000 if VMSPLIT_1G
10272 default 0xC0000000
10273 depends on X86_32
10274 @@ -1584,6 +1585,7 @@ config SECCOMP
10275
10276 config CC_STACKPROTECTOR
10277 bool "Enable -fstack-protector buffer overflow detection"
10278 + depends on X86_64 || !PAX_MEMORY_UDEREF
10279 ---help---
10280 This option turns on the -fstack-protector GCC feature. This
10281 feature puts, at the beginning of functions, a canary value on
10282 @@ -1703,6 +1705,8 @@ config X86_NEED_RELOCS
10283 config PHYSICAL_ALIGN
10284 hex "Alignment value to which kernel should be aligned" if X86_32
10285 default "0x1000000"
10286 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10287 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10288 range 0x2000 0x1000000
10289 ---help---
10290 This value puts the alignment restrictions on physical address
10291 @@ -1778,9 +1782,10 @@ config DEBUG_HOTPLUG_CPU0
10292 If unsure, say N.
10293
10294 config COMPAT_VDSO
10295 - def_bool y
10296 + def_bool n
10297 prompt "Compat VDSO support"
10298 depends on X86_32 || IA32_EMULATION
10299 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10300 ---help---
10301 Map the 32-bit VDSO to the predictable old-style address too.
10302
10303 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10304 index c026cca..14657ae 100644
10305 --- a/arch/x86/Kconfig.cpu
10306 +++ b/arch/x86/Kconfig.cpu
10307 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10308
10309 config X86_F00F_BUG
10310 def_bool y
10311 - depends on M586MMX || M586TSC || M586 || M486
10312 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10313
10314 config X86_INVD_BUG
10315 def_bool y
10316 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10317
10318 config X86_ALIGNMENT_16
10319 def_bool y
10320 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10321 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10322
10323 config X86_INTEL_USERCOPY
10324 def_bool y
10325 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10326 # generates cmov.
10327 config X86_CMOV
10328 def_bool y
10329 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10330 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10331
10332 config X86_MINIMUM_CPU_FAMILY
10333 int
10334 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10335 index c198b7e..63eea60 100644
10336 --- a/arch/x86/Kconfig.debug
10337 +++ b/arch/x86/Kconfig.debug
10338 @@ -84,7 +84,7 @@ config X86_PTDUMP
10339 config DEBUG_RODATA
10340 bool "Write protect kernel read-only data structures"
10341 default y
10342 - depends on DEBUG_KERNEL
10343 + depends on DEBUG_KERNEL && BROKEN
10344 ---help---
10345 Mark the kernel read-only data as write-protected in the pagetables,
10346 in order to catch accidental (and incorrect) writes to such const
10347 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10348
10349 config DEBUG_SET_MODULE_RONX
10350 bool "Set loadable kernel module data as NX and text as RO"
10351 - depends on MODULES
10352 + depends on MODULES && BROKEN
10353 ---help---
10354 This option helps catch unintended modifications to loadable
10355 kernel module's text and read-only data. It also prevents execution
10356 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10357 index 5c47726..8c4fa67 100644
10358 --- a/arch/x86/Makefile
10359 +++ b/arch/x86/Makefile
10360 @@ -54,6 +54,7 @@ else
10361 UTS_MACHINE := x86_64
10362 CHECKFLAGS += -D__x86_64__ -m64
10363
10364 + biarch := $(call cc-option,-m64)
10365 KBUILD_AFLAGS += -m64
10366 KBUILD_CFLAGS += -m64
10367
10368 @@ -234,3 +235,12 @@ define archhelp
10369 echo ' FDARGS="..." arguments for the booted kernel'
10370 echo ' FDINITRD=file initrd for the booted kernel'
10371 endef
10372 +
10373 +define OLD_LD
10374 +
10375 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10376 +*** Please upgrade your binutils to 2.18 or newer
10377 +endef
10378 +
10379 +archprepare:
10380 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10381 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10382 index 379814b..add62ce 100644
10383 --- a/arch/x86/boot/Makefile
10384 +++ b/arch/x86/boot/Makefile
10385 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10386 $(call cc-option, -fno-stack-protector) \
10387 $(call cc-option, -mpreferred-stack-boundary=2)
10388 KBUILD_CFLAGS += $(call cc-option, -m32)
10389 +ifdef CONSTIFY_PLUGIN
10390 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10391 +endif
10392 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10393 GCOV_PROFILE := n
10394
10395 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10396 index 878e4b9..20537ab 100644
10397 --- a/arch/x86/boot/bitops.h
10398 +++ b/arch/x86/boot/bitops.h
10399 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10400 u8 v;
10401 const u32 *p = (const u32 *)addr;
10402
10403 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10404 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10405 return v;
10406 }
10407
10408 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10409
10410 static inline void set_bit(int nr, void *addr)
10411 {
10412 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10413 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10414 }
10415
10416 #endif /* BOOT_BITOPS_H */
10417 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10418 index 5b75319..331a4ca 100644
10419 --- a/arch/x86/boot/boot.h
10420 +++ b/arch/x86/boot/boot.h
10421 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10422 static inline u16 ds(void)
10423 {
10424 u16 seg;
10425 - asm("movw %%ds,%0" : "=rm" (seg));
10426 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10427 return seg;
10428 }
10429
10430 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10431 static inline int memcmp(const void *s1, const void *s2, size_t len)
10432 {
10433 u8 diff;
10434 - asm("repe; cmpsb; setnz %0"
10435 + asm volatile("repe; cmpsb; setnz %0"
10436 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10437 return diff;
10438 }
10439 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10440 index 5ef205c..342191d 100644
10441 --- a/arch/x86/boot/compressed/Makefile
10442 +++ b/arch/x86/boot/compressed/Makefile
10443 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10444 KBUILD_CFLAGS += $(cflags-y)
10445 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10446 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10447 +ifdef CONSTIFY_PLUGIN
10448 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10449 +endif
10450
10451 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10452 GCOV_PROFILE := n
10453 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10454 index d606463..b887794 100644
10455 --- a/arch/x86/boot/compressed/eboot.c
10456 +++ b/arch/x86/boot/compressed/eboot.c
10457 @@ -150,7 +150,6 @@ again:
10458 *addr = max_addr;
10459 }
10460
10461 -free_pool:
10462 efi_call_phys1(sys_table->boottime->free_pool, map);
10463
10464 fail:
10465 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10466 if (i == map_size / desc_size)
10467 status = EFI_NOT_FOUND;
10468
10469 -free_pool:
10470 efi_call_phys1(sys_table->boottime->free_pool, map);
10471 fail:
10472 return status;
10473 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10474 index a53440e..c3dbf1e 100644
10475 --- a/arch/x86/boot/compressed/efi_stub_32.S
10476 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10477 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10478 * parameter 2, ..., param n. To make things easy, we save the return
10479 * address of efi_call_phys in a global variable.
10480 */
10481 - popl %ecx
10482 - movl %ecx, saved_return_addr(%edx)
10483 - /* get the function pointer into ECX*/
10484 - popl %ecx
10485 - movl %ecx, efi_rt_function_ptr(%edx)
10486 + popl saved_return_addr(%edx)
10487 + popl efi_rt_function_ptr(%edx)
10488
10489 /*
10490 * 3. Call the physical function.
10491 */
10492 - call *%ecx
10493 + call *efi_rt_function_ptr(%edx)
10494
10495 /*
10496 * 4. Balance the stack. And because EAX contain the return value,
10497 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10498 1: popl %edx
10499 subl $1b, %edx
10500
10501 - movl efi_rt_function_ptr(%edx), %ecx
10502 - pushl %ecx
10503 + pushl efi_rt_function_ptr(%edx)
10504
10505 /*
10506 * 10. Push the saved return address onto the stack and return.
10507 */
10508 - movl saved_return_addr(%edx), %ecx
10509 - pushl %ecx
10510 - ret
10511 + jmpl *saved_return_addr(%edx)
10512 ENDPROC(efi_call_phys)
10513 .previous
10514
10515 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10516 index 1e3184f..0d11e2e 100644
10517 --- a/arch/x86/boot/compressed/head_32.S
10518 +++ b/arch/x86/boot/compressed/head_32.S
10519 @@ -118,7 +118,7 @@ preferred_addr:
10520 notl %eax
10521 andl %eax, %ebx
10522 #else
10523 - movl $LOAD_PHYSICAL_ADDR, %ebx
10524 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10525 #endif
10526
10527 /* Target address to relocate to for decompression */
10528 @@ -204,7 +204,7 @@ relocated:
10529 * and where it was actually loaded.
10530 */
10531 movl %ebp, %ebx
10532 - subl $LOAD_PHYSICAL_ADDR, %ebx
10533 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10534 jz 2f /* Nothing to be done if loaded at compiled addr. */
10535 /*
10536 * Process relocations.
10537 @@ -212,8 +212,7 @@ relocated:
10538
10539 1: subl $4, %edi
10540 movl (%edi), %ecx
10541 - testl %ecx, %ecx
10542 - jz 2f
10543 + jecxz 2f
10544 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10545 jmp 1b
10546 2:
10547 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10548 index 16f24e6..47491a3 100644
10549 --- a/arch/x86/boot/compressed/head_64.S
10550 +++ b/arch/x86/boot/compressed/head_64.S
10551 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10552 notl %eax
10553 andl %eax, %ebx
10554 #else
10555 - movl $LOAD_PHYSICAL_ADDR, %ebx
10556 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10557 #endif
10558
10559 /* Target address to relocate to for decompression */
10560 @@ -272,7 +272,7 @@ preferred_addr:
10561 notq %rax
10562 andq %rax, %rbp
10563 #else
10564 - movq $LOAD_PHYSICAL_ADDR, %rbp
10565 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10566 #endif
10567
10568 /* Target address to relocate to for decompression */
10569 @@ -363,8 +363,8 @@ gdt:
10570 .long gdt
10571 .word 0
10572 .quad 0x0000000000000000 /* NULL descriptor */
10573 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10574 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10575 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10576 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10577 .quad 0x0080890000000000 /* TS descriptor */
10578 .quad 0x0000000000000000 /* TS continued */
10579 gdt_end:
10580 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10581 index 7cb56c6..d382d84 100644
10582 --- a/arch/x86/boot/compressed/misc.c
10583 +++ b/arch/x86/boot/compressed/misc.c
10584 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10585 case PT_LOAD:
10586 #ifdef CONFIG_RELOCATABLE
10587 dest = output;
10588 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10589 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10590 #else
10591 dest = (void *)(phdr->p_paddr);
10592 #endif
10593 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10594 error("Destination address too large");
10595 #endif
10596 #ifndef CONFIG_RELOCATABLE
10597 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10598 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10599 error("Wrong destination address");
10600 #endif
10601
10602 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10603 index 4d3ff03..e4972ff 100644
10604 --- a/arch/x86/boot/cpucheck.c
10605 +++ b/arch/x86/boot/cpucheck.c
10606 @@ -74,7 +74,7 @@ static int has_fpu(void)
10607 u16 fcw = -1, fsw = -1;
10608 u32 cr0;
10609
10610 - asm("movl %%cr0,%0" : "=r" (cr0));
10611 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10612 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10613 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10614 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10615 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10616 {
10617 u32 f0, f1;
10618
10619 - asm("pushfl ; "
10620 + asm volatile("pushfl ; "
10621 "pushfl ; "
10622 "popl %0 ; "
10623 "movl %0,%1 ; "
10624 @@ -115,7 +115,7 @@ static void get_flags(void)
10625 set_bit(X86_FEATURE_FPU, cpu.flags);
10626
10627 if (has_eflag(X86_EFLAGS_ID)) {
10628 - asm("cpuid"
10629 + asm volatile("cpuid"
10630 : "=a" (max_intel_level),
10631 "=b" (cpu_vendor[0]),
10632 "=d" (cpu_vendor[1]),
10633 @@ -124,7 +124,7 @@ static void get_flags(void)
10634
10635 if (max_intel_level >= 0x00000001 &&
10636 max_intel_level <= 0x0000ffff) {
10637 - asm("cpuid"
10638 + asm volatile("cpuid"
10639 : "=a" (tfms),
10640 "=c" (cpu.flags[4]),
10641 "=d" (cpu.flags[0])
10642 @@ -136,7 +136,7 @@ static void get_flags(void)
10643 cpu.model += ((tfms >> 16) & 0xf) << 4;
10644 }
10645
10646 - asm("cpuid"
10647 + asm volatile("cpuid"
10648 : "=a" (max_amd_level)
10649 : "a" (0x80000000)
10650 : "ebx", "ecx", "edx");
10651 @@ -144,7 +144,7 @@ static void get_flags(void)
10652 if (max_amd_level >= 0x80000001 &&
10653 max_amd_level <= 0x8000ffff) {
10654 u32 eax = 0x80000001;
10655 - asm("cpuid"
10656 + asm volatile("cpuid"
10657 : "+a" (eax),
10658 "=c" (cpu.flags[6]),
10659 "=d" (cpu.flags[1])
10660 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10661 u32 ecx = MSR_K7_HWCR;
10662 u32 eax, edx;
10663
10664 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10665 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10666 eax &= ~(1 << 15);
10667 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10668 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10669
10670 get_flags(); /* Make sure it really did something */
10671 err = check_flags();
10672 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10673 u32 ecx = MSR_VIA_FCR;
10674 u32 eax, edx;
10675
10676 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10677 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10678 eax |= (1<<1)|(1<<7);
10679 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10680 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10681
10682 set_bit(X86_FEATURE_CX8, cpu.flags);
10683 err = check_flags();
10684 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10685 u32 eax, edx;
10686 u32 level = 1;
10687
10688 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10689 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10690 - asm("cpuid"
10691 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10692 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10693 + asm volatile("cpuid"
10694 : "+a" (level), "=d" (cpu.flags[0])
10695 : : "ecx", "ebx");
10696 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10697 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10698
10699 err = check_flags();
10700 }
10701 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10702 index 9ec06a1..2c25e79 100644
10703 --- a/arch/x86/boot/header.S
10704 +++ b/arch/x86/boot/header.S
10705 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10706 # single linked list of
10707 # struct setup_data
10708
10709 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10710 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10711
10712 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10713 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10714 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10715 +#else
10716 #define VO_INIT_SIZE (VO__end - VO__text)
10717 +#endif
10718 #if ZO_INIT_SIZE > VO_INIT_SIZE
10719 #define INIT_SIZE ZO_INIT_SIZE
10720 #else
10721 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10722 index db75d07..8e6d0af 100644
10723 --- a/arch/x86/boot/memory.c
10724 +++ b/arch/x86/boot/memory.c
10725 @@ -19,7 +19,7 @@
10726
10727 static int detect_memory_e820(void)
10728 {
10729 - int count = 0;
10730 + unsigned int count = 0;
10731 struct biosregs ireg, oreg;
10732 struct e820entry *desc = boot_params.e820_map;
10733 static struct e820entry buf; /* static so it is zeroed */
10734 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10735 index 11e8c6e..fdbb1ed 100644
10736 --- a/arch/x86/boot/video-vesa.c
10737 +++ b/arch/x86/boot/video-vesa.c
10738 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10739
10740 boot_params.screen_info.vesapm_seg = oreg.es;
10741 boot_params.screen_info.vesapm_off = oreg.di;
10742 + boot_params.screen_info.vesapm_size = oreg.cx;
10743 }
10744
10745 /*
10746 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10747 index 43eda28..5ab5fdb 100644
10748 --- a/arch/x86/boot/video.c
10749 +++ b/arch/x86/boot/video.c
10750 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10751 static unsigned int get_entry(void)
10752 {
10753 char entry_buf[4];
10754 - int i, len = 0;
10755 + unsigned int i, len = 0;
10756 int key;
10757 unsigned int v;
10758
10759 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10760 index 9105655..5e37f27 100644
10761 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10762 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10763 @@ -8,6 +8,8 @@
10764 * including this sentence is retained in full.
10765 */
10766
10767 +#include <asm/alternative-asm.h>
10768 +
10769 .extern crypto_ft_tab
10770 .extern crypto_it_tab
10771 .extern crypto_fl_tab
10772 @@ -70,6 +72,8 @@
10773 je B192; \
10774 leaq 32(r9),r9;
10775
10776 +#define ret pax_force_retaddr 0, 1; ret
10777 +
10778 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10779 movq r1,r2; \
10780 movq r3,r4; \
10781 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10782 index 477e9d7..3ab339f 100644
10783 --- a/arch/x86/crypto/aesni-intel_asm.S
10784 +++ b/arch/x86/crypto/aesni-intel_asm.S
10785 @@ -31,6 +31,7 @@
10786
10787 #include <linux/linkage.h>
10788 #include <asm/inst.h>
10789 +#include <asm/alternative-asm.h>
10790
10791 #ifdef __x86_64__
10792 .data
10793 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
10794 pop %r14
10795 pop %r13
10796 pop %r12
10797 + pax_force_retaddr 0, 1
10798 ret
10799 ENDPROC(aesni_gcm_dec)
10800
10801 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
10802 pop %r14
10803 pop %r13
10804 pop %r12
10805 + pax_force_retaddr 0, 1
10806 ret
10807 ENDPROC(aesni_gcm_enc)
10808
10809 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
10810 pxor %xmm1, %xmm0
10811 movaps %xmm0, (TKEYP)
10812 add $0x10, TKEYP
10813 + pax_force_retaddr_bts
10814 ret
10815 ENDPROC(_key_expansion_128)
10816 ENDPROC(_key_expansion_256a)
10817 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
10818 shufps $0b01001110, %xmm2, %xmm1
10819 movaps %xmm1, 0x10(TKEYP)
10820 add $0x20, TKEYP
10821 + pax_force_retaddr_bts
10822 ret
10823 ENDPROC(_key_expansion_192a)
10824
10825 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
10826
10827 movaps %xmm0, (TKEYP)
10828 add $0x10, TKEYP
10829 + pax_force_retaddr_bts
10830 ret
10831 ENDPROC(_key_expansion_192b)
10832
10833 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
10834 pxor %xmm1, %xmm2
10835 movaps %xmm2, (TKEYP)
10836 add $0x10, TKEYP
10837 + pax_force_retaddr_bts
10838 ret
10839 ENDPROC(_key_expansion_256b)
10840
10841 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
10842 #ifndef __x86_64__
10843 popl KEYP
10844 #endif
10845 + pax_force_retaddr 0, 1
10846 ret
10847 ENDPROC(aesni_set_key)
10848
10849 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
10850 popl KLEN
10851 popl KEYP
10852 #endif
10853 + pax_force_retaddr 0, 1
10854 ret
10855 ENDPROC(aesni_enc)
10856
10857 @@ -1974,6 +1983,7 @@ _aesni_enc1:
10858 AESENC KEY STATE
10859 movaps 0x70(TKEYP), KEY
10860 AESENCLAST KEY STATE
10861 + pax_force_retaddr_bts
10862 ret
10863 ENDPROC(_aesni_enc1)
10864
10865 @@ -2083,6 +2093,7 @@ _aesni_enc4:
10866 AESENCLAST KEY STATE2
10867 AESENCLAST KEY STATE3
10868 AESENCLAST KEY STATE4
10869 + pax_force_retaddr_bts
10870 ret
10871 ENDPROC(_aesni_enc4)
10872
10873 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
10874 popl KLEN
10875 popl KEYP
10876 #endif
10877 + pax_force_retaddr 0, 1
10878 ret
10879 ENDPROC(aesni_dec)
10880
10881 @@ -2164,6 +2176,7 @@ _aesni_dec1:
10882 AESDEC KEY STATE
10883 movaps 0x70(TKEYP), KEY
10884 AESDECLAST KEY STATE
10885 + pax_force_retaddr_bts
10886 ret
10887 ENDPROC(_aesni_dec1)
10888
10889 @@ -2273,6 +2286,7 @@ _aesni_dec4:
10890 AESDECLAST KEY STATE2
10891 AESDECLAST KEY STATE3
10892 AESDECLAST KEY STATE4
10893 + pax_force_retaddr_bts
10894 ret
10895 ENDPROC(_aesni_dec4)
10896
10897 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
10898 popl KEYP
10899 popl LEN
10900 #endif
10901 + pax_force_retaddr 0, 1
10902 ret
10903 ENDPROC(aesni_ecb_enc)
10904
10905 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
10906 popl KEYP
10907 popl LEN
10908 #endif
10909 + pax_force_retaddr 0, 1
10910 ret
10911 ENDPROC(aesni_ecb_dec)
10912
10913 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
10914 popl LEN
10915 popl IVP
10916 #endif
10917 + pax_force_retaddr 0, 1
10918 ret
10919 ENDPROC(aesni_cbc_enc)
10920
10921 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
10922 popl LEN
10923 popl IVP
10924 #endif
10925 + pax_force_retaddr 0, 1
10926 ret
10927 ENDPROC(aesni_cbc_dec)
10928
10929 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
10930 mov $1, TCTR_LOW
10931 MOVQ_R64_XMM TCTR_LOW INC
10932 MOVQ_R64_XMM CTR TCTR_LOW
10933 + pax_force_retaddr_bts
10934 ret
10935 ENDPROC(_aesni_inc_init)
10936
10937 @@ -2579,6 +2598,7 @@ _aesni_inc:
10938 .Linc_low:
10939 movaps CTR, IV
10940 PSHUFB_XMM BSWAP_MASK IV
10941 + pax_force_retaddr_bts
10942 ret
10943 ENDPROC(_aesni_inc)
10944
10945 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
10946 .Lctr_enc_ret:
10947 movups IV, (IVP)
10948 .Lctr_enc_just_ret:
10949 + pax_force_retaddr 0, 1
10950 ret
10951 ENDPROC(aesni_ctr_enc)
10952
10953 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
10954 pxor INC, STATE4
10955 movdqu STATE4, 0x70(OUTP)
10956
10957 + pax_force_retaddr 0, 1
10958 ret
10959 ENDPROC(aesni_xts_crypt8)
10960
10961 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10962 index 246c670..4d1ed00 100644
10963 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10964 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10965 @@ -21,6 +21,7 @@
10966 */
10967
10968 #include <linux/linkage.h>
10969 +#include <asm/alternative-asm.h>
10970
10971 .file "blowfish-x86_64-asm.S"
10972 .text
10973 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10974 jnz .L__enc_xor;
10975
10976 write_block();
10977 + pax_force_retaddr 0, 1
10978 ret;
10979 .L__enc_xor:
10980 xor_block();
10981 + pax_force_retaddr 0, 1
10982 ret;
10983 ENDPROC(__blowfish_enc_blk)
10984
10985 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10986
10987 movq %r11, %rbp;
10988
10989 + pax_force_retaddr 0, 1
10990 ret;
10991 ENDPROC(blowfish_dec_blk)
10992
10993 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10994
10995 popq %rbx;
10996 popq %rbp;
10997 + pax_force_retaddr 0, 1
10998 ret;
10999
11000 .L__enc_xor4:
11001 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
11002
11003 popq %rbx;
11004 popq %rbp;
11005 + pax_force_retaddr 0, 1
11006 ret;
11007 ENDPROC(__blowfish_enc_blk_4way)
11008
11009 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
11010 popq %rbx;
11011 popq %rbp;
11012
11013 + pax_force_retaddr 0, 1
11014 ret;
11015 ENDPROC(blowfish_dec_blk_4way)
11016 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11017 index 310319c..ce174a4 100644
11018 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11019 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11020 @@ -21,6 +21,7 @@
11021 */
11022
11023 #include <linux/linkage.h>
11024 +#include <asm/alternative-asm.h>
11025
11026 .file "camellia-x86_64-asm_64.S"
11027 .text
11028 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11029 enc_outunpack(mov, RT1);
11030
11031 movq RRBP, %rbp;
11032 + pax_force_retaddr 0, 1
11033 ret;
11034
11035 .L__enc_xor:
11036 enc_outunpack(xor, RT1);
11037
11038 movq RRBP, %rbp;
11039 + pax_force_retaddr 0, 1
11040 ret;
11041 ENDPROC(__camellia_enc_blk)
11042
11043 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11044 dec_outunpack();
11045
11046 movq RRBP, %rbp;
11047 + pax_force_retaddr 0, 1
11048 ret;
11049 ENDPROC(camellia_dec_blk)
11050
11051 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11052
11053 movq RRBP, %rbp;
11054 popq %rbx;
11055 + pax_force_retaddr 0, 1
11056 ret;
11057
11058 .L__enc2_xor:
11059 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11060
11061 movq RRBP, %rbp;
11062 popq %rbx;
11063 + pax_force_retaddr 0, 1
11064 ret;
11065 ENDPROC(__camellia_enc_blk_2way)
11066
11067 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11068
11069 movq RRBP, %rbp;
11070 movq RXOR, %rbx;
11071 + pax_force_retaddr 0, 1
11072 ret;
11073 ENDPROC(camellia_dec_blk_2way)
11074 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11075 index c35fd5d..c1ee236 100644
11076 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11077 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11078 @@ -24,6 +24,7 @@
11079 */
11080
11081 #include <linux/linkage.h>
11082 +#include <asm/alternative-asm.h>
11083
11084 .file "cast5-avx-x86_64-asm_64.S"
11085
11086 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11087 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11088 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11089
11090 + pax_force_retaddr 0, 1
11091 ret;
11092 ENDPROC(__cast5_enc_blk16)
11093
11094 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11095 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11096 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11097
11098 + pax_force_retaddr 0, 1
11099 ret;
11100
11101 .L__skip_dec:
11102 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11103 vmovdqu RR4, (6*4*4)(%r11);
11104 vmovdqu RL4, (7*4*4)(%r11);
11105
11106 + pax_force_retaddr
11107 ret;
11108 ENDPROC(cast5_ecb_enc_16way)
11109
11110 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11111 vmovdqu RR4, (6*4*4)(%r11);
11112 vmovdqu RL4, (7*4*4)(%r11);
11113
11114 + pax_force_retaddr
11115 ret;
11116 ENDPROC(cast5_ecb_dec_16way)
11117
11118 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11119
11120 popq %r12;
11121
11122 + pax_force_retaddr
11123 ret;
11124 ENDPROC(cast5_cbc_dec_16way)
11125
11126 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11127
11128 popq %r12;
11129
11130 + pax_force_retaddr
11131 ret;
11132 ENDPROC(cast5_ctr_16way)
11133 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11134 index e3531f8..18ded3a 100644
11135 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11136 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11137 @@ -24,6 +24,7 @@
11138 */
11139
11140 #include <linux/linkage.h>
11141 +#include <asm/alternative-asm.h>
11142 #include "glue_helper-asm-avx.S"
11143
11144 .file "cast6-avx-x86_64-asm_64.S"
11145 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
11146 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11147 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11148
11149 + pax_force_retaddr 0, 1
11150 ret;
11151 ENDPROC(__cast6_enc_blk8)
11152
11153 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
11154 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11155 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11156
11157 + pax_force_retaddr 0, 1
11158 ret;
11159 ENDPROC(__cast6_dec_blk8)
11160
11161 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
11162
11163 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11164
11165 + pax_force_retaddr
11166 ret;
11167 ENDPROC(cast6_ecb_enc_8way)
11168
11169 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
11170
11171 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11172
11173 + pax_force_retaddr
11174 ret;
11175 ENDPROC(cast6_ecb_dec_8way)
11176
11177 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
11178
11179 popq %r12;
11180
11181 + pax_force_retaddr
11182 ret;
11183 ENDPROC(cast6_cbc_dec_8way)
11184
11185 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
11186
11187 popq %r12;
11188
11189 + pax_force_retaddr
11190 ret;
11191 ENDPROC(cast6_ctr_8way)
11192
11193 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
11194 /* dst <= regs xor IVs(in dst) */
11195 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11196
11197 + pax_force_retaddr
11198 ret;
11199 ENDPROC(cast6_xts_enc_8way)
11200
11201 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
11202 /* dst <= regs xor IVs(in dst) */
11203 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11204
11205 + pax_force_retaddr
11206 ret;
11207 ENDPROC(cast6_xts_dec_8way)
11208 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11209 index 9279e0b..9270820 100644
11210 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11211 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11212 @@ -1,4 +1,5 @@
11213 #include <linux/linkage.h>
11214 +#include <asm/alternative-asm.h>
11215
11216 # enter salsa20_encrypt_bytes
11217 ENTRY(salsa20_encrypt_bytes)
11218 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11219 add %r11,%rsp
11220 mov %rdi,%rax
11221 mov %rsi,%rdx
11222 + pax_force_retaddr 0, 1
11223 ret
11224 # bytesatleast65:
11225 ._bytesatleast65:
11226 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11227 add %r11,%rsp
11228 mov %rdi,%rax
11229 mov %rsi,%rdx
11230 + pax_force_retaddr
11231 ret
11232 ENDPROC(salsa20_keysetup)
11233
11234 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11235 add %r11,%rsp
11236 mov %rdi,%rax
11237 mov %rsi,%rdx
11238 + pax_force_retaddr
11239 ret
11240 ENDPROC(salsa20_ivsetup)
11241 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11242 index 2f202f4..d9164d6 100644
11243 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11244 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11245 @@ -24,6 +24,7 @@
11246 */
11247
11248 #include <linux/linkage.h>
11249 +#include <asm/alternative-asm.h>
11250 #include "glue_helper-asm-avx.S"
11251
11252 .file "serpent-avx-x86_64-asm_64.S"
11253 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
11254 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11255 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11256
11257 + pax_force_retaddr
11258 ret;
11259 ENDPROC(__serpent_enc_blk8_avx)
11260
11261 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
11262 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11263 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11264
11265 + pax_force_retaddr
11266 ret;
11267 ENDPROC(__serpent_dec_blk8_avx)
11268
11269 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11270
11271 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11272
11273 + pax_force_retaddr
11274 ret;
11275 ENDPROC(serpent_ecb_enc_8way_avx)
11276
11277 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11278
11279 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11280
11281 + pax_force_retaddr
11282 ret;
11283 ENDPROC(serpent_ecb_dec_8way_avx)
11284
11285 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11286
11287 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11288
11289 + pax_force_retaddr
11290 ret;
11291 ENDPROC(serpent_cbc_dec_8way_avx)
11292
11293 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
11294
11295 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11296
11297 + pax_force_retaddr
11298 ret;
11299 ENDPROC(serpent_ctr_8way_avx)
11300
11301 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
11302 /* dst <= regs xor IVs(in dst) */
11303 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11304
11305 + pax_force_retaddr
11306 ret;
11307 ENDPROC(serpent_xts_enc_8way_avx)
11308
11309 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
11310 /* dst <= regs xor IVs(in dst) */
11311 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11312
11313 + pax_force_retaddr
11314 ret;
11315 ENDPROC(serpent_xts_dec_8way_avx)
11316 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11317 index acc066c..1559cc4 100644
11318 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11319 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11320 @@ -25,6 +25,7 @@
11321 */
11322
11323 #include <linux/linkage.h>
11324 +#include <asm/alternative-asm.h>
11325
11326 .file "serpent-sse2-x86_64-asm_64.S"
11327 .text
11328 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11329 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11330 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11331
11332 + pax_force_retaddr
11333 ret;
11334
11335 .L__enc_xor8:
11336 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11337 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11338
11339 + pax_force_retaddr
11340 ret;
11341 ENDPROC(__serpent_enc_blk_8way)
11342
11343 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11344 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11345 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11346
11347 + pax_force_retaddr
11348 ret;
11349 ENDPROC(serpent_dec_blk_8way)
11350 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11351 index a410950..3356d42 100644
11352 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11353 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11354 @@ -29,6 +29,7 @@
11355 */
11356
11357 #include <linux/linkage.h>
11358 +#include <asm/alternative-asm.h>
11359
11360 #define CTX %rdi // arg1
11361 #define BUF %rsi // arg2
11362 @@ -104,6 +105,7 @@
11363 pop %r12
11364 pop %rbp
11365 pop %rbx
11366 + pax_force_retaddr 0, 1
11367 ret
11368
11369 ENDPROC(\name)
11370 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11371 index 0505813..63b1d00 100644
11372 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11373 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11374 @@ -24,6 +24,7 @@
11375 */
11376
11377 #include <linux/linkage.h>
11378 +#include <asm/alternative-asm.h>
11379 #include "glue_helper-asm-avx.S"
11380
11381 .file "twofish-avx-x86_64-asm_64.S"
11382 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
11383 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11384 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11385
11386 + pax_force_retaddr 0, 1
11387 ret;
11388 ENDPROC(__twofish_enc_blk8)
11389
11390 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
11391 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11392 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11393
11394 + pax_force_retaddr 0, 1
11395 ret;
11396 ENDPROC(__twofish_dec_blk8)
11397
11398 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
11399
11400 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11401
11402 + pax_force_retaddr 0, 1
11403 ret;
11404 ENDPROC(twofish_ecb_enc_8way)
11405
11406 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
11407
11408 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11409
11410 + pax_force_retaddr 0, 1
11411 ret;
11412 ENDPROC(twofish_ecb_dec_8way)
11413
11414 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
11415
11416 popq %r12;
11417
11418 + pax_force_retaddr 0, 1
11419 ret;
11420 ENDPROC(twofish_cbc_dec_8way)
11421
11422 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
11423
11424 popq %r12;
11425
11426 + pax_force_retaddr 0, 1
11427 ret;
11428 ENDPROC(twofish_ctr_8way)
11429
11430 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
11431 /* dst <= regs xor IVs(in dst) */
11432 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11433
11434 + pax_force_retaddr 0, 1
11435 ret;
11436 ENDPROC(twofish_xts_enc_8way)
11437
11438 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
11439 /* dst <= regs xor IVs(in dst) */
11440 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11441
11442 + pax_force_retaddr 0, 1
11443 ret;
11444 ENDPROC(twofish_xts_dec_8way)
11445 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11446 index 1c3b7ce..b365c5e 100644
11447 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11448 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11449 @@ -21,6 +21,7 @@
11450 */
11451
11452 #include <linux/linkage.h>
11453 +#include <asm/alternative-asm.h>
11454
11455 .file "twofish-x86_64-asm-3way.S"
11456 .text
11457 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11458 popq %r13;
11459 popq %r14;
11460 popq %r15;
11461 + pax_force_retaddr 0, 1
11462 ret;
11463
11464 .L__enc_xor3:
11465 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11466 popq %r13;
11467 popq %r14;
11468 popq %r15;
11469 + pax_force_retaddr 0, 1
11470 ret;
11471 ENDPROC(__twofish_enc_blk_3way)
11472
11473 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11474 popq %r13;
11475 popq %r14;
11476 popq %r15;
11477 + pax_force_retaddr 0, 1
11478 ret;
11479 ENDPROC(twofish_dec_blk_3way)
11480 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11481 index a039d21..29e7615 100644
11482 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11483 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11484 @@ -22,6 +22,7 @@
11485
11486 #include <linux/linkage.h>
11487 #include <asm/asm-offsets.h>
11488 +#include <asm/alternative-asm.h>
11489
11490 #define a_offset 0
11491 #define b_offset 4
11492 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11493
11494 popq R1
11495 movq $1,%rax
11496 + pax_force_retaddr 0, 1
11497 ret
11498 ENDPROC(twofish_enc_blk)
11499
11500 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11501
11502 popq R1
11503 movq $1,%rax
11504 + pax_force_retaddr 0, 1
11505 ret
11506 ENDPROC(twofish_dec_blk)
11507 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11508 index 52ff81c..98af645 100644
11509 --- a/arch/x86/ia32/ia32_aout.c
11510 +++ b/arch/x86/ia32/ia32_aout.c
11511 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11512 unsigned long dump_start, dump_size;
11513 struct user32 dump;
11514
11515 + memset(&dump, 0, sizeof(dump));
11516 +
11517 fs = get_fs();
11518 set_fs(KERNEL_DS);
11519 has_dumped = 1;
11520 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11521 index cf1a471..3bc4cf8 100644
11522 --- a/arch/x86/ia32/ia32_signal.c
11523 +++ b/arch/x86/ia32/ia32_signal.c
11524 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11525 sp -= frame_size;
11526 /* Align the stack pointer according to the i386 ABI,
11527 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11528 - sp = ((sp + 4) & -16ul) - 4;
11529 + sp = ((sp - 12) & -16ul) - 4;
11530 return (void __user *) sp;
11531 }
11532
11533 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11534 * These are actually not used anymore, but left because some
11535 * gdb versions depend on them as a marker.
11536 */
11537 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11538 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11539 } put_user_catch(err);
11540
11541 if (err)
11542 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11543 0xb8,
11544 __NR_ia32_rt_sigreturn,
11545 0x80cd,
11546 - 0,
11547 + 0
11548 };
11549
11550 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11551 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11552
11553 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11554 restorer = ksig->ka.sa.sa_restorer;
11555 + else if (current->mm->context.vdso)
11556 + /* Return stub is in 32bit vsyscall page */
11557 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11558 else
11559 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11560 - rt_sigreturn);
11561 + restorer = &frame->retcode;
11562 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11563
11564 /*
11565 * Not actually used anymore, but left because some gdb
11566 * versions need it.
11567 */
11568 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11569 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11570 } put_user_catch(err);
11571
11572 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11573 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11574 index 474dc1b..24aaa3e 100644
11575 --- a/arch/x86/ia32/ia32entry.S
11576 +++ b/arch/x86/ia32/ia32entry.S
11577 @@ -15,8 +15,10 @@
11578 #include <asm/irqflags.h>
11579 #include <asm/asm.h>
11580 #include <asm/smap.h>
11581 +#include <asm/pgtable.h>
11582 #include <linux/linkage.h>
11583 #include <linux/err.h>
11584 +#include <asm/alternative-asm.h>
11585
11586 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11587 #include <linux/elf-em.h>
11588 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11589 ENDPROC(native_irq_enable_sysexit)
11590 #endif
11591
11592 + .macro pax_enter_kernel_user
11593 + pax_set_fptr_mask
11594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11595 + call pax_enter_kernel_user
11596 +#endif
11597 + .endm
11598 +
11599 + .macro pax_exit_kernel_user
11600 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11601 + call pax_exit_kernel_user
11602 +#endif
11603 +#ifdef CONFIG_PAX_RANDKSTACK
11604 + pushq %rax
11605 + pushq %r11
11606 + call pax_randomize_kstack
11607 + popq %r11
11608 + popq %rax
11609 +#endif
11610 + .endm
11611 +
11612 + .macro pax_erase_kstack
11613 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11614 + call pax_erase_kstack
11615 +#endif
11616 + .endm
11617 +
11618 /*
11619 * 32bit SYSENTER instruction entry.
11620 *
11621 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11622 CFI_REGISTER rsp,rbp
11623 SWAPGS_UNSAFE_STACK
11624 movq PER_CPU_VAR(kernel_stack), %rsp
11625 - addq $(KERNEL_STACK_OFFSET),%rsp
11626 - /*
11627 - * No need to follow this irqs on/off section: the syscall
11628 - * disabled irqs, here we enable it straight after entry:
11629 - */
11630 - ENABLE_INTERRUPTS(CLBR_NONE)
11631 movl %ebp,%ebp /* zero extension */
11632 pushq_cfi $__USER32_DS
11633 /*CFI_REL_OFFSET ss,0*/
11634 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11635 CFI_REL_OFFSET rsp,0
11636 pushfq_cfi
11637 /*CFI_REL_OFFSET rflags,0*/
11638 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11639 - CFI_REGISTER rip,r10
11640 + orl $X86_EFLAGS_IF,(%rsp)
11641 + GET_THREAD_INFO(%r11)
11642 + movl TI_sysenter_return(%r11), %r11d
11643 + CFI_REGISTER rip,r11
11644 pushq_cfi $__USER32_CS
11645 /*CFI_REL_OFFSET cs,0*/
11646 movl %eax, %eax
11647 - pushq_cfi %r10
11648 + pushq_cfi %r11
11649 CFI_REL_OFFSET rip,0
11650 pushq_cfi %rax
11651 cld
11652 SAVE_ARGS 0,1,0
11653 + pax_enter_kernel_user
11654 +
11655 +#ifdef CONFIG_PAX_RANDKSTACK
11656 + pax_erase_kstack
11657 +#endif
11658 +
11659 + /*
11660 + * No need to follow this irqs on/off section: the syscall
11661 + * disabled irqs, here we enable it straight after entry:
11662 + */
11663 + ENABLE_INTERRUPTS(CLBR_NONE)
11664 /* no need to do an access_ok check here because rbp has been
11665 32bit zero extended */
11666 +
11667 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11668 + mov pax_user_shadow_base,%r11
11669 + add %r11,%rbp
11670 +#endif
11671 +
11672 ASM_STAC
11673 1: movl (%rbp),%ebp
11674 _ASM_EXTABLE(1b,ia32_badarg)
11675 ASM_CLAC
11676 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11677 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11678 + GET_THREAD_INFO(%r11)
11679 + orl $TS_COMPAT,TI_status(%r11)
11680 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11681 CFI_REMEMBER_STATE
11682 jnz sysenter_tracesys
11683 cmpq $(IA32_NR_syscalls-1),%rax
11684 @@ -162,12 +204,15 @@ sysenter_do_call:
11685 sysenter_dispatch:
11686 call *ia32_sys_call_table(,%rax,8)
11687 movq %rax,RAX-ARGOFFSET(%rsp)
11688 + GET_THREAD_INFO(%r11)
11689 DISABLE_INTERRUPTS(CLBR_NONE)
11690 TRACE_IRQS_OFF
11691 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11692 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11693 jnz sysexit_audit
11694 sysexit_from_sys_call:
11695 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11696 + pax_exit_kernel_user
11697 + pax_erase_kstack
11698 + andl $~TS_COMPAT,TI_status(%r11)
11699 /* clear IF, that popfq doesn't enable interrupts early */
11700 andl $~0x200,EFLAGS-R11(%rsp)
11701 movl RIP-R11(%rsp),%edx /* User %eip */
11702 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11703 movl %eax,%esi /* 2nd arg: syscall number */
11704 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11705 call __audit_syscall_entry
11706 +
11707 + pax_erase_kstack
11708 +
11709 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11710 cmpq $(IA32_NR_syscalls-1),%rax
11711 ja ia32_badsys
11712 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11713 .endm
11714
11715 .macro auditsys_exit exit
11716 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11717 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11718 jnz ia32_ret_from_sys_call
11719 TRACE_IRQS_ON
11720 ENABLE_INTERRUPTS(CLBR_NONE)
11721 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11722 1: setbe %al /* 1 if error, 0 if not */
11723 movzbl %al,%edi /* zero-extend that into %edi */
11724 call __audit_syscall_exit
11725 + GET_THREAD_INFO(%r11)
11726 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11727 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11728 DISABLE_INTERRUPTS(CLBR_NONE)
11729 TRACE_IRQS_OFF
11730 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11731 + testl %edi,TI_flags(%r11)
11732 jz \exit
11733 CLEAR_RREGS -ARGOFFSET
11734 jmp int_with_check
11735 @@ -237,7 +286,7 @@ sysexit_audit:
11736
11737 sysenter_tracesys:
11738 #ifdef CONFIG_AUDITSYSCALL
11739 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11740 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11741 jz sysenter_auditsys
11742 #endif
11743 SAVE_REST
11744 @@ -249,6 +298,9 @@ sysenter_tracesys:
11745 RESTORE_REST
11746 cmpq $(IA32_NR_syscalls-1),%rax
11747 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11748 +
11749 + pax_erase_kstack
11750 +
11751 jmp sysenter_do_call
11752 CFI_ENDPROC
11753 ENDPROC(ia32_sysenter_target)
11754 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11755 ENTRY(ia32_cstar_target)
11756 CFI_STARTPROC32 simple
11757 CFI_SIGNAL_FRAME
11758 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11759 + CFI_DEF_CFA rsp,0
11760 CFI_REGISTER rip,rcx
11761 /*CFI_REGISTER rflags,r11*/
11762 SWAPGS_UNSAFE_STACK
11763 movl %esp,%r8d
11764 CFI_REGISTER rsp,r8
11765 movq PER_CPU_VAR(kernel_stack),%rsp
11766 + SAVE_ARGS 8*6,0,0
11767 + pax_enter_kernel_user
11768 +
11769 +#ifdef CONFIG_PAX_RANDKSTACK
11770 + pax_erase_kstack
11771 +#endif
11772 +
11773 /*
11774 * No need to follow this irqs on/off section: the syscall
11775 * disabled irqs and here we enable it straight after entry:
11776 */
11777 ENABLE_INTERRUPTS(CLBR_NONE)
11778 - SAVE_ARGS 8,0,0
11779 movl %eax,%eax /* zero extension */
11780 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11781 movq %rcx,RIP-ARGOFFSET(%rsp)
11782 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11783 /* no need to do an access_ok check here because r8 has been
11784 32bit zero extended */
11785 /* hardware stack frame is complete now */
11786 +
11787 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11788 + mov pax_user_shadow_base,%r11
11789 + add %r11,%r8
11790 +#endif
11791 +
11792 ASM_STAC
11793 1: movl (%r8),%r9d
11794 _ASM_EXTABLE(1b,ia32_badarg)
11795 ASM_CLAC
11796 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11797 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11798 + GET_THREAD_INFO(%r11)
11799 + orl $TS_COMPAT,TI_status(%r11)
11800 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11801 CFI_REMEMBER_STATE
11802 jnz cstar_tracesys
11803 cmpq $IA32_NR_syscalls-1,%rax
11804 @@ -319,12 +384,15 @@ cstar_do_call:
11805 cstar_dispatch:
11806 call *ia32_sys_call_table(,%rax,8)
11807 movq %rax,RAX-ARGOFFSET(%rsp)
11808 + GET_THREAD_INFO(%r11)
11809 DISABLE_INTERRUPTS(CLBR_NONE)
11810 TRACE_IRQS_OFF
11811 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11812 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11813 jnz sysretl_audit
11814 sysretl_from_sys_call:
11815 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11816 + pax_exit_kernel_user
11817 + pax_erase_kstack
11818 + andl $~TS_COMPAT,TI_status(%r11)
11819 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11820 movl RIP-ARGOFFSET(%rsp),%ecx
11821 CFI_REGISTER rip,rcx
11822 @@ -352,7 +420,7 @@ sysretl_audit:
11823
11824 cstar_tracesys:
11825 #ifdef CONFIG_AUDITSYSCALL
11826 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11827 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11828 jz cstar_auditsys
11829 #endif
11830 xchgl %r9d,%ebp
11831 @@ -366,6 +434,9 @@ cstar_tracesys:
11832 xchgl %ebp,%r9d
11833 cmpq $(IA32_NR_syscalls-1),%rax
11834 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11835 +
11836 + pax_erase_kstack
11837 +
11838 jmp cstar_do_call
11839 END(ia32_cstar_target)
11840
11841 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11842 CFI_REL_OFFSET rip,RIP-RIP
11843 PARAVIRT_ADJUST_EXCEPTION_FRAME
11844 SWAPGS
11845 - /*
11846 - * No need to follow this irqs on/off section: the syscall
11847 - * disabled irqs and here we enable it straight after entry:
11848 - */
11849 - ENABLE_INTERRUPTS(CLBR_NONE)
11850 movl %eax,%eax
11851 pushq_cfi %rax
11852 cld
11853 /* note the registers are not zero extended to the sf.
11854 this could be a problem. */
11855 SAVE_ARGS 0,1,0
11856 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11857 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11858 + pax_enter_kernel_user
11859 +
11860 +#ifdef CONFIG_PAX_RANDKSTACK
11861 + pax_erase_kstack
11862 +#endif
11863 +
11864 + /*
11865 + * No need to follow this irqs on/off section: the syscall
11866 + * disabled irqs and here we enable it straight after entry:
11867 + */
11868 + ENABLE_INTERRUPTS(CLBR_NONE)
11869 + GET_THREAD_INFO(%r11)
11870 + orl $TS_COMPAT,TI_status(%r11)
11871 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11872 jnz ia32_tracesys
11873 cmpq $(IA32_NR_syscalls-1),%rax
11874 ja ia32_badsys
11875 @@ -442,6 +520,9 @@ ia32_tracesys:
11876 RESTORE_REST
11877 cmpq $(IA32_NR_syscalls-1),%rax
11878 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11879 +
11880 + pax_erase_kstack
11881 +
11882 jmp ia32_do_call
11883 END(ia32_syscall)
11884
11885 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11886 index 8e0ceec..af13504 100644
11887 --- a/arch/x86/ia32/sys_ia32.c
11888 +++ b/arch/x86/ia32/sys_ia32.c
11889 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11890 */
11891 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11892 {
11893 - typeof(ubuf->st_uid) uid = 0;
11894 - typeof(ubuf->st_gid) gid = 0;
11895 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11896 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11897 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11898 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11899 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11900 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11901 index 372231c..a5aa1a1 100644
11902 --- a/arch/x86/include/asm/alternative-asm.h
11903 +++ b/arch/x86/include/asm/alternative-asm.h
11904 @@ -18,6 +18,45 @@
11905 .endm
11906 #endif
11907
11908 +#ifdef KERNEXEC_PLUGIN
11909 + .macro pax_force_retaddr_bts rip=0
11910 + btsq $63,\rip(%rsp)
11911 + .endm
11912 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11913 + .macro pax_force_retaddr rip=0, reload=0
11914 + btsq $63,\rip(%rsp)
11915 + .endm
11916 + .macro pax_force_fptr ptr
11917 + btsq $63,\ptr
11918 + .endm
11919 + .macro pax_set_fptr_mask
11920 + .endm
11921 +#endif
11922 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11923 + .macro pax_force_retaddr rip=0, reload=0
11924 + .if \reload
11925 + pax_set_fptr_mask
11926 + .endif
11927 + orq %r10,\rip(%rsp)
11928 + .endm
11929 + .macro pax_force_fptr ptr
11930 + orq %r10,\ptr
11931 + .endm
11932 + .macro pax_set_fptr_mask
11933 + movabs $0x8000000000000000,%r10
11934 + .endm
11935 +#endif
11936 +#else
11937 + .macro pax_force_retaddr rip=0, reload=0
11938 + .endm
11939 + .macro pax_force_fptr ptr
11940 + .endm
11941 + .macro pax_force_retaddr_bts rip=0
11942 + .endm
11943 + .macro pax_set_fptr_mask
11944 + .endm
11945 +#endif
11946 +
11947 .macro altinstruction_entry orig alt feature orig_len alt_len
11948 .long \orig - .
11949 .long \alt - .
11950 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11951 index 58ed6d9..f1cbe58 100644
11952 --- a/arch/x86/include/asm/alternative.h
11953 +++ b/arch/x86/include/asm/alternative.h
11954 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11955 ".pushsection .discard,\"aw\",@progbits\n" \
11956 DISCARD_ENTRY(1) \
11957 ".popsection\n" \
11958 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11959 + ".pushsection .altinstr_replacement, \"a\"\n" \
11960 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11961 ".popsection"
11962
11963 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11964 DISCARD_ENTRY(1) \
11965 DISCARD_ENTRY(2) \
11966 ".popsection\n" \
11967 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11968 + ".pushsection .altinstr_replacement, \"a\"\n" \
11969 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11970 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11971 ".popsection"
11972 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11973 index 3388034..050f0b9 100644
11974 --- a/arch/x86/include/asm/apic.h
11975 +++ b/arch/x86/include/asm/apic.h
11976 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11977
11978 #ifdef CONFIG_X86_LOCAL_APIC
11979
11980 -extern unsigned int apic_verbosity;
11981 +extern int apic_verbosity;
11982 extern int local_apic_timer_c2_ok;
11983
11984 extern int disable_apic;
11985 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11986 index 20370c6..a2eb9b0 100644
11987 --- a/arch/x86/include/asm/apm.h
11988 +++ b/arch/x86/include/asm/apm.h
11989 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11990 __asm__ __volatile__(APM_DO_ZERO_SEGS
11991 "pushl %%edi\n\t"
11992 "pushl %%ebp\n\t"
11993 - "lcall *%%cs:apm_bios_entry\n\t"
11994 + "lcall *%%ss:apm_bios_entry\n\t"
11995 "setc %%al\n\t"
11996 "popl %%ebp\n\t"
11997 "popl %%edi\n\t"
11998 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11999 __asm__ __volatile__(APM_DO_ZERO_SEGS
12000 "pushl %%edi\n\t"
12001 "pushl %%ebp\n\t"
12002 - "lcall *%%cs:apm_bios_entry\n\t"
12003 + "lcall *%%ss:apm_bios_entry\n\t"
12004 "setc %%bl\n\t"
12005 "popl %%ebp\n\t"
12006 "popl %%edi\n\t"
12007 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12008 index 722aa3b..3a0bb27 100644
12009 --- a/arch/x86/include/asm/atomic.h
12010 +++ b/arch/x86/include/asm/atomic.h
12011 @@ -22,7 +22,18 @@
12012 */
12013 static inline int atomic_read(const atomic_t *v)
12014 {
12015 - return (*(volatile int *)&(v)->counter);
12016 + return (*(volatile const int *)&(v)->counter);
12017 +}
12018 +
12019 +/**
12020 + * atomic_read_unchecked - read atomic variable
12021 + * @v: pointer of type atomic_unchecked_t
12022 + *
12023 + * Atomically reads the value of @v.
12024 + */
12025 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12026 +{
12027 + return (*(volatile const int *)&(v)->counter);
12028 }
12029
12030 /**
12031 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12032 }
12033
12034 /**
12035 + * atomic_set_unchecked - set atomic variable
12036 + * @v: pointer of type atomic_unchecked_t
12037 + * @i: required value
12038 + *
12039 + * Atomically sets the value of @v to @i.
12040 + */
12041 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12042 +{
12043 + v->counter = i;
12044 +}
12045 +
12046 +/**
12047 * atomic_add - add integer to atomic variable
12048 * @i: integer value to add
12049 * @v: pointer of type atomic_t
12050 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12051 */
12052 static inline void atomic_add(int i, atomic_t *v)
12053 {
12054 - asm volatile(LOCK_PREFIX "addl %1,%0"
12055 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12056 +
12057 +#ifdef CONFIG_PAX_REFCOUNT
12058 + "jno 0f\n"
12059 + LOCK_PREFIX "subl %1,%0\n"
12060 + "int $4\n0:\n"
12061 + _ASM_EXTABLE(0b, 0b)
12062 +#endif
12063 +
12064 + : "+m" (v->counter)
12065 + : "ir" (i));
12066 +}
12067 +
12068 +/**
12069 + * atomic_add_unchecked - add integer to atomic variable
12070 + * @i: integer value to add
12071 + * @v: pointer of type atomic_unchecked_t
12072 + *
12073 + * Atomically adds @i to @v.
12074 + */
12075 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12076 +{
12077 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12078 : "+m" (v->counter)
12079 : "ir" (i));
12080 }
12081 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12082 */
12083 static inline void atomic_sub(int i, atomic_t *v)
12084 {
12085 - asm volatile(LOCK_PREFIX "subl %1,%0"
12086 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12087 +
12088 +#ifdef CONFIG_PAX_REFCOUNT
12089 + "jno 0f\n"
12090 + LOCK_PREFIX "addl %1,%0\n"
12091 + "int $4\n0:\n"
12092 + _ASM_EXTABLE(0b, 0b)
12093 +#endif
12094 +
12095 + : "+m" (v->counter)
12096 + : "ir" (i));
12097 +}
12098 +
12099 +/**
12100 + * atomic_sub_unchecked - subtract integer from atomic variable
12101 + * @i: integer value to subtract
12102 + * @v: pointer of type atomic_unchecked_t
12103 + *
12104 + * Atomically subtracts @i from @v.
12105 + */
12106 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12107 +{
12108 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12109 : "+m" (v->counter)
12110 : "ir" (i));
12111 }
12112 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12113 {
12114 unsigned char c;
12115
12116 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12117 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12118 +
12119 +#ifdef CONFIG_PAX_REFCOUNT
12120 + "jno 0f\n"
12121 + LOCK_PREFIX "addl %2,%0\n"
12122 + "int $4\n0:\n"
12123 + _ASM_EXTABLE(0b, 0b)
12124 +#endif
12125 +
12126 + "sete %1\n"
12127 : "+m" (v->counter), "=qm" (c)
12128 : "ir" (i) : "memory");
12129 return c;
12130 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12131 */
12132 static inline void atomic_inc(atomic_t *v)
12133 {
12134 - asm volatile(LOCK_PREFIX "incl %0"
12135 + asm volatile(LOCK_PREFIX "incl %0\n"
12136 +
12137 +#ifdef CONFIG_PAX_REFCOUNT
12138 + "jno 0f\n"
12139 + LOCK_PREFIX "decl %0\n"
12140 + "int $4\n0:\n"
12141 + _ASM_EXTABLE(0b, 0b)
12142 +#endif
12143 +
12144 + : "+m" (v->counter));
12145 +}
12146 +
12147 +/**
12148 + * atomic_inc_unchecked - increment atomic variable
12149 + * @v: pointer of type atomic_unchecked_t
12150 + *
12151 + * Atomically increments @v by 1.
12152 + */
12153 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12154 +{
12155 + asm volatile(LOCK_PREFIX "incl %0\n"
12156 : "+m" (v->counter));
12157 }
12158
12159 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12160 */
12161 static inline void atomic_dec(atomic_t *v)
12162 {
12163 - asm volatile(LOCK_PREFIX "decl %0"
12164 + asm volatile(LOCK_PREFIX "decl %0\n"
12165 +
12166 +#ifdef CONFIG_PAX_REFCOUNT
12167 + "jno 0f\n"
12168 + LOCK_PREFIX "incl %0\n"
12169 + "int $4\n0:\n"
12170 + _ASM_EXTABLE(0b, 0b)
12171 +#endif
12172 +
12173 + : "+m" (v->counter));
12174 +}
12175 +
12176 +/**
12177 + * atomic_dec_unchecked - decrement atomic variable
12178 + * @v: pointer of type atomic_unchecked_t
12179 + *
12180 + * Atomically decrements @v by 1.
12181 + */
12182 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12183 +{
12184 + asm volatile(LOCK_PREFIX "decl %0\n"
12185 : "+m" (v->counter));
12186 }
12187
12188 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12189 {
12190 unsigned char c;
12191
12192 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12193 + asm volatile(LOCK_PREFIX "decl %0\n"
12194 +
12195 +#ifdef CONFIG_PAX_REFCOUNT
12196 + "jno 0f\n"
12197 + LOCK_PREFIX "incl %0\n"
12198 + "int $4\n0:\n"
12199 + _ASM_EXTABLE(0b, 0b)
12200 +#endif
12201 +
12202 + "sete %1\n"
12203 : "+m" (v->counter), "=qm" (c)
12204 : : "memory");
12205 return c != 0;
12206 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12207 {
12208 unsigned char c;
12209
12210 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12211 + asm volatile(LOCK_PREFIX "incl %0\n"
12212 +
12213 +#ifdef CONFIG_PAX_REFCOUNT
12214 + "jno 0f\n"
12215 + LOCK_PREFIX "decl %0\n"
12216 + "int $4\n0:\n"
12217 + _ASM_EXTABLE(0b, 0b)
12218 +#endif
12219 +
12220 + "sete %1\n"
12221 + : "+m" (v->counter), "=qm" (c)
12222 + : : "memory");
12223 + return c != 0;
12224 +}
12225 +
12226 +/**
12227 + * atomic_inc_and_test_unchecked - increment and test
12228 + * @v: pointer of type atomic_unchecked_t
12229 + *
12230 + * Atomically increments @v by 1
12231 + * and returns true if the result is zero, or false for all
12232 + * other cases.
12233 + */
12234 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12235 +{
12236 + unsigned char c;
12237 +
12238 + asm volatile(LOCK_PREFIX "incl %0\n"
12239 + "sete %1\n"
12240 : "+m" (v->counter), "=qm" (c)
12241 : : "memory");
12242 return c != 0;
12243 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12244 {
12245 unsigned char c;
12246
12247 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12248 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12249 +
12250 +#ifdef CONFIG_PAX_REFCOUNT
12251 + "jno 0f\n"
12252 + LOCK_PREFIX "subl %2,%0\n"
12253 + "int $4\n0:\n"
12254 + _ASM_EXTABLE(0b, 0b)
12255 +#endif
12256 +
12257 + "sets %1\n"
12258 : "+m" (v->counter), "=qm" (c)
12259 : "ir" (i) : "memory");
12260 return c;
12261 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12262 */
12263 static inline int atomic_add_return(int i, atomic_t *v)
12264 {
12265 + return i + xadd_check_overflow(&v->counter, i);
12266 +}
12267 +
12268 +/**
12269 + * atomic_add_return_unchecked - add integer and return
12270 + * @i: integer value to add
12271 + * @v: pointer of type atomic_unchecked_t
12272 + *
12273 + * Atomically adds @i to @v and returns @i + @v
12274 + */
12275 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12276 +{
12277 return i + xadd(&v->counter, i);
12278 }
12279
12280 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12281 }
12282
12283 #define atomic_inc_return(v) (atomic_add_return(1, v))
12284 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12285 +{
12286 + return atomic_add_return_unchecked(1, v);
12287 +}
12288 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12289
12290 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12291 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12292 return cmpxchg(&v->counter, old, new);
12293 }
12294
12295 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12296 +{
12297 + return cmpxchg(&v->counter, old, new);
12298 +}
12299 +
12300 static inline int atomic_xchg(atomic_t *v, int new)
12301 {
12302 return xchg(&v->counter, new);
12303 }
12304
12305 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12306 +{
12307 + return xchg(&v->counter, new);
12308 +}
12309 +
12310 /**
12311 * __atomic_add_unless - add unless the number is already a given value
12312 * @v: pointer of type atomic_t
12313 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12314 */
12315 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12316 {
12317 - int c, old;
12318 + int c, old, new;
12319 c = atomic_read(v);
12320 for (;;) {
12321 - if (unlikely(c == (u)))
12322 + if (unlikely(c == u))
12323 break;
12324 - old = atomic_cmpxchg((v), c, c + (a));
12325 +
12326 + asm volatile("addl %2,%0\n"
12327 +
12328 +#ifdef CONFIG_PAX_REFCOUNT
12329 + "jno 0f\n"
12330 + "subl %2,%0\n"
12331 + "int $4\n0:\n"
12332 + _ASM_EXTABLE(0b, 0b)
12333 +#endif
12334 +
12335 + : "=r" (new)
12336 + : "0" (c), "ir" (a));
12337 +
12338 + old = atomic_cmpxchg(v, c, new);
12339 if (likely(old == c))
12340 break;
12341 c = old;
12342 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12343 }
12344
12345 /**
12346 + * atomic_inc_not_zero_hint - increment if not null
12347 + * @v: pointer of type atomic_t
12348 + * @hint: probable value of the atomic before the increment
12349 + *
12350 + * This version of atomic_inc_not_zero() gives a hint of probable
12351 + * value of the atomic. This helps processor to not read the memory
12352 + * before doing the atomic read/modify/write cycle, lowering
12353 + * number of bus transactions on some arches.
12354 + *
12355 + * Returns: 0 if increment was not done, 1 otherwise.
12356 + */
12357 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12358 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12359 +{
12360 + int val, c = hint, new;
12361 +
12362 + /* sanity test, should be removed by compiler if hint is a constant */
12363 + if (!hint)
12364 + return __atomic_add_unless(v, 1, 0);
12365 +
12366 + do {
12367 + asm volatile("incl %0\n"
12368 +
12369 +#ifdef CONFIG_PAX_REFCOUNT
12370 + "jno 0f\n"
12371 + "decl %0\n"
12372 + "int $4\n0:\n"
12373 + _ASM_EXTABLE(0b, 0b)
12374 +#endif
12375 +
12376 + : "=r" (new)
12377 + : "0" (c));
12378 +
12379 + val = atomic_cmpxchg(v, c, new);
12380 + if (val == c)
12381 + return 1;
12382 + c = val;
12383 + } while (c);
12384 +
12385 + return 0;
12386 +}
12387 +
12388 +/**
12389 * atomic_inc_short - increment of a short integer
12390 * @v: pointer to type int
12391 *
12392 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12393 #endif
12394
12395 /* These are x86-specific, used by some header files */
12396 -#define atomic_clear_mask(mask, addr) \
12397 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12398 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12399 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12400 +{
12401 + asm volatile(LOCK_PREFIX "andl %1,%0"
12402 + : "+m" (v->counter)
12403 + : "r" (~(mask))
12404 + : "memory");
12405 +}
12406
12407 -#define atomic_set_mask(mask, addr) \
12408 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12409 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12410 - : "memory")
12411 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12412 +{
12413 + asm volatile(LOCK_PREFIX "andl %1,%0"
12414 + : "+m" (v->counter)
12415 + : "r" (~(mask))
12416 + : "memory");
12417 +}
12418 +
12419 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12420 +{
12421 + asm volatile(LOCK_PREFIX "orl %1,%0"
12422 + : "+m" (v->counter)
12423 + : "r" (mask)
12424 + : "memory");
12425 +}
12426 +
12427 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12428 +{
12429 + asm volatile(LOCK_PREFIX "orl %1,%0"
12430 + : "+m" (v->counter)
12431 + : "r" (mask)
12432 + : "memory");
12433 +}
12434
12435 /* Atomic operations are already serializing on x86 */
12436 #define smp_mb__before_atomic_dec() barrier()
12437 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12438 index b154de7..aadebd8 100644
12439 --- a/arch/x86/include/asm/atomic64_32.h
12440 +++ b/arch/x86/include/asm/atomic64_32.h
12441 @@ -12,6 +12,14 @@ typedef struct {
12442 u64 __aligned(8) counter;
12443 } atomic64_t;
12444
12445 +#ifdef CONFIG_PAX_REFCOUNT
12446 +typedef struct {
12447 + u64 __aligned(8) counter;
12448 +} atomic64_unchecked_t;
12449 +#else
12450 +typedef atomic64_t atomic64_unchecked_t;
12451 +#endif
12452 +
12453 #define ATOMIC64_INIT(val) { (val) }
12454
12455 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12456 @@ -37,21 +45,31 @@ typedef struct {
12457 ATOMIC64_DECL_ONE(sym##_386)
12458
12459 ATOMIC64_DECL_ONE(add_386);
12460 +ATOMIC64_DECL_ONE(add_unchecked_386);
12461 ATOMIC64_DECL_ONE(sub_386);
12462 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12463 ATOMIC64_DECL_ONE(inc_386);
12464 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12465 ATOMIC64_DECL_ONE(dec_386);
12466 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12467 #endif
12468
12469 #define alternative_atomic64(f, out, in...) \
12470 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12471
12472 ATOMIC64_DECL(read);
12473 +ATOMIC64_DECL(read_unchecked);
12474 ATOMIC64_DECL(set);
12475 +ATOMIC64_DECL(set_unchecked);
12476 ATOMIC64_DECL(xchg);
12477 ATOMIC64_DECL(add_return);
12478 +ATOMIC64_DECL(add_return_unchecked);
12479 ATOMIC64_DECL(sub_return);
12480 +ATOMIC64_DECL(sub_return_unchecked);
12481 ATOMIC64_DECL(inc_return);
12482 +ATOMIC64_DECL(inc_return_unchecked);
12483 ATOMIC64_DECL(dec_return);
12484 +ATOMIC64_DECL(dec_return_unchecked);
12485 ATOMIC64_DECL(dec_if_positive);
12486 ATOMIC64_DECL(inc_not_zero);
12487 ATOMIC64_DECL(add_unless);
12488 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12489 }
12490
12491 /**
12492 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12493 + * @p: pointer to type atomic64_unchecked_t
12494 + * @o: expected value
12495 + * @n: new value
12496 + *
12497 + * Atomically sets @v to @n if it was equal to @o and returns
12498 + * the old value.
12499 + */
12500 +
12501 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12502 +{
12503 + return cmpxchg64(&v->counter, o, n);
12504 +}
12505 +
12506 +/**
12507 * atomic64_xchg - xchg atomic64 variable
12508 * @v: pointer to type atomic64_t
12509 * @n: value to assign
12510 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12511 }
12512
12513 /**
12514 + * atomic64_set_unchecked - set atomic64 variable
12515 + * @v: pointer to type atomic64_unchecked_t
12516 + * @n: value to assign
12517 + *
12518 + * Atomically sets the value of @v to @n.
12519 + */
12520 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12521 +{
12522 + unsigned high = (unsigned)(i >> 32);
12523 + unsigned low = (unsigned)i;
12524 + alternative_atomic64(set, /* no output */,
12525 + "S" (v), "b" (low), "c" (high)
12526 + : "eax", "edx", "memory");
12527 +}
12528 +
12529 +/**
12530 * atomic64_read - read atomic64 variable
12531 * @v: pointer to type atomic64_t
12532 *
12533 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12534 }
12535
12536 /**
12537 + * atomic64_read_unchecked - read atomic64 variable
12538 + * @v: pointer to type atomic64_unchecked_t
12539 + *
12540 + * Atomically reads the value of @v and returns it.
12541 + */
12542 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12543 +{
12544 + long long r;
12545 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12546 + return r;
12547 + }
12548 +
12549 +/**
12550 * atomic64_add_return - add and return
12551 * @i: integer value to add
12552 * @v: pointer to type atomic64_t
12553 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12554 return i;
12555 }
12556
12557 +/**
12558 + * atomic64_add_return_unchecked - add and return
12559 + * @i: integer value to add
12560 + * @v: pointer to type atomic64_unchecked_t
12561 + *
12562 + * Atomically adds @i to @v and returns @i + *@v
12563 + */
12564 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12565 +{
12566 + alternative_atomic64(add_return_unchecked,
12567 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12568 + ASM_NO_INPUT_CLOBBER("memory"));
12569 + return i;
12570 +}
12571 +
12572 /*
12573 * Other variants with different arithmetic operators:
12574 */
12575 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12576 return a;
12577 }
12578
12579 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12580 +{
12581 + long long a;
12582 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12583 + "S" (v) : "memory", "ecx");
12584 + return a;
12585 +}
12586 +
12587 static inline long long atomic64_dec_return(atomic64_t *v)
12588 {
12589 long long a;
12590 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12591 }
12592
12593 /**
12594 + * atomic64_add_unchecked - add integer to atomic64 variable
12595 + * @i: integer value to add
12596 + * @v: pointer to type atomic64_unchecked_t
12597 + *
12598 + * Atomically adds @i to @v.
12599 + */
12600 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12601 +{
12602 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12603 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12604 + ASM_NO_INPUT_CLOBBER("memory"));
12605 + return i;
12606 +}
12607 +
12608 +/**
12609 * atomic64_sub - subtract the atomic64 variable
12610 * @i: integer value to subtract
12611 * @v: pointer to type atomic64_t
12612 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12613 index 0e1cbfc..5623683 100644
12614 --- a/arch/x86/include/asm/atomic64_64.h
12615 +++ b/arch/x86/include/asm/atomic64_64.h
12616 @@ -18,7 +18,19 @@
12617 */
12618 static inline long atomic64_read(const atomic64_t *v)
12619 {
12620 - return (*(volatile long *)&(v)->counter);
12621 + return (*(volatile const long *)&(v)->counter);
12622 +}
12623 +
12624 +/**
12625 + * atomic64_read_unchecked - read atomic64 variable
12626 + * @v: pointer of type atomic64_unchecked_t
12627 + *
12628 + * Atomically reads the value of @v.
12629 + * Doesn't imply a read memory barrier.
12630 + */
12631 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12632 +{
12633 + return (*(volatile const long *)&(v)->counter);
12634 }
12635
12636 /**
12637 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12638 }
12639
12640 /**
12641 + * atomic64_set_unchecked - set atomic64 variable
12642 + * @v: pointer to type atomic64_unchecked_t
12643 + * @i: required value
12644 + *
12645 + * Atomically sets the value of @v to @i.
12646 + */
12647 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12648 +{
12649 + v->counter = i;
12650 +}
12651 +
12652 +/**
12653 * atomic64_add - add integer to atomic64 variable
12654 * @i: integer value to add
12655 * @v: pointer to type atomic64_t
12656 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12657 */
12658 static inline void atomic64_add(long i, atomic64_t *v)
12659 {
12660 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12661 +
12662 +#ifdef CONFIG_PAX_REFCOUNT
12663 + "jno 0f\n"
12664 + LOCK_PREFIX "subq %1,%0\n"
12665 + "int $4\n0:\n"
12666 + _ASM_EXTABLE(0b, 0b)
12667 +#endif
12668 +
12669 + : "=m" (v->counter)
12670 + : "er" (i), "m" (v->counter));
12671 +}
12672 +
12673 +/**
12674 + * atomic64_add_unchecked - add integer to atomic64 variable
12675 + * @i: integer value to add
12676 + * @v: pointer to type atomic64_unchecked_t
12677 + *
12678 + * Atomically adds @i to @v.
12679 + */
12680 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12681 +{
12682 asm volatile(LOCK_PREFIX "addq %1,%0"
12683 : "=m" (v->counter)
12684 : "er" (i), "m" (v->counter));
12685 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12686 */
12687 static inline void atomic64_sub(long i, atomic64_t *v)
12688 {
12689 - asm volatile(LOCK_PREFIX "subq %1,%0"
12690 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12691 +
12692 +#ifdef CONFIG_PAX_REFCOUNT
12693 + "jno 0f\n"
12694 + LOCK_PREFIX "addq %1,%0\n"
12695 + "int $4\n0:\n"
12696 + _ASM_EXTABLE(0b, 0b)
12697 +#endif
12698 +
12699 + : "=m" (v->counter)
12700 + : "er" (i), "m" (v->counter));
12701 +}
12702 +
12703 +/**
12704 + * atomic64_sub_unchecked - subtract the atomic64 variable
12705 + * @i: integer value to subtract
12706 + * @v: pointer to type atomic64_unchecked_t
12707 + *
12708 + * Atomically subtracts @i from @v.
12709 + */
12710 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12711 +{
12712 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12713 : "=m" (v->counter)
12714 : "er" (i), "m" (v->counter));
12715 }
12716 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12717 {
12718 unsigned char c;
12719
12720 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12721 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12722 +
12723 +#ifdef CONFIG_PAX_REFCOUNT
12724 + "jno 0f\n"
12725 + LOCK_PREFIX "addq %2,%0\n"
12726 + "int $4\n0:\n"
12727 + _ASM_EXTABLE(0b, 0b)
12728 +#endif
12729 +
12730 + "sete %1\n"
12731 : "=m" (v->counter), "=qm" (c)
12732 : "er" (i), "m" (v->counter) : "memory");
12733 return c;
12734 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12735 */
12736 static inline void atomic64_inc(atomic64_t *v)
12737 {
12738 + asm volatile(LOCK_PREFIX "incq %0\n"
12739 +
12740 +#ifdef CONFIG_PAX_REFCOUNT
12741 + "jno 0f\n"
12742 + LOCK_PREFIX "decq %0\n"
12743 + "int $4\n0:\n"
12744 + _ASM_EXTABLE(0b, 0b)
12745 +#endif
12746 +
12747 + : "=m" (v->counter)
12748 + : "m" (v->counter));
12749 +}
12750 +
12751 +/**
12752 + * atomic64_inc_unchecked - increment atomic64 variable
12753 + * @v: pointer to type atomic64_unchecked_t
12754 + *
12755 + * Atomically increments @v by 1.
12756 + */
12757 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12758 +{
12759 asm volatile(LOCK_PREFIX "incq %0"
12760 : "=m" (v->counter)
12761 : "m" (v->counter));
12762 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12763 */
12764 static inline void atomic64_dec(atomic64_t *v)
12765 {
12766 - asm volatile(LOCK_PREFIX "decq %0"
12767 + asm volatile(LOCK_PREFIX "decq %0\n"
12768 +
12769 +#ifdef CONFIG_PAX_REFCOUNT
12770 + "jno 0f\n"
12771 + LOCK_PREFIX "incq %0\n"
12772 + "int $4\n0:\n"
12773 + _ASM_EXTABLE(0b, 0b)
12774 +#endif
12775 +
12776 + : "=m" (v->counter)
12777 + : "m" (v->counter));
12778 +}
12779 +
12780 +/**
12781 + * atomic64_dec_unchecked - decrement atomic64 variable
12782 + * @v: pointer to type atomic64_t
12783 + *
12784 + * Atomically decrements @v by 1.
12785 + */
12786 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12787 +{
12788 + asm volatile(LOCK_PREFIX "decq %0\n"
12789 : "=m" (v->counter)
12790 : "m" (v->counter));
12791 }
12792 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12793 {
12794 unsigned char c;
12795
12796 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12797 + asm volatile(LOCK_PREFIX "decq %0\n"
12798 +
12799 +#ifdef CONFIG_PAX_REFCOUNT
12800 + "jno 0f\n"
12801 + LOCK_PREFIX "incq %0\n"
12802 + "int $4\n0:\n"
12803 + _ASM_EXTABLE(0b, 0b)
12804 +#endif
12805 +
12806 + "sete %1\n"
12807 : "=m" (v->counter), "=qm" (c)
12808 : "m" (v->counter) : "memory");
12809 return c != 0;
12810 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12811 {
12812 unsigned char c;
12813
12814 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12815 + asm volatile(LOCK_PREFIX "incq %0\n"
12816 +
12817 +#ifdef CONFIG_PAX_REFCOUNT
12818 + "jno 0f\n"
12819 + LOCK_PREFIX "decq %0\n"
12820 + "int $4\n0:\n"
12821 + _ASM_EXTABLE(0b, 0b)
12822 +#endif
12823 +
12824 + "sete %1\n"
12825 : "=m" (v->counter), "=qm" (c)
12826 : "m" (v->counter) : "memory");
12827 return c != 0;
12828 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12829 {
12830 unsigned char c;
12831
12832 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12833 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12834 +
12835 +#ifdef CONFIG_PAX_REFCOUNT
12836 + "jno 0f\n"
12837 + LOCK_PREFIX "subq %2,%0\n"
12838 + "int $4\n0:\n"
12839 + _ASM_EXTABLE(0b, 0b)
12840 +#endif
12841 +
12842 + "sets %1\n"
12843 : "=m" (v->counter), "=qm" (c)
12844 : "er" (i), "m" (v->counter) : "memory");
12845 return c;
12846 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12847 */
12848 static inline long atomic64_add_return(long i, atomic64_t *v)
12849 {
12850 + return i + xadd_check_overflow(&v->counter, i);
12851 +}
12852 +
12853 +/**
12854 + * atomic64_add_return_unchecked - add and return
12855 + * @i: integer value to add
12856 + * @v: pointer to type atomic64_unchecked_t
12857 + *
12858 + * Atomically adds @i to @v and returns @i + @v
12859 + */
12860 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12861 +{
12862 return i + xadd(&v->counter, i);
12863 }
12864
12865 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12866 }
12867
12868 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12869 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12870 +{
12871 + return atomic64_add_return_unchecked(1, v);
12872 +}
12873 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12874
12875 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12876 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12877 return cmpxchg(&v->counter, old, new);
12878 }
12879
12880 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12881 +{
12882 + return cmpxchg(&v->counter, old, new);
12883 +}
12884 +
12885 static inline long atomic64_xchg(atomic64_t *v, long new)
12886 {
12887 return xchg(&v->counter, new);
12888 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12889 */
12890 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12891 {
12892 - long c, old;
12893 + long c, old, new;
12894 c = atomic64_read(v);
12895 for (;;) {
12896 - if (unlikely(c == (u)))
12897 + if (unlikely(c == u))
12898 break;
12899 - old = atomic64_cmpxchg((v), c, c + (a));
12900 +
12901 + asm volatile("add %2,%0\n"
12902 +
12903 +#ifdef CONFIG_PAX_REFCOUNT
12904 + "jno 0f\n"
12905 + "sub %2,%0\n"
12906 + "int $4\n0:\n"
12907 + _ASM_EXTABLE(0b, 0b)
12908 +#endif
12909 +
12910 + : "=r" (new)
12911 + : "0" (c), "ir" (a));
12912 +
12913 + old = atomic64_cmpxchg(v, c, new);
12914 if (likely(old == c))
12915 break;
12916 c = old;
12917 }
12918 - return c != (u);
12919 + return c != u;
12920 }
12921
12922 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12923 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12924 index 6dfd019..28e188d 100644
12925 --- a/arch/x86/include/asm/bitops.h
12926 +++ b/arch/x86/include/asm/bitops.h
12927 @@ -40,7 +40,7 @@
12928 * a mask operation on a byte.
12929 */
12930 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12931 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12932 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12933 #define CONST_MASK(nr) (1 << ((nr) & 7))
12934
12935 /**
12936 @@ -486,7 +486,7 @@ static inline int fls(int x)
12937 * at position 64.
12938 */
12939 #ifdef CONFIG_X86_64
12940 -static __always_inline int fls64(__u64 x)
12941 +static __always_inline long fls64(__u64 x)
12942 {
12943 int bitpos = -1;
12944 /*
12945 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12946 index 4fa687a..60f2d39 100644
12947 --- a/arch/x86/include/asm/boot.h
12948 +++ b/arch/x86/include/asm/boot.h
12949 @@ -6,10 +6,15 @@
12950 #include <uapi/asm/boot.h>
12951
12952 /* Physical address where kernel should be loaded. */
12953 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12954 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12955 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12956 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12957
12958 +#ifndef __ASSEMBLY__
12959 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12960 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12961 +#endif
12962 +
12963 /* Minimum kernel alignment, as a power of two */
12964 #ifdef CONFIG_X86_64
12965 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12966 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12967 index 48f99f1..d78ebf9 100644
12968 --- a/arch/x86/include/asm/cache.h
12969 +++ b/arch/x86/include/asm/cache.h
12970 @@ -5,12 +5,13 @@
12971
12972 /* L1 cache line size */
12973 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12974 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12975 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12976
12977 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12978 +#define __read_only __attribute__((__section__(".data..read_only")))
12979
12980 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12981 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12982 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12983
12984 #ifdef CONFIG_X86_VSMP
12985 #ifdef CONFIG_SMP
12986 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12987 index 9863ee3..4a1f8e1 100644
12988 --- a/arch/x86/include/asm/cacheflush.h
12989 +++ b/arch/x86/include/asm/cacheflush.h
12990 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12991 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12992
12993 if (pg_flags == _PGMT_DEFAULT)
12994 - return -1;
12995 + return ~0UL;
12996 else if (pg_flags == _PGMT_WC)
12997 return _PAGE_CACHE_WC;
12998 else if (pg_flags == _PGMT_UC_MINUS)
12999 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13000 index 46fc474..b02b0f9 100644
13001 --- a/arch/x86/include/asm/checksum_32.h
13002 +++ b/arch/x86/include/asm/checksum_32.h
13003 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13004 int len, __wsum sum,
13005 int *src_err_ptr, int *dst_err_ptr);
13006
13007 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13008 + int len, __wsum sum,
13009 + int *src_err_ptr, int *dst_err_ptr);
13010 +
13011 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13012 + int len, __wsum sum,
13013 + int *src_err_ptr, int *dst_err_ptr);
13014 +
13015 /*
13016 * Note: when you get a NULL pointer exception here this means someone
13017 * passed in an incorrect kernel address to one of these functions.
13018 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13019 int *err_ptr)
13020 {
13021 might_sleep();
13022 - return csum_partial_copy_generic((__force void *)src, dst,
13023 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13024 len, sum, err_ptr, NULL);
13025 }
13026
13027 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13028 {
13029 might_sleep();
13030 if (access_ok(VERIFY_WRITE, dst, len))
13031 - return csum_partial_copy_generic(src, (__force void *)dst,
13032 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13033 len, sum, NULL, err_ptr);
13034
13035 if (len)
13036 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13037 index d47786a..ce1b05d 100644
13038 --- a/arch/x86/include/asm/cmpxchg.h
13039 +++ b/arch/x86/include/asm/cmpxchg.h
13040 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13041 __compiletime_error("Bad argument size for cmpxchg");
13042 extern void __xadd_wrong_size(void)
13043 __compiletime_error("Bad argument size for xadd");
13044 +extern void __xadd_check_overflow_wrong_size(void)
13045 + __compiletime_error("Bad argument size for xadd_check_overflow");
13046 extern void __add_wrong_size(void)
13047 __compiletime_error("Bad argument size for add");
13048 +extern void __add_check_overflow_wrong_size(void)
13049 + __compiletime_error("Bad argument size for add_check_overflow");
13050
13051 /*
13052 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13053 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13054 __ret; \
13055 })
13056
13057 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13058 + ({ \
13059 + __typeof__ (*(ptr)) __ret = (arg); \
13060 + switch (sizeof(*(ptr))) { \
13061 + case __X86_CASE_L: \
13062 + asm volatile (lock #op "l %0, %1\n" \
13063 + "jno 0f\n" \
13064 + "mov %0,%1\n" \
13065 + "int $4\n0:\n" \
13066 + _ASM_EXTABLE(0b, 0b) \
13067 + : "+r" (__ret), "+m" (*(ptr)) \
13068 + : : "memory", "cc"); \
13069 + break; \
13070 + case __X86_CASE_Q: \
13071 + asm volatile (lock #op "q %q0, %1\n" \
13072 + "jno 0f\n" \
13073 + "mov %0,%1\n" \
13074 + "int $4\n0:\n" \
13075 + _ASM_EXTABLE(0b, 0b) \
13076 + : "+r" (__ret), "+m" (*(ptr)) \
13077 + : : "memory", "cc"); \
13078 + break; \
13079 + default: \
13080 + __ ## op ## _check_overflow_wrong_size(); \
13081 + } \
13082 + __ret; \
13083 + })
13084 +
13085 /*
13086 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13087 * Since this is generally used to protect other memory information, we
13088 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13089 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13090 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13091
13092 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13093 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13094 +
13095 #define __add(ptr, inc, lock) \
13096 ({ \
13097 __typeof__ (*(ptr)) __ret = (inc); \
13098 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13099 index 59c6c40..5e0b22c 100644
13100 --- a/arch/x86/include/asm/compat.h
13101 +++ b/arch/x86/include/asm/compat.h
13102 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13103 typedef u32 compat_uint_t;
13104 typedef u32 compat_ulong_t;
13105 typedef u64 __attribute__((aligned(4))) compat_u64;
13106 -typedef u32 compat_uptr_t;
13107 +typedef u32 __user compat_uptr_t;
13108
13109 struct compat_timespec {
13110 compat_time_t tv_sec;
13111 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13112 index e99ac27..e89e28c 100644
13113 --- a/arch/x86/include/asm/cpufeature.h
13114 +++ b/arch/x86/include/asm/cpufeature.h
13115 @@ -211,7 +211,7 @@
13116 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13117 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13118 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13119 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13120 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13121 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13122 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13123 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13124 @@ -394,7 +394,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13125 ".section .discard,\"aw\",@progbits\n"
13126 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13127 ".previous\n"
13128 - ".section .altinstr_replacement,\"ax\"\n"
13129 + ".section .altinstr_replacement,\"a\"\n"
13130 "3: movb $1,%0\n"
13131 "4:\n"
13132 ".previous\n"
13133 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13134 index 8bf1c06..b6ae785 100644
13135 --- a/arch/x86/include/asm/desc.h
13136 +++ b/arch/x86/include/asm/desc.h
13137 @@ -4,6 +4,7 @@
13138 #include <asm/desc_defs.h>
13139 #include <asm/ldt.h>
13140 #include <asm/mmu.h>
13141 +#include <asm/pgtable.h>
13142
13143 #include <linux/smp.h>
13144 #include <linux/percpu.h>
13145 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13146
13147 desc->type = (info->read_exec_only ^ 1) << 1;
13148 desc->type |= info->contents << 2;
13149 + desc->type |= info->seg_not_present ^ 1;
13150
13151 desc->s = 1;
13152 desc->dpl = 0x3;
13153 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13154 }
13155
13156 extern struct desc_ptr idt_descr;
13157 -extern gate_desc idt_table[];
13158 extern struct desc_ptr nmi_idt_descr;
13159 -extern gate_desc nmi_idt_table[];
13160 -
13161 -struct gdt_page {
13162 - struct desc_struct gdt[GDT_ENTRIES];
13163 -} __attribute__((aligned(PAGE_SIZE)));
13164 -
13165 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13166 +extern gate_desc idt_table[256];
13167 +extern gate_desc nmi_idt_table[256];
13168
13169 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13170 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13171 {
13172 - return per_cpu(gdt_page, cpu).gdt;
13173 + return cpu_gdt_table[cpu];
13174 }
13175
13176 #ifdef CONFIG_X86_64
13177 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13178 unsigned long base, unsigned dpl, unsigned flags,
13179 unsigned short seg)
13180 {
13181 - gate->a = (seg << 16) | (base & 0xffff);
13182 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13183 + gate->gate.offset_low = base;
13184 + gate->gate.seg = seg;
13185 + gate->gate.reserved = 0;
13186 + gate->gate.type = type;
13187 + gate->gate.s = 0;
13188 + gate->gate.dpl = dpl;
13189 + gate->gate.p = 1;
13190 + gate->gate.offset_high = base >> 16;
13191 }
13192
13193 #endif
13194 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13195
13196 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13197 {
13198 + pax_open_kernel();
13199 memcpy(&idt[entry], gate, sizeof(*gate));
13200 + pax_close_kernel();
13201 }
13202
13203 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13204 {
13205 + pax_open_kernel();
13206 memcpy(&ldt[entry], desc, 8);
13207 + pax_close_kernel();
13208 }
13209
13210 static inline void
13211 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13212 default: size = sizeof(*gdt); break;
13213 }
13214
13215 + pax_open_kernel();
13216 memcpy(&gdt[entry], desc, size);
13217 + pax_close_kernel();
13218 }
13219
13220 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13221 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13222
13223 static inline void native_load_tr_desc(void)
13224 {
13225 + pax_open_kernel();
13226 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13227 + pax_close_kernel();
13228 }
13229
13230 static inline void native_load_gdt(const struct desc_ptr *dtr)
13231 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13232 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13233 unsigned int i;
13234
13235 + pax_open_kernel();
13236 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13237 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13238 + pax_close_kernel();
13239 }
13240
13241 #define _LDT_empty(info) \
13242 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13243 preempt_enable();
13244 }
13245
13246 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13247 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13248 {
13249 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13250 }
13251 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13252 }
13253
13254 #ifdef CONFIG_X86_64
13255 -static inline void set_nmi_gate(int gate, void *addr)
13256 +static inline void set_nmi_gate(int gate, const void *addr)
13257 {
13258 gate_desc s;
13259
13260 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13261 }
13262 #endif
13263
13264 -static inline void _set_gate(int gate, unsigned type, void *addr,
13265 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13266 unsigned dpl, unsigned ist, unsigned seg)
13267 {
13268 gate_desc s;
13269 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13270 * Pentium F0 0F bugfix can have resulted in the mapped
13271 * IDT being write-protected.
13272 */
13273 -static inline void set_intr_gate(unsigned int n, void *addr)
13274 +static inline void set_intr_gate(unsigned int n, const void *addr)
13275 {
13276 BUG_ON((unsigned)n > 0xFF);
13277 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13278 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13279 /*
13280 * This routine sets up an interrupt gate at directory privilege level 3.
13281 */
13282 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13283 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13284 {
13285 BUG_ON((unsigned)n > 0xFF);
13286 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13287 }
13288
13289 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13290 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13291 {
13292 BUG_ON((unsigned)n > 0xFF);
13293 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13294 }
13295
13296 -static inline void set_trap_gate(unsigned int n, void *addr)
13297 +static inline void set_trap_gate(unsigned int n, const void *addr)
13298 {
13299 BUG_ON((unsigned)n > 0xFF);
13300 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13301 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13302 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13303 {
13304 BUG_ON((unsigned)n > 0xFF);
13305 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13306 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13307 }
13308
13309 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13310 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13311 {
13312 BUG_ON((unsigned)n > 0xFF);
13313 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13314 }
13315
13316 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13317 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13318 {
13319 BUG_ON((unsigned)n > 0xFF);
13320 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13321 }
13322
13323 +#ifdef CONFIG_X86_32
13324 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13325 +{
13326 + struct desc_struct d;
13327 +
13328 + if (likely(limit))
13329 + limit = (limit - 1UL) >> PAGE_SHIFT;
13330 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13331 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13332 +}
13333 +#endif
13334 +
13335 #endif /* _ASM_X86_DESC_H */
13336 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13337 index 278441f..b95a174 100644
13338 --- a/arch/x86/include/asm/desc_defs.h
13339 +++ b/arch/x86/include/asm/desc_defs.h
13340 @@ -31,6 +31,12 @@ struct desc_struct {
13341 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13342 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13343 };
13344 + struct {
13345 + u16 offset_low;
13346 + u16 seg;
13347 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13348 + unsigned offset_high: 16;
13349 + } gate;
13350 };
13351 } __attribute__((packed));
13352
13353 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13354 index ced283a..ffe04cc 100644
13355 --- a/arch/x86/include/asm/div64.h
13356 +++ b/arch/x86/include/asm/div64.h
13357 @@ -39,7 +39,7 @@
13358 __mod; \
13359 })
13360
13361 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13362 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13363 {
13364 union {
13365 u64 v64;
13366 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13367 index 9c999c1..3860cb8 100644
13368 --- a/arch/x86/include/asm/elf.h
13369 +++ b/arch/x86/include/asm/elf.h
13370 @@ -243,7 +243,25 @@ extern int force_personality32;
13371 the loader. We need to make sure that it is out of the way of the program
13372 that it will "exec", and that there is sufficient room for the brk. */
13373
13374 +#ifdef CONFIG_PAX_SEGMEXEC
13375 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13376 +#else
13377 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13378 +#endif
13379 +
13380 +#ifdef CONFIG_PAX_ASLR
13381 +#ifdef CONFIG_X86_32
13382 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13383 +
13384 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13385 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13386 +#else
13387 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13388 +
13389 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13390 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13391 +#endif
13392 +#endif
13393
13394 /* This yields a mask that user programs can use to figure out what
13395 instruction set this CPU supports. This could be done in user space,
13396 @@ -296,16 +314,12 @@ do { \
13397
13398 #define ARCH_DLINFO \
13399 do { \
13400 - if (vdso_enabled) \
13401 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13402 - (unsigned long)current->mm->context.vdso); \
13403 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13404 } while (0)
13405
13406 #define ARCH_DLINFO_X32 \
13407 do { \
13408 - if (vdso_enabled) \
13409 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13410 - (unsigned long)current->mm->context.vdso); \
13411 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13412 } while (0)
13413
13414 #define AT_SYSINFO 32
13415 @@ -320,7 +334,7 @@ else \
13416
13417 #endif /* !CONFIG_X86_32 */
13418
13419 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13420 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13421
13422 #define VDSO_ENTRY \
13423 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13424 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13425 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13426 #define compat_arch_setup_additional_pages syscall32_setup_pages
13427
13428 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13429 -#define arch_randomize_brk arch_randomize_brk
13430 -
13431 /*
13432 * True on X86_32 or when emulating IA32 on X86_64
13433 */
13434 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13435 index 75ce3f4..882e801 100644
13436 --- a/arch/x86/include/asm/emergency-restart.h
13437 +++ b/arch/x86/include/asm/emergency-restart.h
13438 @@ -13,6 +13,6 @@ enum reboot_type {
13439
13440 extern enum reboot_type reboot_type;
13441
13442 -extern void machine_emergency_restart(void);
13443 +extern void machine_emergency_restart(void) __noreturn;
13444
13445 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13446 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13447 index e25cc33..425d099 100644
13448 --- a/arch/x86/include/asm/fpu-internal.h
13449 +++ b/arch/x86/include/asm/fpu-internal.h
13450 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13451 ({ \
13452 int err; \
13453 asm volatile(ASM_STAC "\n" \
13454 - "1:" #insn "\n\t" \
13455 + "1:" \
13456 + __copyuser_seg \
13457 + #insn "\n\t" \
13458 "2: " ASM_CLAC "\n" \
13459 ".section .fixup,\"ax\"\n" \
13460 "3: movl $-1,%[err]\n" \
13461 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13462 "emms\n\t" /* clear stack tags */
13463 "fildl %P[addr]", /* set F?P to defined value */
13464 X86_FEATURE_FXSAVE_LEAK,
13465 - [addr] "m" (tsk->thread.fpu.has_fpu));
13466 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13467
13468 return fpu_restore_checking(&tsk->thread.fpu);
13469 }
13470 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13471 index be27ba1..8f13ff9 100644
13472 --- a/arch/x86/include/asm/futex.h
13473 +++ b/arch/x86/include/asm/futex.h
13474 @@ -12,6 +12,7 @@
13475 #include <asm/smap.h>
13476
13477 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13478 + typecheck(u32 __user *, uaddr); \
13479 asm volatile("\t" ASM_STAC "\n" \
13480 "1:\t" insn "\n" \
13481 "2:\t" ASM_CLAC "\n" \
13482 @@ -20,15 +21,16 @@
13483 "\tjmp\t2b\n" \
13484 "\t.previous\n" \
13485 _ASM_EXTABLE(1b, 3b) \
13486 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13487 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13488 : "i" (-EFAULT), "0" (oparg), "1" (0))
13489
13490 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13491 + typecheck(u32 __user *, uaddr); \
13492 asm volatile("\t" ASM_STAC "\n" \
13493 "1:\tmovl %2, %0\n" \
13494 "\tmovl\t%0, %3\n" \
13495 "\t" insn "\n" \
13496 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13497 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13498 "\tjnz\t1b\n" \
13499 "3:\t" ASM_CLAC "\n" \
13500 "\t.section .fixup,\"ax\"\n" \
13501 @@ -38,7 +40,7 @@
13502 _ASM_EXTABLE(1b, 4b) \
13503 _ASM_EXTABLE(2b, 4b) \
13504 : "=&a" (oldval), "=&r" (ret), \
13505 - "+m" (*uaddr), "=&r" (tem) \
13506 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13507 : "r" (oparg), "i" (-EFAULT), "1" (0))
13508
13509 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13510 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13511
13512 switch (op) {
13513 case FUTEX_OP_SET:
13514 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13515 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13516 break;
13517 case FUTEX_OP_ADD:
13518 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13519 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13520 uaddr, oparg);
13521 break;
13522 case FUTEX_OP_OR:
13523 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13524 return -EFAULT;
13525
13526 asm volatile("\t" ASM_STAC "\n"
13527 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13528 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13529 "2:\t" ASM_CLAC "\n"
13530 "\t.section .fixup, \"ax\"\n"
13531 "3:\tmov %3, %0\n"
13532 "\tjmp 2b\n"
13533 "\t.previous\n"
13534 _ASM_EXTABLE(1b, 3b)
13535 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13536 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13537 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13538 : "memory"
13539 );
13540 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13541 index 1da97ef..9c2ebff 100644
13542 --- a/arch/x86/include/asm/hw_irq.h
13543 +++ b/arch/x86/include/asm/hw_irq.h
13544 @@ -148,8 +148,8 @@ extern void setup_ioapic_dest(void);
13545 extern void enable_IO_APIC(void);
13546
13547 /* Statistics */
13548 -extern atomic_t irq_err_count;
13549 -extern atomic_t irq_mis_count;
13550 +extern atomic_unchecked_t irq_err_count;
13551 +extern atomic_unchecked_t irq_mis_count;
13552
13553 /* EISA */
13554 extern void eisa_set_level_irq(unsigned int irq);
13555 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13556 index a203659..9889f1c 100644
13557 --- a/arch/x86/include/asm/i8259.h
13558 +++ b/arch/x86/include/asm/i8259.h
13559 @@ -62,7 +62,7 @@ struct legacy_pic {
13560 void (*init)(int auto_eoi);
13561 int (*irq_pending)(unsigned int irq);
13562 void (*make_irq)(unsigned int irq);
13563 -};
13564 +} __do_const;
13565
13566 extern struct legacy_pic *legacy_pic;
13567 extern struct legacy_pic null_legacy_pic;
13568 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13569 index d8e8eef..1765f78 100644
13570 --- a/arch/x86/include/asm/io.h
13571 +++ b/arch/x86/include/asm/io.h
13572 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13573 "m" (*(volatile type __force *)addr) barrier); }
13574
13575 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13576 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13577 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13578 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13579 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13580
13581 build_mmio_read(__readb, "b", unsigned char, "=q", )
13582 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13583 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13584 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13585 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13586
13587 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13588 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13589 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13590 return ioremap_nocache(offset, size);
13591 }
13592
13593 -extern void iounmap(volatile void __iomem *addr);
13594 +extern void iounmap(const volatile void __iomem *addr);
13595
13596 extern void set_iounmap_nonlazy(void);
13597
13598 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13599
13600 #include <linux/vmalloc.h>
13601
13602 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13603 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13604 +{
13605 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13606 +}
13607 +
13608 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13609 +{
13610 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13611 +}
13612 +
13613 /*
13614 * Convert a virtual cached pointer to an uncached pointer
13615 */
13616 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13617 index bba3cf8..06bc8da 100644
13618 --- a/arch/x86/include/asm/irqflags.h
13619 +++ b/arch/x86/include/asm/irqflags.h
13620 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13621 sti; \
13622 sysexit
13623
13624 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13625 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13626 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13627 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13628 +
13629 #else
13630 #define INTERRUPT_RETURN iret
13631 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13632 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13633 index 5a6d287..f815789 100644
13634 --- a/arch/x86/include/asm/kprobes.h
13635 +++ b/arch/x86/include/asm/kprobes.h
13636 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13637 #define RELATIVEJUMP_SIZE 5
13638 #define RELATIVECALL_OPCODE 0xe8
13639 #define RELATIVE_ADDR_SIZE 4
13640 -#define MAX_STACK_SIZE 64
13641 -#define MIN_STACK_SIZE(ADDR) \
13642 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13643 - THREAD_SIZE - (unsigned long)(ADDR))) \
13644 - ? (MAX_STACK_SIZE) \
13645 - : (((unsigned long)current_thread_info()) + \
13646 - THREAD_SIZE - (unsigned long)(ADDR)))
13647 +#define MAX_STACK_SIZE 64UL
13648 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13649
13650 #define flush_insn_slot(p) do { } while (0)
13651
13652 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13653 index 2d89e39..baee879 100644
13654 --- a/arch/x86/include/asm/local.h
13655 +++ b/arch/x86/include/asm/local.h
13656 @@ -10,33 +10,97 @@ typedef struct {
13657 atomic_long_t a;
13658 } local_t;
13659
13660 +typedef struct {
13661 + atomic_long_unchecked_t a;
13662 +} local_unchecked_t;
13663 +
13664 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13665
13666 #define local_read(l) atomic_long_read(&(l)->a)
13667 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13668 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13669 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13670
13671 static inline void local_inc(local_t *l)
13672 {
13673 - asm volatile(_ASM_INC "%0"
13674 + asm volatile(_ASM_INC "%0\n"
13675 +
13676 +#ifdef CONFIG_PAX_REFCOUNT
13677 + "jno 0f\n"
13678 + _ASM_DEC "%0\n"
13679 + "int $4\n0:\n"
13680 + _ASM_EXTABLE(0b, 0b)
13681 +#endif
13682 +
13683 + : "+m" (l->a.counter));
13684 +}
13685 +
13686 +static inline void local_inc_unchecked(local_unchecked_t *l)
13687 +{
13688 + asm volatile(_ASM_INC "%0\n"
13689 : "+m" (l->a.counter));
13690 }
13691
13692 static inline void local_dec(local_t *l)
13693 {
13694 - asm volatile(_ASM_DEC "%0"
13695 + asm volatile(_ASM_DEC "%0\n"
13696 +
13697 +#ifdef CONFIG_PAX_REFCOUNT
13698 + "jno 0f\n"
13699 + _ASM_INC "%0\n"
13700 + "int $4\n0:\n"
13701 + _ASM_EXTABLE(0b, 0b)
13702 +#endif
13703 +
13704 + : "+m" (l->a.counter));
13705 +}
13706 +
13707 +static inline void local_dec_unchecked(local_unchecked_t *l)
13708 +{
13709 + asm volatile(_ASM_DEC "%0\n"
13710 : "+m" (l->a.counter));
13711 }
13712
13713 static inline void local_add(long i, local_t *l)
13714 {
13715 - asm volatile(_ASM_ADD "%1,%0"
13716 + asm volatile(_ASM_ADD "%1,%0\n"
13717 +
13718 +#ifdef CONFIG_PAX_REFCOUNT
13719 + "jno 0f\n"
13720 + _ASM_SUB "%1,%0\n"
13721 + "int $4\n0:\n"
13722 + _ASM_EXTABLE(0b, 0b)
13723 +#endif
13724 +
13725 + : "+m" (l->a.counter)
13726 + : "ir" (i));
13727 +}
13728 +
13729 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13730 +{
13731 + asm volatile(_ASM_ADD "%1,%0\n"
13732 : "+m" (l->a.counter)
13733 : "ir" (i));
13734 }
13735
13736 static inline void local_sub(long i, local_t *l)
13737 {
13738 - asm volatile(_ASM_SUB "%1,%0"
13739 + asm volatile(_ASM_SUB "%1,%0\n"
13740 +
13741 +#ifdef CONFIG_PAX_REFCOUNT
13742 + "jno 0f\n"
13743 + _ASM_ADD "%1,%0\n"
13744 + "int $4\n0:\n"
13745 + _ASM_EXTABLE(0b, 0b)
13746 +#endif
13747 +
13748 + : "+m" (l->a.counter)
13749 + : "ir" (i));
13750 +}
13751 +
13752 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13753 +{
13754 + asm volatile(_ASM_SUB "%1,%0\n"
13755 : "+m" (l->a.counter)
13756 : "ir" (i));
13757 }
13758 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13759 {
13760 unsigned char c;
13761
13762 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13763 + asm volatile(_ASM_SUB "%2,%0\n"
13764 +
13765 +#ifdef CONFIG_PAX_REFCOUNT
13766 + "jno 0f\n"
13767 + _ASM_ADD "%2,%0\n"
13768 + "int $4\n0:\n"
13769 + _ASM_EXTABLE(0b, 0b)
13770 +#endif
13771 +
13772 + "sete %1\n"
13773 : "+m" (l->a.counter), "=qm" (c)
13774 : "ir" (i) : "memory");
13775 return c;
13776 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13777 {
13778 unsigned char c;
13779
13780 - asm volatile(_ASM_DEC "%0; sete %1"
13781 + asm volatile(_ASM_DEC "%0\n"
13782 +
13783 +#ifdef CONFIG_PAX_REFCOUNT
13784 + "jno 0f\n"
13785 + _ASM_INC "%0\n"
13786 + "int $4\n0:\n"
13787 + _ASM_EXTABLE(0b, 0b)
13788 +#endif
13789 +
13790 + "sete %1\n"
13791 : "+m" (l->a.counter), "=qm" (c)
13792 : : "memory");
13793 return c != 0;
13794 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13795 {
13796 unsigned char c;
13797
13798 - asm volatile(_ASM_INC "%0; sete %1"
13799 + asm volatile(_ASM_INC "%0\n"
13800 +
13801 +#ifdef CONFIG_PAX_REFCOUNT
13802 + "jno 0f\n"
13803 + _ASM_DEC "%0\n"
13804 + "int $4\n0:\n"
13805 + _ASM_EXTABLE(0b, 0b)
13806 +#endif
13807 +
13808 + "sete %1\n"
13809 : "+m" (l->a.counter), "=qm" (c)
13810 : : "memory");
13811 return c != 0;
13812 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13813 {
13814 unsigned char c;
13815
13816 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13817 + asm volatile(_ASM_ADD "%2,%0\n"
13818 +
13819 +#ifdef CONFIG_PAX_REFCOUNT
13820 + "jno 0f\n"
13821 + _ASM_SUB "%2,%0\n"
13822 + "int $4\n0:\n"
13823 + _ASM_EXTABLE(0b, 0b)
13824 +#endif
13825 +
13826 + "sets %1\n"
13827 : "+m" (l->a.counter), "=qm" (c)
13828 : "ir" (i) : "memory");
13829 return c;
13830 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13831 static inline long local_add_return(long i, local_t *l)
13832 {
13833 long __i = i;
13834 + asm volatile(_ASM_XADD "%0, %1\n"
13835 +
13836 +#ifdef CONFIG_PAX_REFCOUNT
13837 + "jno 0f\n"
13838 + _ASM_MOV "%0,%1\n"
13839 + "int $4\n0:\n"
13840 + _ASM_EXTABLE(0b, 0b)
13841 +#endif
13842 +
13843 + : "+r" (i), "+m" (l->a.counter)
13844 + : : "memory");
13845 + return i + __i;
13846 +}
13847 +
13848 +/**
13849 + * local_add_return_unchecked - add and return
13850 + * @i: integer value to add
13851 + * @l: pointer to type local_unchecked_t
13852 + *
13853 + * Atomically adds @i to @l and returns @i + @l
13854 + */
13855 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13856 +{
13857 + long __i = i;
13858 asm volatile(_ASM_XADD "%0, %1;"
13859 : "+r" (i), "+m" (l->a.counter)
13860 : : "memory");
13861 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13862
13863 #define local_cmpxchg(l, o, n) \
13864 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13865 +#define local_cmpxchg_unchecked(l, o, n) \
13866 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13867 /* Always has a lock prefix */
13868 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13869
13870 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13871 new file mode 100644
13872 index 0000000..2bfd3ba
13873 --- /dev/null
13874 +++ b/arch/x86/include/asm/mman.h
13875 @@ -0,0 +1,15 @@
13876 +#ifndef _X86_MMAN_H
13877 +#define _X86_MMAN_H
13878 +
13879 +#include <uapi/asm/mman.h>
13880 +
13881 +#ifdef __KERNEL__
13882 +#ifndef __ASSEMBLY__
13883 +#ifdef CONFIG_X86_32
13884 +#define arch_mmap_check i386_mmap_check
13885 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13886 +#endif
13887 +#endif
13888 +#endif
13889 +
13890 +#endif /* X86_MMAN_H */
13891 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13892 index 5f55e69..e20bfb1 100644
13893 --- a/arch/x86/include/asm/mmu.h
13894 +++ b/arch/x86/include/asm/mmu.h
13895 @@ -9,7 +9,7 @@
13896 * we put the segment information here.
13897 */
13898 typedef struct {
13899 - void *ldt;
13900 + struct desc_struct *ldt;
13901 int size;
13902
13903 #ifdef CONFIG_X86_64
13904 @@ -18,7 +18,19 @@ typedef struct {
13905 #endif
13906
13907 struct mutex lock;
13908 - void *vdso;
13909 + unsigned long vdso;
13910 +
13911 +#ifdef CONFIG_X86_32
13912 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13913 + unsigned long user_cs_base;
13914 + unsigned long user_cs_limit;
13915 +
13916 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13917 + cpumask_t cpu_user_cs_mask;
13918 +#endif
13919 +
13920 +#endif
13921 +#endif
13922 } mm_context_t;
13923
13924 #ifdef CONFIG_SMP
13925 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13926 index cdbf367..adb37ac 100644
13927 --- a/arch/x86/include/asm/mmu_context.h
13928 +++ b/arch/x86/include/asm/mmu_context.h
13929 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13930
13931 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13932 {
13933 +
13934 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13935 + unsigned int i;
13936 + pgd_t *pgd;
13937 +
13938 + pax_open_kernel();
13939 + pgd = get_cpu_pgd(smp_processor_id());
13940 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13941 + set_pgd_batched(pgd+i, native_make_pgd(0));
13942 + pax_close_kernel();
13943 +#endif
13944 +
13945 #ifdef CONFIG_SMP
13946 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13947 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13948 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13949 struct task_struct *tsk)
13950 {
13951 unsigned cpu = smp_processor_id();
13952 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13953 + int tlbstate = TLBSTATE_OK;
13954 +#endif
13955
13956 if (likely(prev != next)) {
13957 #ifdef CONFIG_SMP
13958 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13959 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13960 +#endif
13961 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13962 this_cpu_write(cpu_tlbstate.active_mm, next);
13963 #endif
13964 cpumask_set_cpu(cpu, mm_cpumask(next));
13965
13966 /* Re-load page tables */
13967 +#ifdef CONFIG_PAX_PER_CPU_PGD
13968 + pax_open_kernel();
13969 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13970 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13971 + pax_close_kernel();
13972 + load_cr3(get_cpu_pgd(cpu));
13973 +#else
13974 load_cr3(next->pgd);
13975 +#endif
13976
13977 /* stop flush ipis for the previous mm */
13978 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13979 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13980 */
13981 if (unlikely(prev->context.ldt != next->context.ldt))
13982 load_LDT_nolock(&next->context);
13983 - }
13984 +
13985 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13986 + if (!(__supported_pte_mask & _PAGE_NX)) {
13987 + smp_mb__before_clear_bit();
13988 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13989 + smp_mb__after_clear_bit();
13990 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13991 + }
13992 +#endif
13993 +
13994 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13995 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13996 + prev->context.user_cs_limit != next->context.user_cs_limit))
13997 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13998 #ifdef CONFIG_SMP
13999 + else if (unlikely(tlbstate != TLBSTATE_OK))
14000 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14001 +#endif
14002 +#endif
14003 +
14004 + }
14005 else {
14006 +
14007 +#ifdef CONFIG_PAX_PER_CPU_PGD
14008 + pax_open_kernel();
14009 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14010 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14011 + pax_close_kernel();
14012 + load_cr3(get_cpu_pgd(cpu));
14013 +#endif
14014 +
14015 +#ifdef CONFIG_SMP
14016 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14017 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14018
14019 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14020 * tlb flush IPI delivery. We must reload CR3
14021 * to make sure to use no freed page tables.
14022 */
14023 +
14024 +#ifndef CONFIG_PAX_PER_CPU_PGD
14025 load_cr3(next->pgd);
14026 +#endif
14027 +
14028 load_LDT_nolock(&next->context);
14029 +
14030 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14031 + if (!(__supported_pte_mask & _PAGE_NX))
14032 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14033 +#endif
14034 +
14035 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14036 +#ifdef CONFIG_PAX_PAGEEXEC
14037 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14038 +#endif
14039 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14040 +#endif
14041 +
14042 }
14043 +#endif
14044 }
14045 -#endif
14046 }
14047
14048 #define activate_mm(prev, next) \
14049 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14050 index e3b7819..b257c64 100644
14051 --- a/arch/x86/include/asm/module.h
14052 +++ b/arch/x86/include/asm/module.h
14053 @@ -5,6 +5,7 @@
14054
14055 #ifdef CONFIG_X86_64
14056 /* X86_64 does not define MODULE_PROC_FAMILY */
14057 +#define MODULE_PROC_FAMILY ""
14058 #elif defined CONFIG_M486
14059 #define MODULE_PROC_FAMILY "486 "
14060 #elif defined CONFIG_M586
14061 @@ -57,8 +58,20 @@
14062 #error unknown processor family
14063 #endif
14064
14065 -#ifdef CONFIG_X86_32
14066 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14067 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14068 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14069 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14070 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14071 +#else
14072 +#define MODULE_PAX_KERNEXEC ""
14073 #endif
14074
14075 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14076 +#define MODULE_PAX_UDEREF "UDEREF "
14077 +#else
14078 +#define MODULE_PAX_UDEREF ""
14079 +#endif
14080 +
14081 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14082 +
14083 #endif /* _ASM_X86_MODULE_H */
14084 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14085 index 86f9301..b365cda 100644
14086 --- a/arch/x86/include/asm/nmi.h
14087 +++ b/arch/x86/include/asm/nmi.h
14088 @@ -40,11 +40,11 @@ struct nmiaction {
14089 nmi_handler_t handler;
14090 unsigned long flags;
14091 const char *name;
14092 -};
14093 +} __do_const;
14094
14095 #define register_nmi_handler(t, fn, fg, n, init...) \
14096 ({ \
14097 - static struct nmiaction init fn##_na = { \
14098 + static const struct nmiaction init fn##_na = { \
14099 .handler = (fn), \
14100 .name = (n), \
14101 .flags = (fg), \
14102 @@ -52,7 +52,7 @@ struct nmiaction {
14103 __register_nmi_handler((t), &fn##_na); \
14104 })
14105
14106 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14107 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14108
14109 void unregister_nmi_handler(unsigned int, const char *);
14110
14111 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
14112 index c878924..21f4889 100644
14113 --- a/arch/x86/include/asm/page.h
14114 +++ b/arch/x86/include/asm/page.h
14115 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
14116 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
14117
14118 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
14119 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
14120
14121 #define __boot_va(x) __va(x)
14122 #define __boot_pa(x) __pa(x)
14123 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14124 index 0f1ddee..e2fc3d1 100644
14125 --- a/arch/x86/include/asm/page_64.h
14126 +++ b/arch/x86/include/asm/page_64.h
14127 @@ -7,9 +7,9 @@
14128
14129 /* duplicated to the one in bootmem.h */
14130 extern unsigned long max_pfn;
14131 -extern unsigned long phys_base;
14132 +extern const unsigned long phys_base;
14133
14134 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14135 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14136 {
14137 unsigned long y = x - __START_KERNEL_map;
14138
14139 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14140 index cfdc9ee..3f7b5d6 100644
14141 --- a/arch/x86/include/asm/paravirt.h
14142 +++ b/arch/x86/include/asm/paravirt.h
14143 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
14144 return (pmd_t) { ret };
14145 }
14146
14147 -static inline pmdval_t pmd_val(pmd_t pmd)
14148 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14149 {
14150 pmdval_t ret;
14151
14152 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14153 val);
14154 }
14155
14156 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14157 +{
14158 + pgdval_t val = native_pgd_val(pgd);
14159 +
14160 + if (sizeof(pgdval_t) > sizeof(long))
14161 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14162 + val, (u64)val >> 32);
14163 + else
14164 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14165 + val);
14166 +}
14167 +
14168 static inline void pgd_clear(pgd_t *pgdp)
14169 {
14170 set_pgd(pgdp, __pgd(0));
14171 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14172 pv_mmu_ops.set_fixmap(idx, phys, flags);
14173 }
14174
14175 +#ifdef CONFIG_PAX_KERNEXEC
14176 +static inline unsigned long pax_open_kernel(void)
14177 +{
14178 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14179 +}
14180 +
14181 +static inline unsigned long pax_close_kernel(void)
14182 +{
14183 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14184 +}
14185 +#else
14186 +static inline unsigned long pax_open_kernel(void) { return 0; }
14187 +static inline unsigned long pax_close_kernel(void) { return 0; }
14188 +#endif
14189 +
14190 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14191
14192 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14193 @@ -926,7 +953,7 @@ extern void default_banner(void);
14194
14195 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14196 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14197 -#define PARA_INDIRECT(addr) *%cs:addr
14198 +#define PARA_INDIRECT(addr) *%ss:addr
14199 #endif
14200
14201 #define INTERRUPT_RETURN \
14202 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
14203 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14204 CLBR_NONE, \
14205 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14206 +
14207 +#define GET_CR0_INTO_RDI \
14208 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14209 + mov %rax,%rdi
14210 +
14211 +#define SET_RDI_INTO_CR0 \
14212 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14213 +
14214 +#define GET_CR3_INTO_RDI \
14215 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14216 + mov %rax,%rdi
14217 +
14218 +#define SET_RDI_INTO_CR3 \
14219 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14220 +
14221 #endif /* CONFIG_X86_32 */
14222
14223 #endif /* __ASSEMBLY__ */
14224 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14225 index 0db1fca..52310cc 100644
14226 --- a/arch/x86/include/asm/paravirt_types.h
14227 +++ b/arch/x86/include/asm/paravirt_types.h
14228 @@ -84,7 +84,7 @@ struct pv_init_ops {
14229 */
14230 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14231 unsigned long addr, unsigned len);
14232 -};
14233 +} __no_const;
14234
14235
14236 struct pv_lazy_ops {
14237 @@ -98,7 +98,7 @@ struct pv_time_ops {
14238 unsigned long long (*sched_clock)(void);
14239 unsigned long long (*steal_clock)(int cpu);
14240 unsigned long (*get_tsc_khz)(void);
14241 -};
14242 +} __no_const;
14243
14244 struct pv_cpu_ops {
14245 /* hooks for various privileged instructions */
14246 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14247
14248 void (*start_context_switch)(struct task_struct *prev);
14249 void (*end_context_switch)(struct task_struct *next);
14250 -};
14251 +} __no_const;
14252
14253 struct pv_irq_ops {
14254 /*
14255 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14256 unsigned long start_eip,
14257 unsigned long start_esp);
14258 #endif
14259 -};
14260 +} __no_const;
14261
14262 struct pv_mmu_ops {
14263 unsigned long (*read_cr2)(void);
14264 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14265 struct paravirt_callee_save make_pud;
14266
14267 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14268 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14269 #endif /* PAGETABLE_LEVELS == 4 */
14270 #endif /* PAGETABLE_LEVELS >= 3 */
14271
14272 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14273 an mfn. We can tell which is which from the index. */
14274 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14275 phys_addr_t phys, pgprot_t flags);
14276 +
14277 +#ifdef CONFIG_PAX_KERNEXEC
14278 + unsigned long (*pax_open_kernel)(void);
14279 + unsigned long (*pax_close_kernel)(void);
14280 +#endif
14281 +
14282 };
14283
14284 struct arch_spinlock;
14285 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14286 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14287 int (*spin_trylock)(struct arch_spinlock *lock);
14288 void (*spin_unlock)(struct arch_spinlock *lock);
14289 -};
14290 +} __no_const;
14291
14292 /* This contains all the paravirt structures: we get a convenient
14293 * number for each function using the offset which we use to indicate
14294 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14295 index b4389a4..7024269 100644
14296 --- a/arch/x86/include/asm/pgalloc.h
14297 +++ b/arch/x86/include/asm/pgalloc.h
14298 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14299 pmd_t *pmd, pte_t *pte)
14300 {
14301 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14302 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14303 +}
14304 +
14305 +static inline void pmd_populate_user(struct mm_struct *mm,
14306 + pmd_t *pmd, pte_t *pte)
14307 +{
14308 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14309 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14310 }
14311
14312 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14313
14314 #ifdef CONFIG_X86_PAE
14315 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14316 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14317 +{
14318 + pud_populate(mm, pudp, pmd);
14319 +}
14320 #else /* !CONFIG_X86_PAE */
14321 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14322 {
14323 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14324 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14325 }
14326 +
14327 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14328 +{
14329 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14330 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14331 +}
14332 #endif /* CONFIG_X86_PAE */
14333
14334 #if PAGETABLE_LEVELS > 3
14335 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14336 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14337 }
14338
14339 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14340 +{
14341 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14342 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14343 +}
14344 +
14345 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14346 {
14347 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14348 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14349 index f2b489c..4f7e2e5 100644
14350 --- a/arch/x86/include/asm/pgtable-2level.h
14351 +++ b/arch/x86/include/asm/pgtable-2level.h
14352 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14353
14354 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14355 {
14356 + pax_open_kernel();
14357 *pmdp = pmd;
14358 + pax_close_kernel();
14359 }
14360
14361 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14362 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14363 index 4cc9f2b..5fd9226 100644
14364 --- a/arch/x86/include/asm/pgtable-3level.h
14365 +++ b/arch/x86/include/asm/pgtable-3level.h
14366 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14367
14368 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14369 {
14370 + pax_open_kernel();
14371 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14372 + pax_close_kernel();
14373 }
14374
14375 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14376 {
14377 + pax_open_kernel();
14378 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14379 + pax_close_kernel();
14380 }
14381
14382 /*
14383 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14384 index 1e67223..dd6e7ea 100644
14385 --- a/arch/x86/include/asm/pgtable.h
14386 +++ b/arch/x86/include/asm/pgtable.h
14387 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14388
14389 #ifndef __PAGETABLE_PUD_FOLDED
14390 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14391 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14392 #define pgd_clear(pgd) native_pgd_clear(pgd)
14393 #endif
14394
14395 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14396
14397 #define arch_end_context_switch(prev) do {} while(0)
14398
14399 +#define pax_open_kernel() native_pax_open_kernel()
14400 +#define pax_close_kernel() native_pax_close_kernel()
14401 #endif /* CONFIG_PARAVIRT */
14402
14403 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14404 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14405 +
14406 +#ifdef CONFIG_PAX_KERNEXEC
14407 +static inline unsigned long native_pax_open_kernel(void)
14408 +{
14409 + unsigned long cr0;
14410 +
14411 + preempt_disable();
14412 + barrier();
14413 + cr0 = read_cr0() ^ X86_CR0_WP;
14414 + BUG_ON(cr0 & X86_CR0_WP);
14415 + write_cr0(cr0);
14416 + return cr0 ^ X86_CR0_WP;
14417 +}
14418 +
14419 +static inline unsigned long native_pax_close_kernel(void)
14420 +{
14421 + unsigned long cr0;
14422 +
14423 + cr0 = read_cr0() ^ X86_CR0_WP;
14424 + BUG_ON(!(cr0 & X86_CR0_WP));
14425 + write_cr0(cr0);
14426 + barrier();
14427 + preempt_enable_no_resched();
14428 + return cr0 ^ X86_CR0_WP;
14429 +}
14430 +#else
14431 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14432 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14433 +#endif
14434 +
14435 /*
14436 * The following only work if pte_present() is true.
14437 * Undefined behaviour if not..
14438 */
14439 +static inline int pte_user(pte_t pte)
14440 +{
14441 + return pte_val(pte) & _PAGE_USER;
14442 +}
14443 +
14444 static inline int pte_dirty(pte_t pte)
14445 {
14446 return pte_flags(pte) & _PAGE_DIRTY;
14447 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14448 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14449 }
14450
14451 +static inline unsigned long pgd_pfn(pgd_t pgd)
14452 +{
14453 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14454 +}
14455 +
14456 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14457
14458 static inline int pmd_large(pmd_t pte)
14459 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14460 return pte_clear_flags(pte, _PAGE_RW);
14461 }
14462
14463 +static inline pte_t pte_mkread(pte_t pte)
14464 +{
14465 + return __pte(pte_val(pte) | _PAGE_USER);
14466 +}
14467 +
14468 static inline pte_t pte_mkexec(pte_t pte)
14469 {
14470 - return pte_clear_flags(pte, _PAGE_NX);
14471 +#ifdef CONFIG_X86_PAE
14472 + if (__supported_pte_mask & _PAGE_NX)
14473 + return pte_clear_flags(pte, _PAGE_NX);
14474 + else
14475 +#endif
14476 + return pte_set_flags(pte, _PAGE_USER);
14477 +}
14478 +
14479 +static inline pte_t pte_exprotect(pte_t pte)
14480 +{
14481 +#ifdef CONFIG_X86_PAE
14482 + if (__supported_pte_mask & _PAGE_NX)
14483 + return pte_set_flags(pte, _PAGE_NX);
14484 + else
14485 +#endif
14486 + return pte_clear_flags(pte, _PAGE_USER);
14487 }
14488
14489 static inline pte_t pte_mkdirty(pte_t pte)
14490 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14491 #endif
14492
14493 #ifndef __ASSEMBLY__
14494 +
14495 +#ifdef CONFIG_PAX_PER_CPU_PGD
14496 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14497 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14498 +{
14499 + return cpu_pgd[cpu];
14500 +}
14501 +#endif
14502 +
14503 #include <linux/mm_types.h>
14504 #include <linux/log2.h>
14505
14506 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14507 * Currently stuck as a macro due to indirect forward reference to
14508 * linux/mmzone.h's __section_mem_map_addr() definition:
14509 */
14510 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14511 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14512
14513 /* Find an entry in the second-level page table.. */
14514 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14515 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14516 * Currently stuck as a macro due to indirect forward reference to
14517 * linux/mmzone.h's __section_mem_map_addr() definition:
14518 */
14519 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14520 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14521
14522 /* to find an entry in a page-table-directory. */
14523 static inline unsigned long pud_index(unsigned long address)
14524 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14525
14526 static inline int pgd_bad(pgd_t pgd)
14527 {
14528 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14529 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14530 }
14531
14532 static inline int pgd_none(pgd_t pgd)
14533 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14534 * pgd_offset() returns a (pgd_t *)
14535 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14536 */
14537 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14538 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14539 +
14540 +#ifdef CONFIG_PAX_PER_CPU_PGD
14541 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14542 +#endif
14543 +
14544 /*
14545 * a shortcut which implies the use of the kernel's pgd, instead
14546 * of a process's
14547 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14548 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14549 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14550
14551 +#ifdef CONFIG_X86_32
14552 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14553 +#else
14554 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14555 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14556 +
14557 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14558 +#ifdef __ASSEMBLY__
14559 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14560 +#else
14561 +extern unsigned long pax_user_shadow_base;
14562 +#endif
14563 +#endif
14564 +
14565 +#endif
14566 +
14567 #ifndef __ASSEMBLY__
14568
14569 extern int direct_gbpages;
14570 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14571 * dst and src can be on the same page, but the range must not overlap,
14572 * and must not cross a page boundary.
14573 */
14574 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14575 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14576 {
14577 - memcpy(dst, src, count * sizeof(pgd_t));
14578 + pax_open_kernel();
14579 + while (count--)
14580 + *dst++ = *src++;
14581 + pax_close_kernel();
14582 }
14583
14584 +#ifdef CONFIG_PAX_PER_CPU_PGD
14585 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14586 +#endif
14587 +
14588 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14589 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14590 +#else
14591 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14592 +#endif
14593 +
14594 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14595 static inline int page_level_shift(enum pg_level level)
14596 {
14597 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14598 index 9ee3221..b979c6b 100644
14599 --- a/arch/x86/include/asm/pgtable_32.h
14600 +++ b/arch/x86/include/asm/pgtable_32.h
14601 @@ -25,9 +25,6 @@
14602 struct mm_struct;
14603 struct vm_area_struct;
14604
14605 -extern pgd_t swapper_pg_dir[1024];
14606 -extern pgd_t initial_page_table[1024];
14607 -
14608 static inline void pgtable_cache_init(void) { }
14609 static inline void check_pgt_cache(void) { }
14610 void paging_init(void);
14611 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14612 # include <asm/pgtable-2level.h>
14613 #endif
14614
14615 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14616 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14617 +#ifdef CONFIG_X86_PAE
14618 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14619 +#endif
14620 +
14621 #if defined(CONFIG_HIGHPTE)
14622 #define pte_offset_map(dir, address) \
14623 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14624 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14625 /* Clear a kernel PTE and flush it from the TLB */
14626 #define kpte_clear_flush(ptep, vaddr) \
14627 do { \
14628 + pax_open_kernel(); \
14629 pte_clear(&init_mm, (vaddr), (ptep)); \
14630 + pax_close_kernel(); \
14631 __flush_tlb_one((vaddr)); \
14632 } while (0)
14633
14634 #endif /* !__ASSEMBLY__ */
14635
14636 +#define HAVE_ARCH_UNMAPPED_AREA
14637 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14638 +
14639 /*
14640 * kern_addr_valid() is (1) for FLATMEM and (0) for
14641 * SPARSEMEM and DISCONTIGMEM
14642 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14643 index ed5903b..c7fe163 100644
14644 --- a/arch/x86/include/asm/pgtable_32_types.h
14645 +++ b/arch/x86/include/asm/pgtable_32_types.h
14646 @@ -8,7 +8,7 @@
14647 */
14648 #ifdef CONFIG_X86_PAE
14649 # include <asm/pgtable-3level_types.h>
14650 -# define PMD_SIZE (1UL << PMD_SHIFT)
14651 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14652 # define PMD_MASK (~(PMD_SIZE - 1))
14653 #else
14654 # include <asm/pgtable-2level_types.h>
14655 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14656 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14657 #endif
14658
14659 +#ifdef CONFIG_PAX_KERNEXEC
14660 +#ifndef __ASSEMBLY__
14661 +extern unsigned char MODULES_EXEC_VADDR[];
14662 +extern unsigned char MODULES_EXEC_END[];
14663 +#endif
14664 +#include <asm/boot.h>
14665 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14666 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14667 +#else
14668 +#define ktla_ktva(addr) (addr)
14669 +#define ktva_ktla(addr) (addr)
14670 +#endif
14671 +
14672 #define MODULES_VADDR VMALLOC_START
14673 #define MODULES_END VMALLOC_END
14674 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14675 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14676 index e22c1db..23a625a 100644
14677 --- a/arch/x86/include/asm/pgtable_64.h
14678 +++ b/arch/x86/include/asm/pgtable_64.h
14679 @@ -16,10 +16,14 @@
14680
14681 extern pud_t level3_kernel_pgt[512];
14682 extern pud_t level3_ident_pgt[512];
14683 +extern pud_t level3_vmalloc_start_pgt[512];
14684 +extern pud_t level3_vmalloc_end_pgt[512];
14685 +extern pud_t level3_vmemmap_pgt[512];
14686 +extern pud_t level2_vmemmap_pgt[512];
14687 extern pmd_t level2_kernel_pgt[512];
14688 extern pmd_t level2_fixmap_pgt[512];
14689 -extern pmd_t level2_ident_pgt[512];
14690 -extern pgd_t init_level4_pgt[];
14691 +extern pmd_t level2_ident_pgt[512*2];
14692 +extern pgd_t init_level4_pgt[512];
14693
14694 #define swapper_pg_dir init_level4_pgt
14695
14696 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14697
14698 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14699 {
14700 + pax_open_kernel();
14701 *pmdp = pmd;
14702 + pax_close_kernel();
14703 }
14704
14705 static inline void native_pmd_clear(pmd_t *pmd)
14706 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14707
14708 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14709 {
14710 + pax_open_kernel();
14711 *pudp = pud;
14712 + pax_close_kernel();
14713 }
14714
14715 static inline void native_pud_clear(pud_t *pud)
14716 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14717
14718 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14719 {
14720 + pax_open_kernel();
14721 + *pgdp = pgd;
14722 + pax_close_kernel();
14723 +}
14724 +
14725 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14726 +{
14727 *pgdp = pgd;
14728 }
14729
14730 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14731 index 2d88344..4679fc3 100644
14732 --- a/arch/x86/include/asm/pgtable_64_types.h
14733 +++ b/arch/x86/include/asm/pgtable_64_types.h
14734 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14735 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14736 #define MODULES_END _AC(0xffffffffff000000, UL)
14737 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14738 +#define MODULES_EXEC_VADDR MODULES_VADDR
14739 +#define MODULES_EXEC_END MODULES_END
14740 +
14741 +#define ktla_ktva(addr) (addr)
14742 +#define ktva_ktla(addr) (addr)
14743
14744 #define EARLY_DYNAMIC_PAGE_TABLES 64
14745
14746 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14747 index e642300..0ef8f31 100644
14748 --- a/arch/x86/include/asm/pgtable_types.h
14749 +++ b/arch/x86/include/asm/pgtable_types.h
14750 @@ -16,13 +16,12 @@
14751 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14752 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14753 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14754 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14755 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14756 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14757 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14758 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14759 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14760 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14761 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14762 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14763 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14764 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14765
14766 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14767 @@ -40,7 +39,6 @@
14768 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14769 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14770 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14771 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14772 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14773 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14774 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14775 @@ -57,8 +55,10 @@
14776
14777 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14778 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14779 -#else
14780 +#elif defined(CONFIG_KMEMCHECK)
14781 #define _PAGE_NX (_AT(pteval_t, 0))
14782 +#else
14783 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14784 #endif
14785
14786 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14787 @@ -116,6 +116,9 @@
14788 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14789 _PAGE_ACCESSED)
14790
14791 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14792 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14793 +
14794 #define __PAGE_KERNEL_EXEC \
14795 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14796 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14797 @@ -126,7 +129,7 @@
14798 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14799 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14800 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14801 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14802 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14803 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14804 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14805 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14806 @@ -188,8 +191,8 @@
14807 * bits are combined, this will alow user to access the high address mapped
14808 * VDSO in the presence of CONFIG_COMPAT_VDSO
14809 */
14810 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14811 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14812 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14813 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14814 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14815 #endif
14816
14817 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14818 {
14819 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14820 }
14821 +#endif
14822
14823 +#if PAGETABLE_LEVELS == 3
14824 +#include <asm-generic/pgtable-nopud.h>
14825 +#endif
14826 +
14827 +#if PAGETABLE_LEVELS == 2
14828 +#include <asm-generic/pgtable-nopmd.h>
14829 +#endif
14830 +
14831 +#ifndef __ASSEMBLY__
14832 #if PAGETABLE_LEVELS > 3
14833 typedef struct { pudval_t pud; } pud_t;
14834
14835 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14836 return pud.pud;
14837 }
14838 #else
14839 -#include <asm-generic/pgtable-nopud.h>
14840 -
14841 static inline pudval_t native_pud_val(pud_t pud)
14842 {
14843 return native_pgd_val(pud.pgd);
14844 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14845 return pmd.pmd;
14846 }
14847 #else
14848 -#include <asm-generic/pgtable-nopmd.h>
14849 -
14850 static inline pmdval_t native_pmd_val(pmd_t pmd)
14851 {
14852 return native_pgd_val(pmd.pud.pgd);
14853 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14854
14855 extern pteval_t __supported_pte_mask;
14856 extern void set_nx(void);
14857 -extern int nx_enabled;
14858
14859 #define pgprot_writecombine pgprot_writecombine
14860 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14861 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14862 index 22224b3..4080dab 100644
14863 --- a/arch/x86/include/asm/processor.h
14864 +++ b/arch/x86/include/asm/processor.h
14865 @@ -282,7 +282,7 @@ struct tss_struct {
14866
14867 } ____cacheline_aligned;
14868
14869 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14870 +extern struct tss_struct init_tss[NR_CPUS];
14871
14872 /*
14873 * Save the original ist values for checking stack pointers during debugging
14874 @@ -823,11 +823,18 @@ static inline void spin_lock_prefetch(const void *x)
14875 */
14876 #define TASK_SIZE PAGE_OFFSET
14877 #define TASK_SIZE_MAX TASK_SIZE
14878 +
14879 +#ifdef CONFIG_PAX_SEGMEXEC
14880 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14881 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14882 +#else
14883 #define STACK_TOP TASK_SIZE
14884 -#define STACK_TOP_MAX STACK_TOP
14885 +#endif
14886 +
14887 +#define STACK_TOP_MAX TASK_SIZE
14888
14889 #define INIT_THREAD { \
14890 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14891 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14892 .vm86_info = NULL, \
14893 .sysenter_cs = __KERNEL_CS, \
14894 .io_bitmap_ptr = NULL, \
14895 @@ -841,7 +848,7 @@ static inline void spin_lock_prefetch(const void *x)
14896 */
14897 #define INIT_TSS { \
14898 .x86_tss = { \
14899 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14900 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14901 .ss0 = __KERNEL_DS, \
14902 .ss1 = __KERNEL_CS, \
14903 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14904 @@ -852,11 +859,7 @@ static inline void spin_lock_prefetch(const void *x)
14905 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14906
14907 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14908 -#define KSTK_TOP(info) \
14909 -({ \
14910 - unsigned long *__ptr = (unsigned long *)(info); \
14911 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14912 -})
14913 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14914
14915 /*
14916 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14917 @@ -871,7 +874,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14918 #define task_pt_regs(task) \
14919 ({ \
14920 struct pt_regs *__regs__; \
14921 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14922 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14923 __regs__ - 1; \
14924 })
14925
14926 @@ -881,13 +884,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14927 /*
14928 * User space process size. 47bits minus one guard page.
14929 */
14930 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14931 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14932
14933 /* This decides where the kernel will search for a free chunk of vm
14934 * space during mmap's.
14935 */
14936 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14937 - 0xc0000000 : 0xFFFFe000)
14938 + 0xc0000000 : 0xFFFFf000)
14939
14940 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14941 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14942 @@ -898,11 +901,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14943 #define STACK_TOP_MAX TASK_SIZE_MAX
14944
14945 #define INIT_THREAD { \
14946 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14947 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14948 }
14949
14950 #define INIT_TSS { \
14951 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14952 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14953 }
14954
14955 /*
14956 @@ -930,6 +933,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14957 */
14958 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14959
14960 +#ifdef CONFIG_PAX_SEGMEXEC
14961 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14962 +#endif
14963 +
14964 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14965
14966 /* Get/set a process' ability to use the timestamp counter instruction */
14967 @@ -970,7 +977,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
14968 return ratio;
14969 }
14970
14971 -extern unsigned long arch_align_stack(unsigned long sp);
14972 +#define arch_align_stack(x) ((x) & ~0xfUL)
14973 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14974
14975 void default_idle(void);
14976 @@ -980,6 +987,6 @@ bool xen_set_default_idle(void);
14977 #define xen_set_default_idle 0
14978 #endif
14979
14980 -void stop_this_cpu(void *dummy);
14981 +void stop_this_cpu(void *dummy) __noreturn;
14982
14983 #endif /* _ASM_X86_PROCESSOR_H */
14984 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14985 index 942a086..6c26446 100644
14986 --- a/arch/x86/include/asm/ptrace.h
14987 +++ b/arch/x86/include/asm/ptrace.h
14988 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14989 }
14990
14991 /*
14992 - * user_mode_vm(regs) determines whether a register set came from user mode.
14993 + * user_mode(regs) determines whether a register set came from user mode.
14994 * This is true if V8086 mode was enabled OR if the register set was from
14995 * protected mode with RPL-3 CS value. This tricky test checks that with
14996 * one comparison. Many places in the kernel can bypass this full check
14997 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14998 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14999 + * be used.
15000 */
15001 -static inline int user_mode(struct pt_regs *regs)
15002 +static inline int user_mode_novm(struct pt_regs *regs)
15003 {
15004 #ifdef CONFIG_X86_32
15005 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15006 #else
15007 - return !!(regs->cs & 3);
15008 + return !!(regs->cs & SEGMENT_RPL_MASK);
15009 #endif
15010 }
15011
15012 -static inline int user_mode_vm(struct pt_regs *regs)
15013 +static inline int user_mode(struct pt_regs *regs)
15014 {
15015 #ifdef CONFIG_X86_32
15016 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15017 USER_RPL;
15018 #else
15019 - return user_mode(regs);
15020 + return user_mode_novm(regs);
15021 #endif
15022 }
15023
15024 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15025 #ifdef CONFIG_X86_64
15026 static inline bool user_64bit_mode(struct pt_regs *regs)
15027 {
15028 + unsigned long cs = regs->cs & 0xffff;
15029 #ifndef CONFIG_PARAVIRT
15030 /*
15031 * On non-paravirt systems, this is the only long mode CPL 3
15032 * selector. We do not allow long mode selectors in the LDT.
15033 */
15034 - return regs->cs == __USER_CS;
15035 + return cs == __USER_CS;
15036 #else
15037 /* Headers are too twisted for this to go in paravirt.h. */
15038 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15039 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15040 #endif
15041 }
15042
15043 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15044 * Traps from the kernel do not save sp and ss.
15045 * Use the helper function to retrieve sp.
15046 */
15047 - if (offset == offsetof(struct pt_regs, sp) &&
15048 - regs->cs == __KERNEL_CS)
15049 - return kernel_stack_pointer(regs);
15050 + if (offset == offsetof(struct pt_regs, sp)) {
15051 + unsigned long cs = regs->cs & 0xffff;
15052 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15053 + return kernel_stack_pointer(regs);
15054 + }
15055 #endif
15056 return *(unsigned long *)((unsigned long)regs + offset);
15057 }
15058 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15059 index 9c6b890..5305f53 100644
15060 --- a/arch/x86/include/asm/realmode.h
15061 +++ b/arch/x86/include/asm/realmode.h
15062 @@ -22,16 +22,14 @@ struct real_mode_header {
15063 #endif
15064 /* APM/BIOS reboot */
15065 u32 machine_real_restart_asm;
15066 -#ifdef CONFIG_X86_64
15067 u32 machine_real_restart_seg;
15068 -#endif
15069 };
15070
15071 /* This must match data at trampoline_32/64.S */
15072 struct trampoline_header {
15073 #ifdef CONFIG_X86_32
15074 u32 start;
15075 - u16 gdt_pad;
15076 + u16 boot_cs;
15077 u16 gdt_limit;
15078 u32 gdt_base;
15079 #else
15080 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15081 index a82c4f1..ac45053 100644
15082 --- a/arch/x86/include/asm/reboot.h
15083 +++ b/arch/x86/include/asm/reboot.h
15084 @@ -6,13 +6,13 @@
15085 struct pt_regs;
15086
15087 struct machine_ops {
15088 - void (*restart)(char *cmd);
15089 - void (*halt)(void);
15090 - void (*power_off)(void);
15091 + void (* __noreturn restart)(char *cmd);
15092 + void (* __noreturn halt)(void);
15093 + void (* __noreturn power_off)(void);
15094 void (*shutdown)(void);
15095 void (*crash_shutdown)(struct pt_regs *);
15096 - void (*emergency_restart)(void);
15097 -};
15098 + void (* __noreturn emergency_restart)(void);
15099 +} __no_const;
15100
15101 extern struct machine_ops machine_ops;
15102
15103 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15104 index cad82c9..2e5c5c1 100644
15105 --- a/arch/x86/include/asm/rwsem.h
15106 +++ b/arch/x86/include/asm/rwsem.h
15107 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15108 {
15109 asm volatile("# beginning down_read\n\t"
15110 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15111 +
15112 +#ifdef CONFIG_PAX_REFCOUNT
15113 + "jno 0f\n"
15114 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15115 + "int $4\n0:\n"
15116 + _ASM_EXTABLE(0b, 0b)
15117 +#endif
15118 +
15119 /* adds 0x00000001 */
15120 " jns 1f\n"
15121 " call call_rwsem_down_read_failed\n"
15122 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15123 "1:\n\t"
15124 " mov %1,%2\n\t"
15125 " add %3,%2\n\t"
15126 +
15127 +#ifdef CONFIG_PAX_REFCOUNT
15128 + "jno 0f\n"
15129 + "sub %3,%2\n"
15130 + "int $4\n0:\n"
15131 + _ASM_EXTABLE(0b, 0b)
15132 +#endif
15133 +
15134 " jle 2f\n\t"
15135 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15136 " jnz 1b\n\t"
15137 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15138 long tmp;
15139 asm volatile("# beginning down_write\n\t"
15140 LOCK_PREFIX " xadd %1,(%2)\n\t"
15141 +
15142 +#ifdef CONFIG_PAX_REFCOUNT
15143 + "jno 0f\n"
15144 + "mov %1,(%2)\n"
15145 + "int $4\n0:\n"
15146 + _ASM_EXTABLE(0b, 0b)
15147 +#endif
15148 +
15149 /* adds 0xffff0001, returns the old value */
15150 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
15151 /* was the active mask 0 before? */
15152 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15153 long tmp;
15154 asm volatile("# beginning __up_read\n\t"
15155 LOCK_PREFIX " xadd %1,(%2)\n\t"
15156 +
15157 +#ifdef CONFIG_PAX_REFCOUNT
15158 + "jno 0f\n"
15159 + "mov %1,(%2)\n"
15160 + "int $4\n0:\n"
15161 + _ASM_EXTABLE(0b, 0b)
15162 +#endif
15163 +
15164 /* subtracts 1, returns the old value */
15165 " jns 1f\n\t"
15166 " call call_rwsem_wake\n" /* expects old value in %edx */
15167 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15168 long tmp;
15169 asm volatile("# beginning __up_write\n\t"
15170 LOCK_PREFIX " xadd %1,(%2)\n\t"
15171 +
15172 +#ifdef CONFIG_PAX_REFCOUNT
15173 + "jno 0f\n"
15174 + "mov %1,(%2)\n"
15175 + "int $4\n0:\n"
15176 + _ASM_EXTABLE(0b, 0b)
15177 +#endif
15178 +
15179 /* subtracts 0xffff0001, returns the old value */
15180 " jns 1f\n\t"
15181 " call call_rwsem_wake\n" /* expects old value in %edx */
15182 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15183 {
15184 asm volatile("# beginning __downgrade_write\n\t"
15185 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15186 +
15187 +#ifdef CONFIG_PAX_REFCOUNT
15188 + "jno 0f\n"
15189 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15190 + "int $4\n0:\n"
15191 + _ASM_EXTABLE(0b, 0b)
15192 +#endif
15193 +
15194 /*
15195 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15196 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15197 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15198 */
15199 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15200 {
15201 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15202 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15203 +
15204 +#ifdef CONFIG_PAX_REFCOUNT
15205 + "jno 0f\n"
15206 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15207 + "int $4\n0:\n"
15208 + _ASM_EXTABLE(0b, 0b)
15209 +#endif
15210 +
15211 : "+m" (sem->count)
15212 : "er" (delta));
15213 }
15214 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15215 */
15216 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15217 {
15218 - return delta + xadd(&sem->count, delta);
15219 + return delta + xadd_check_overflow(&sem->count, delta);
15220 }
15221
15222 #endif /* __KERNEL__ */
15223 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15224 index c48a950..c6d7468 100644
15225 --- a/arch/x86/include/asm/segment.h
15226 +++ b/arch/x86/include/asm/segment.h
15227 @@ -64,10 +64,15 @@
15228 * 26 - ESPFIX small SS
15229 * 27 - per-cpu [ offset to per-cpu data area ]
15230 * 28 - stack_canary-20 [ for stack protector ]
15231 - * 29 - unused
15232 - * 30 - unused
15233 + * 29 - PCI BIOS CS
15234 + * 30 - PCI BIOS DS
15235 * 31 - TSS for double fault handler
15236 */
15237 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15238 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15239 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15240 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15241 +
15242 #define GDT_ENTRY_TLS_MIN 6
15243 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15244
15245 @@ -79,6 +84,8 @@
15246
15247 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15248
15249 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15250 +
15251 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15252
15253 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15254 @@ -104,6 +111,12 @@
15255 #define __KERNEL_STACK_CANARY 0
15256 #endif
15257
15258 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15259 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15260 +
15261 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15262 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15263 +
15264 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15265
15266 /*
15267 @@ -141,7 +154,7 @@
15268 */
15269
15270 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15271 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15272 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15273
15274
15275 #else
15276 @@ -165,6 +178,8 @@
15277 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15278 #define __USER32_DS __USER_DS
15279
15280 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15281 +
15282 #define GDT_ENTRY_TSS 8 /* needs two entries */
15283 #define GDT_ENTRY_LDT 10 /* needs two entries */
15284 #define GDT_ENTRY_TLS_MIN 12
15285 @@ -185,6 +200,7 @@
15286 #endif
15287
15288 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15289 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15290 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15291 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15292 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15293 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15294 {
15295 unsigned long __limit;
15296 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15297 - return __limit + 1;
15298 + return __limit;
15299 }
15300
15301 #endif /* !__ASSEMBLY__ */
15302 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15303 index b073aae..39f9bdd 100644
15304 --- a/arch/x86/include/asm/smp.h
15305 +++ b/arch/x86/include/asm/smp.h
15306 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15307 /* cpus sharing the last level cache: */
15308 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15309 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15310 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15311 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15312
15313 static inline struct cpumask *cpu_sibling_mask(int cpu)
15314 {
15315 @@ -79,7 +79,7 @@ struct smp_ops {
15316
15317 void (*send_call_func_ipi)(const struct cpumask *mask);
15318 void (*send_call_func_single_ipi)(int cpu);
15319 -};
15320 +} __no_const;
15321
15322 /* Globals due to paravirt */
15323 extern void set_cpu_sibling_map(int cpu);
15324 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15325 extern int safe_smp_processor_id(void);
15326
15327 #elif defined(CONFIG_X86_64_SMP)
15328 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15329 -
15330 -#define stack_smp_processor_id() \
15331 -({ \
15332 - struct thread_info *ti; \
15333 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15334 - ti->cpu; \
15335 -})
15336 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15337 +#define stack_smp_processor_id() raw_smp_processor_id()
15338 #define safe_smp_processor_id() smp_processor_id()
15339
15340 #endif
15341 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15342 index 33692ea..350a534 100644
15343 --- a/arch/x86/include/asm/spinlock.h
15344 +++ b/arch/x86/include/asm/spinlock.h
15345 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15346 static inline void arch_read_lock(arch_rwlock_t *rw)
15347 {
15348 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15349 +
15350 +#ifdef CONFIG_PAX_REFCOUNT
15351 + "jno 0f\n"
15352 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15353 + "int $4\n0:\n"
15354 + _ASM_EXTABLE(0b, 0b)
15355 +#endif
15356 +
15357 "jns 1f\n"
15358 "call __read_lock_failed\n\t"
15359 "1:\n"
15360 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15361 static inline void arch_write_lock(arch_rwlock_t *rw)
15362 {
15363 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15364 +
15365 +#ifdef CONFIG_PAX_REFCOUNT
15366 + "jno 0f\n"
15367 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15368 + "int $4\n0:\n"
15369 + _ASM_EXTABLE(0b, 0b)
15370 +#endif
15371 +
15372 "jz 1f\n"
15373 "call __write_lock_failed\n\t"
15374 "1:\n"
15375 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15376
15377 static inline void arch_read_unlock(arch_rwlock_t *rw)
15378 {
15379 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15380 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15381 +
15382 +#ifdef CONFIG_PAX_REFCOUNT
15383 + "jno 0f\n"
15384 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15385 + "int $4\n0:\n"
15386 + _ASM_EXTABLE(0b, 0b)
15387 +#endif
15388 +
15389 :"+m" (rw->lock) : : "memory");
15390 }
15391
15392 static inline void arch_write_unlock(arch_rwlock_t *rw)
15393 {
15394 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15395 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15396 +
15397 +#ifdef CONFIG_PAX_REFCOUNT
15398 + "jno 0f\n"
15399 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15400 + "int $4\n0:\n"
15401 + _ASM_EXTABLE(0b, 0b)
15402 +#endif
15403 +
15404 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15405 }
15406
15407 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15408 index 6a99859..03cb807 100644
15409 --- a/arch/x86/include/asm/stackprotector.h
15410 +++ b/arch/x86/include/asm/stackprotector.h
15411 @@ -47,7 +47,7 @@
15412 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15413 */
15414 #define GDT_STACK_CANARY_INIT \
15415 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15416 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15417
15418 /*
15419 * Initialize the stackprotector canary value.
15420 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15421
15422 static inline void load_stack_canary_segment(void)
15423 {
15424 -#ifdef CONFIG_X86_32
15425 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15426 asm volatile ("mov %0, %%gs" : : "r" (0));
15427 #endif
15428 }
15429 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15430 index 70bbe39..4ae2bd4 100644
15431 --- a/arch/x86/include/asm/stacktrace.h
15432 +++ b/arch/x86/include/asm/stacktrace.h
15433 @@ -11,28 +11,20 @@
15434
15435 extern int kstack_depth_to_print;
15436
15437 -struct thread_info;
15438 +struct task_struct;
15439 struct stacktrace_ops;
15440
15441 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15442 - unsigned long *stack,
15443 - unsigned long bp,
15444 - const struct stacktrace_ops *ops,
15445 - void *data,
15446 - unsigned long *end,
15447 - int *graph);
15448 +typedef unsigned long walk_stack_t(struct task_struct *task,
15449 + void *stack_start,
15450 + unsigned long *stack,
15451 + unsigned long bp,
15452 + const struct stacktrace_ops *ops,
15453 + void *data,
15454 + unsigned long *end,
15455 + int *graph);
15456
15457 -extern unsigned long
15458 -print_context_stack(struct thread_info *tinfo,
15459 - unsigned long *stack, unsigned long bp,
15460 - const struct stacktrace_ops *ops, void *data,
15461 - unsigned long *end, int *graph);
15462 -
15463 -extern unsigned long
15464 -print_context_stack_bp(struct thread_info *tinfo,
15465 - unsigned long *stack, unsigned long bp,
15466 - const struct stacktrace_ops *ops, void *data,
15467 - unsigned long *end, int *graph);
15468 +extern walk_stack_t print_context_stack;
15469 +extern walk_stack_t print_context_stack_bp;
15470
15471 /* Generic stack tracer with callbacks */
15472
15473 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15474 void (*address)(void *data, unsigned long address, int reliable);
15475 /* On negative return stop dumping */
15476 int (*stack)(void *data, char *name);
15477 - walk_stack_t walk_stack;
15478 + walk_stack_t *walk_stack;
15479 };
15480
15481 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15482 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15483 index 4ec45b3..a4f0a8a 100644
15484 --- a/arch/x86/include/asm/switch_to.h
15485 +++ b/arch/x86/include/asm/switch_to.h
15486 @@ -108,7 +108,7 @@ do { \
15487 "call __switch_to\n\t" \
15488 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15489 __switch_canary \
15490 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15491 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15492 "movq %%rax,%%rdi\n\t" \
15493 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15494 "jnz ret_from_fork\n\t" \
15495 @@ -119,7 +119,7 @@ do { \
15496 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15497 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15498 [_tif_fork] "i" (_TIF_FORK), \
15499 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15500 + [thread_info] "m" (current_tinfo), \
15501 [current_task] "m" (current_task) \
15502 __switch_canary_iparam \
15503 : "memory", "cc" __EXTRA_CLOBBER)
15504 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15505 index a1df6e8..e002940 100644
15506 --- a/arch/x86/include/asm/thread_info.h
15507 +++ b/arch/x86/include/asm/thread_info.h
15508 @@ -10,6 +10,7 @@
15509 #include <linux/compiler.h>
15510 #include <asm/page.h>
15511 #include <asm/types.h>
15512 +#include <asm/percpu.h>
15513
15514 /*
15515 * low level task data that entry.S needs immediate access to
15516 @@ -23,7 +24,6 @@ struct exec_domain;
15517 #include <linux/atomic.h>
15518
15519 struct thread_info {
15520 - struct task_struct *task; /* main task structure */
15521 struct exec_domain *exec_domain; /* execution domain */
15522 __u32 flags; /* low level flags */
15523 __u32 status; /* thread synchronous flags */
15524 @@ -33,19 +33,13 @@ struct thread_info {
15525 mm_segment_t addr_limit;
15526 struct restart_block restart_block;
15527 void __user *sysenter_return;
15528 -#ifdef CONFIG_X86_32
15529 - unsigned long previous_esp; /* ESP of the previous stack in
15530 - case of nested (IRQ) stacks
15531 - */
15532 - __u8 supervisor_stack[0];
15533 -#endif
15534 + unsigned long lowest_stack;
15535 unsigned int sig_on_uaccess_error:1;
15536 unsigned int uaccess_err:1; /* uaccess failed */
15537 };
15538
15539 -#define INIT_THREAD_INFO(tsk) \
15540 +#define INIT_THREAD_INFO \
15541 { \
15542 - .task = &tsk, \
15543 .exec_domain = &default_exec_domain, \
15544 .flags = 0, \
15545 .cpu = 0, \
15546 @@ -56,7 +50,7 @@ struct thread_info {
15547 }, \
15548 }
15549
15550 -#define init_thread_info (init_thread_union.thread_info)
15551 +#define init_thread_info (init_thread_union.stack)
15552 #define init_stack (init_thread_union.stack)
15553
15554 #else /* !__ASSEMBLY__ */
15555 @@ -97,6 +91,7 @@ struct thread_info {
15556 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15557 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15558 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15559 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15560
15561 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15562 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15563 @@ -121,17 +116,18 @@ struct thread_info {
15564 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15565 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15566 #define _TIF_X32 (1 << TIF_X32)
15567 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15568
15569 /* work to do in syscall_trace_enter() */
15570 #define _TIF_WORK_SYSCALL_ENTRY \
15571 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15572 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15573 - _TIF_NOHZ)
15574 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15575
15576 /* work to do in syscall_trace_leave() */
15577 #define _TIF_WORK_SYSCALL_EXIT \
15578 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15579 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15580 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15581
15582 /* work to do on interrupt/exception return */
15583 #define _TIF_WORK_MASK \
15584 @@ -142,7 +138,7 @@ struct thread_info {
15585 /* work to do on any return to user space */
15586 #define _TIF_ALLWORK_MASK \
15587 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15588 - _TIF_NOHZ)
15589 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15590
15591 /* Only used for 64 bit */
15592 #define _TIF_DO_NOTIFY_MASK \
15593 @@ -158,45 +154,40 @@ struct thread_info {
15594
15595 #define PREEMPT_ACTIVE 0x10000000
15596
15597 -#ifdef CONFIG_X86_32
15598 -
15599 -#define STACK_WARN (THREAD_SIZE/8)
15600 -/*
15601 - * macros/functions for gaining access to the thread information structure
15602 - *
15603 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15604 - */
15605 -#ifndef __ASSEMBLY__
15606 -
15607 -
15608 -/* how to get the current stack pointer from C */
15609 -register unsigned long current_stack_pointer asm("esp") __used;
15610 -
15611 -/* how to get the thread information struct from C */
15612 -static inline struct thread_info *current_thread_info(void)
15613 -{
15614 - return (struct thread_info *)
15615 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15616 -}
15617 -
15618 -#else /* !__ASSEMBLY__ */
15619 -
15620 +#ifdef __ASSEMBLY__
15621 /* how to get the thread information struct from ASM */
15622 #define GET_THREAD_INFO(reg) \
15623 - movl $-THREAD_SIZE, reg; \
15624 - andl %esp, reg
15625 + mov PER_CPU_VAR(current_tinfo), reg
15626
15627 /* use this one if reg already contains %esp */
15628 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15629 - andl $-THREAD_SIZE, reg
15630 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15631 +#else
15632 +/* how to get the thread information struct from C */
15633 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15634 +
15635 +static __always_inline struct thread_info *current_thread_info(void)
15636 +{
15637 + return this_cpu_read_stable(current_tinfo);
15638 +}
15639 +#endif
15640 +
15641 +#ifdef CONFIG_X86_32
15642 +
15643 +#define STACK_WARN (THREAD_SIZE/8)
15644 +/*
15645 + * macros/functions for gaining access to the thread information structure
15646 + *
15647 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15648 + */
15649 +#ifndef __ASSEMBLY__
15650 +
15651 +/* how to get the current stack pointer from C */
15652 +register unsigned long current_stack_pointer asm("esp") __used;
15653
15654 #endif
15655
15656 #else /* X86_32 */
15657
15658 -#include <asm/percpu.h>
15659 -#define KERNEL_STACK_OFFSET (5*8)
15660 -
15661 /*
15662 * macros/functions for gaining access to the thread information structure
15663 * preempt_count needs to be 1 initially, until the scheduler is functional.
15664 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15665 #ifndef __ASSEMBLY__
15666 DECLARE_PER_CPU(unsigned long, kernel_stack);
15667
15668 -static inline struct thread_info *current_thread_info(void)
15669 -{
15670 - struct thread_info *ti;
15671 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15672 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15673 - return ti;
15674 -}
15675 -
15676 -#else /* !__ASSEMBLY__ */
15677 -
15678 -/* how to get the thread information struct from ASM */
15679 -#define GET_THREAD_INFO(reg) \
15680 - movq PER_CPU_VAR(kernel_stack),reg ; \
15681 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15682 -
15683 -/*
15684 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15685 - * a certain register (to be used in assembler memory operands).
15686 - */
15687 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15688 -
15689 +/* how to get the current stack pointer from C */
15690 +register unsigned long current_stack_pointer asm("rsp") __used;
15691 #endif
15692
15693 #endif /* !X86_32 */
15694 @@ -283,5 +255,12 @@ static inline bool is_ia32_task(void)
15695 extern void arch_task_cache_init(void);
15696 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15697 extern void arch_release_task_struct(struct task_struct *tsk);
15698 +
15699 +#define __HAVE_THREAD_FUNCTIONS
15700 +#define task_thread_info(task) (&(task)->tinfo)
15701 +#define task_stack_page(task) ((task)->stack)
15702 +#define setup_thread_stack(p, org) do {} while (0)
15703 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15704 +
15705 #endif
15706 #endif /* _ASM_X86_THREAD_INFO_H */
15707 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15708 index 5ee2687..70d5895 100644
15709 --- a/arch/x86/include/asm/uaccess.h
15710 +++ b/arch/x86/include/asm/uaccess.h
15711 @@ -7,6 +7,7 @@
15712 #include <linux/compiler.h>
15713 #include <linux/thread_info.h>
15714 #include <linux/string.h>
15715 +#include <linux/sched.h>
15716 #include <asm/asm.h>
15717 #include <asm/page.h>
15718 #include <asm/smap.h>
15719 @@ -29,7 +30,12 @@
15720
15721 #define get_ds() (KERNEL_DS)
15722 #define get_fs() (current_thread_info()->addr_limit)
15723 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15724 +void __set_fs(mm_segment_t x);
15725 +void set_fs(mm_segment_t x);
15726 +#else
15727 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15728 +#endif
15729
15730 #define segment_eq(a, b) ((a).seg == (b).seg)
15731
15732 @@ -77,8 +83,33 @@
15733 * checks that the pointer is in the user space range - after calling
15734 * this function, memory access functions may still return -EFAULT.
15735 */
15736 -#define access_ok(type, addr, size) \
15737 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15738 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15739 +#define access_ok(type, addr, size) \
15740 +({ \
15741 + long __size = size; \
15742 + unsigned long __addr = (unsigned long)addr; \
15743 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15744 + unsigned long __end_ao = __addr + __size - 1; \
15745 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15746 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15747 + while(__addr_ao <= __end_ao) { \
15748 + char __c_ao; \
15749 + __addr_ao += PAGE_SIZE; \
15750 + if (__size > PAGE_SIZE) \
15751 + cond_resched(); \
15752 + if (__get_user(__c_ao, (char __user *)__addr)) \
15753 + break; \
15754 + if (type != VERIFY_WRITE) { \
15755 + __addr = __addr_ao; \
15756 + continue; \
15757 + } \
15758 + if (__put_user(__c_ao, (char __user *)__addr)) \
15759 + break; \
15760 + __addr = __addr_ao; \
15761 + } \
15762 + } \
15763 + __ret_ao; \
15764 +})
15765
15766 /*
15767 * The exception table consists of pairs of addresses relative to the
15768 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15769 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15770 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15771
15772 -
15773 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15774 +#define __copyuser_seg "gs;"
15775 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15776 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15777 +#else
15778 +#define __copyuser_seg
15779 +#define __COPYUSER_SET_ES
15780 +#define __COPYUSER_RESTORE_ES
15781 +#endif
15782
15783 #ifdef CONFIG_X86_32
15784 #define __put_user_asm_u64(x, addr, err, errret) \
15785 asm volatile(ASM_STAC "\n" \
15786 - "1: movl %%eax,0(%2)\n" \
15787 - "2: movl %%edx,4(%2)\n" \
15788 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15789 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15790 "3: " ASM_CLAC "\n" \
15791 ".section .fixup,\"ax\"\n" \
15792 "4: movl %3,%0\n" \
15793 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15794
15795 #define __put_user_asm_ex_u64(x, addr) \
15796 asm volatile(ASM_STAC "\n" \
15797 - "1: movl %%eax,0(%1)\n" \
15798 - "2: movl %%edx,4(%1)\n" \
15799 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15800 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15801 "3: " ASM_CLAC "\n" \
15802 _ASM_EXTABLE_EX(1b, 2b) \
15803 _ASM_EXTABLE_EX(2b, 3b) \
15804 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15805 __typeof__(*(ptr)) __pu_val; \
15806 __chk_user_ptr(ptr); \
15807 might_fault(); \
15808 - __pu_val = x; \
15809 + __pu_val = (x); \
15810 switch (sizeof(*(ptr))) { \
15811 case 1: \
15812 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15813 @@ -345,7 +384,7 @@ do { \
15814
15815 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15816 asm volatile(ASM_STAC "\n" \
15817 - "1: mov"itype" %2,%"rtype"1\n" \
15818 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15819 "2: " ASM_CLAC "\n" \
15820 ".section .fixup,\"ax\"\n" \
15821 "3: mov %3,%0\n" \
15822 @@ -353,7 +392,7 @@ do { \
15823 " jmp 2b\n" \
15824 ".previous\n" \
15825 _ASM_EXTABLE(1b, 3b) \
15826 - : "=r" (err), ltype(x) \
15827 + : "=r" (err), ltype (x) \
15828 : "m" (__m(addr)), "i" (errret), "0" (err))
15829
15830 #define __get_user_size_ex(x, ptr, size) \
15831 @@ -378,7 +417,7 @@ do { \
15832 } while (0)
15833
15834 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15835 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15836 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15837 "2:\n" \
15838 _ASM_EXTABLE_EX(1b, 2b) \
15839 : ltype(x) : "m" (__m(addr)))
15840 @@ -395,13 +434,24 @@ do { \
15841 int __gu_err; \
15842 unsigned long __gu_val; \
15843 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15844 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15845 + (x) = (__typeof__(*(ptr)))__gu_val; \
15846 __gu_err; \
15847 })
15848
15849 /* FIXME: this hack is definitely wrong -AK */
15850 struct __large_struct { unsigned long buf[100]; };
15851 -#define __m(x) (*(struct __large_struct __user *)(x))
15852 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15853 +#define ____m(x) \
15854 +({ \
15855 + unsigned long ____x = (unsigned long)(x); \
15856 + if (____x < pax_user_shadow_base) \
15857 + ____x += pax_user_shadow_base; \
15858 + (typeof(x))____x; \
15859 +})
15860 +#else
15861 +#define ____m(x) (x)
15862 +#endif
15863 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15864
15865 /*
15866 * Tell gcc we read from memory instead of writing: this is because
15867 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15868 */
15869 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15870 asm volatile(ASM_STAC "\n" \
15871 - "1: mov"itype" %"rtype"1,%2\n" \
15872 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15873 "2: " ASM_CLAC "\n" \
15874 ".section .fixup,\"ax\"\n" \
15875 "3: mov %3,%0\n" \
15876 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15877 ".previous\n" \
15878 _ASM_EXTABLE(1b, 3b) \
15879 : "=r"(err) \
15880 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15881 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15882
15883 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15884 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15885 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15886 "2:\n" \
15887 _ASM_EXTABLE_EX(1b, 2b) \
15888 : : ltype(x), "m" (__m(addr)))
15889 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15890 * On error, the variable @x is set to zero.
15891 */
15892
15893 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15894 +#define __get_user(x, ptr) get_user((x), (ptr))
15895 +#else
15896 #define __get_user(x, ptr) \
15897 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15898 +#endif
15899
15900 /**
15901 * __put_user: - Write a simple value into user space, with less checking.
15902 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15903 * Returns zero on success, or -EFAULT on error.
15904 */
15905
15906 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15907 +#define __put_user(x, ptr) put_user((x), (ptr))
15908 +#else
15909 #define __put_user(x, ptr) \
15910 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15911 +#endif
15912
15913 #define __get_user_unaligned __get_user
15914 #define __put_user_unaligned __put_user
15915 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15916 #define get_user_ex(x, ptr) do { \
15917 unsigned long __gue_val; \
15918 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15919 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15920 + (x) = (__typeof__(*(ptr)))__gue_val; \
15921 } while (0)
15922
15923 #define put_user_try uaccess_try
15924 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15925 extern __must_check long strlen_user(const char __user *str);
15926 extern __must_check long strnlen_user(const char __user *str, long n);
15927
15928 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15929 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15930 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15931 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15932
15933 /*
15934 * movsl can be slow when source and dest are not both 8-byte aligned
15935 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15936 index 7f760a9..04b1c65 100644
15937 --- a/arch/x86/include/asm/uaccess_32.h
15938 +++ b/arch/x86/include/asm/uaccess_32.h
15939 @@ -11,15 +11,15 @@
15940 #include <asm/page.h>
15941
15942 unsigned long __must_check __copy_to_user_ll
15943 - (void __user *to, const void *from, unsigned long n);
15944 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15945 unsigned long __must_check __copy_from_user_ll
15946 - (void *to, const void __user *from, unsigned long n);
15947 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15948 unsigned long __must_check __copy_from_user_ll_nozero
15949 - (void *to, const void __user *from, unsigned long n);
15950 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15951 unsigned long __must_check __copy_from_user_ll_nocache
15952 - (void *to, const void __user *from, unsigned long n);
15953 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15954 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15955 - (void *to, const void __user *from, unsigned long n);
15956 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15957
15958 /**
15959 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15960 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15961 static __always_inline unsigned long __must_check
15962 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15963 {
15964 + if ((long)n < 0)
15965 + return n;
15966 +
15967 + check_object_size(from, n, true);
15968 +
15969 if (__builtin_constant_p(n)) {
15970 unsigned long ret;
15971
15972 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15973 __copy_to_user(void __user *to, const void *from, unsigned long n)
15974 {
15975 might_fault();
15976 +
15977 return __copy_to_user_inatomic(to, from, n);
15978 }
15979
15980 static __always_inline unsigned long
15981 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15982 {
15983 + if ((long)n < 0)
15984 + return n;
15985 +
15986 /* Avoid zeroing the tail if the copy fails..
15987 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15988 * but as the zeroing behaviour is only significant when n is not
15989 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15990 __copy_from_user(void *to, const void __user *from, unsigned long n)
15991 {
15992 might_fault();
15993 +
15994 + if ((long)n < 0)
15995 + return n;
15996 +
15997 + check_object_size(to, n, false);
15998 +
15999 if (__builtin_constant_p(n)) {
16000 unsigned long ret;
16001
16002 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16003 const void __user *from, unsigned long n)
16004 {
16005 might_fault();
16006 +
16007 + if ((long)n < 0)
16008 + return n;
16009 +
16010 if (__builtin_constant_p(n)) {
16011 unsigned long ret;
16012
16013 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16014 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16015 unsigned long n)
16016 {
16017 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16018 + if ((long)n < 0)
16019 + return n;
16020 +
16021 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16022 }
16023
16024 -unsigned long __must_check copy_to_user(void __user *to,
16025 - const void *from, unsigned long n);
16026 -unsigned long __must_check _copy_from_user(void *to,
16027 - const void __user *from,
16028 - unsigned long n);
16029 -
16030 +extern void copy_to_user_overflow(void)
16031 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16032 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16033 +#else
16034 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16035 +#endif
16036 +;
16037
16038 extern void copy_from_user_overflow(void)
16039 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16040 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16041 #endif
16042 ;
16043
16044 -static inline unsigned long __must_check copy_from_user(void *to,
16045 - const void __user *from,
16046 - unsigned long n)
16047 +/**
16048 + * copy_to_user: - Copy a block of data into user space.
16049 + * @to: Destination address, in user space.
16050 + * @from: Source address, in kernel space.
16051 + * @n: Number of bytes to copy.
16052 + *
16053 + * Context: User context only. This function may sleep.
16054 + *
16055 + * Copy data from kernel space to user space.
16056 + *
16057 + * Returns number of bytes that could not be copied.
16058 + * On success, this will be zero.
16059 + */
16060 +static inline unsigned long __must_check
16061 +copy_to_user(void __user *to, const void *from, unsigned long n)
16062 {
16063 - int sz = __compiletime_object_size(to);
16064 + size_t sz = __compiletime_object_size(from);
16065
16066 - if (likely(sz == -1 || sz >= n))
16067 - n = _copy_from_user(to, from, n);
16068 - else
16069 + if (unlikely(sz != (size_t)-1 && sz < n))
16070 + copy_to_user_overflow();
16071 + else if (access_ok(VERIFY_WRITE, to, n))
16072 + n = __copy_to_user(to, from, n);
16073 + return n;
16074 +}
16075 +
16076 +/**
16077 + * copy_from_user: - Copy a block of data from user space.
16078 + * @to: Destination address, in kernel space.
16079 + * @from: Source address, in user space.
16080 + * @n: Number of bytes to copy.
16081 + *
16082 + * Context: User context only. This function may sleep.
16083 + *
16084 + * Copy data from user space to kernel space.
16085 + *
16086 + * Returns number of bytes that could not be copied.
16087 + * On success, this will be zero.
16088 + *
16089 + * If some data could not be copied, this function will pad the copied
16090 + * data to the requested size using zero bytes.
16091 + */
16092 +static inline unsigned long __must_check
16093 +copy_from_user(void *to, const void __user *from, unsigned long n)
16094 +{
16095 + size_t sz = __compiletime_object_size(to);
16096 +
16097 + check_object_size(to, n, false);
16098 +
16099 + if (unlikely(sz != (size_t)-1 && sz < n))
16100 copy_from_user_overflow();
16101 -
16102 + else if (access_ok(VERIFY_READ, from, n))
16103 + n = __copy_from_user(to, from, n);
16104 + else if ((long)n > 0)
16105 + memset(to, 0, n);
16106 return n;
16107 }
16108
16109 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16110 index 142810c..1f2a0a7 100644
16111 --- a/arch/x86/include/asm/uaccess_64.h
16112 +++ b/arch/x86/include/asm/uaccess_64.h
16113 @@ -10,6 +10,9 @@
16114 #include <asm/alternative.h>
16115 #include <asm/cpufeature.h>
16116 #include <asm/page.h>
16117 +#include <asm/pgtable.h>
16118 +
16119 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16120
16121 /*
16122 * Copy To/From Userspace
16123 @@ -17,13 +20,13 @@
16124
16125 /* Handles exceptions in both to and from, but doesn't do access_ok */
16126 __must_check unsigned long
16127 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16128 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16129 __must_check unsigned long
16130 -copy_user_generic_string(void *to, const void *from, unsigned len);
16131 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16132 __must_check unsigned long
16133 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16134 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16135
16136 -static __always_inline __must_check unsigned long
16137 +static __always_inline __must_check __size_overflow(3) unsigned long
16138 copy_user_generic(void *to, const void *from, unsigned len)
16139 {
16140 unsigned ret;
16141 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16142 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16143 "=d" (len)),
16144 "1" (to), "2" (from), "3" (len)
16145 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16146 + : "memory", "rcx", "r8", "r9", "r11");
16147 return ret;
16148 }
16149
16150 +static __always_inline __must_check unsigned long
16151 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16152 +static __always_inline __must_check unsigned long
16153 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16154 __must_check unsigned long
16155 -_copy_to_user(void __user *to, const void *from, unsigned len);
16156 -__must_check unsigned long
16157 -_copy_from_user(void *to, const void __user *from, unsigned len);
16158 -__must_check unsigned long
16159 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16160 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16161 +
16162 +extern void copy_to_user_overflow(void)
16163 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16164 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16165 +#else
16166 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16167 +#endif
16168 +;
16169 +
16170 +extern void copy_from_user_overflow(void)
16171 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16172 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16173 +#else
16174 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16175 +#endif
16176 +;
16177
16178 static inline unsigned long __must_check copy_from_user(void *to,
16179 const void __user *from,
16180 unsigned long n)
16181 {
16182 - int sz = __compiletime_object_size(to);
16183 -
16184 might_fault();
16185 - if (likely(sz == -1 || sz >= n))
16186 - n = _copy_from_user(to, from, n);
16187 -#ifdef CONFIG_DEBUG_VM
16188 - else
16189 - WARN(1, "Buffer overflow detected!\n");
16190 -#endif
16191 +
16192 + check_object_size(to, n, false);
16193 +
16194 + if (access_ok(VERIFY_READ, from, n))
16195 + n = __copy_from_user(to, from, n);
16196 + else if (n < INT_MAX)
16197 + memset(to, 0, n);
16198 return n;
16199 }
16200
16201 static __always_inline __must_check
16202 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16203 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16204 {
16205 might_fault();
16206
16207 - return _copy_to_user(dst, src, size);
16208 + if (access_ok(VERIFY_WRITE, dst, size))
16209 + size = __copy_to_user(dst, src, size);
16210 + return size;
16211 }
16212
16213 static __always_inline __must_check
16214 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16215 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16216 {
16217 - int ret = 0;
16218 + size_t sz = __compiletime_object_size(dst);
16219 + unsigned ret = 0;
16220
16221 might_fault();
16222 +
16223 + if (size > INT_MAX)
16224 + return size;
16225 +
16226 + check_object_size(dst, size, false);
16227 +
16228 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16229 + if (!__access_ok(VERIFY_READ, src, size))
16230 + return size;
16231 +#endif
16232 +
16233 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16234 + copy_from_user_overflow();
16235 + return size;
16236 + }
16237 +
16238 if (!__builtin_constant_p(size))
16239 - return copy_user_generic(dst, (__force void *)src, size);
16240 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16241 switch (size) {
16242 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16243 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16244 ret, "b", "b", "=q", 1);
16245 return ret;
16246 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16247 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16248 ret, "w", "w", "=r", 2);
16249 return ret;
16250 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16251 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16252 ret, "l", "k", "=r", 4);
16253 return ret;
16254 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16255 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16256 ret, "q", "", "=r", 8);
16257 return ret;
16258 case 10:
16259 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16260 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16261 ret, "q", "", "=r", 10);
16262 if (unlikely(ret))
16263 return ret;
16264 __get_user_asm(*(u16 *)(8 + (char *)dst),
16265 - (u16 __user *)(8 + (char __user *)src),
16266 + (const u16 __user *)(8 + (const char __user *)src),
16267 ret, "w", "w", "=r", 2);
16268 return ret;
16269 case 16:
16270 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16271 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16272 ret, "q", "", "=r", 16);
16273 if (unlikely(ret))
16274 return ret;
16275 __get_user_asm(*(u64 *)(8 + (char *)dst),
16276 - (u64 __user *)(8 + (char __user *)src),
16277 + (const u64 __user *)(8 + (const char __user *)src),
16278 ret, "q", "", "=r", 8);
16279 return ret;
16280 default:
16281 - return copy_user_generic(dst, (__force void *)src, size);
16282 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16283 }
16284 }
16285
16286 static __always_inline __must_check
16287 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16288 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16289 {
16290 - int ret = 0;
16291 + size_t sz = __compiletime_object_size(src);
16292 + unsigned ret = 0;
16293
16294 might_fault();
16295 +
16296 + if (size > INT_MAX)
16297 + return size;
16298 +
16299 + check_object_size(src, size, true);
16300 +
16301 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16302 + if (!__access_ok(VERIFY_WRITE, dst, size))
16303 + return size;
16304 +#endif
16305 +
16306 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16307 + copy_to_user_overflow();
16308 + return size;
16309 + }
16310 +
16311 if (!__builtin_constant_p(size))
16312 - return copy_user_generic((__force void *)dst, src, size);
16313 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16314 switch (size) {
16315 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16316 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16317 ret, "b", "b", "iq", 1);
16318 return ret;
16319 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16320 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16321 ret, "w", "w", "ir", 2);
16322 return ret;
16323 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16324 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16325 ret, "l", "k", "ir", 4);
16326 return ret;
16327 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16328 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16329 ret, "q", "", "er", 8);
16330 return ret;
16331 case 10:
16332 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16333 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16334 ret, "q", "", "er", 10);
16335 if (unlikely(ret))
16336 return ret;
16337 asm("":::"memory");
16338 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16339 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16340 ret, "w", "w", "ir", 2);
16341 return ret;
16342 case 16:
16343 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16344 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16345 ret, "q", "", "er", 16);
16346 if (unlikely(ret))
16347 return ret;
16348 asm("":::"memory");
16349 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16350 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16351 ret, "q", "", "er", 8);
16352 return ret;
16353 default:
16354 - return copy_user_generic((__force void *)dst, src, size);
16355 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16356 }
16357 }
16358
16359 static __always_inline __must_check
16360 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16361 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16362 {
16363 - int ret = 0;
16364 + unsigned ret = 0;
16365
16366 might_fault();
16367 +
16368 + if (size > INT_MAX)
16369 + return size;
16370 +
16371 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16372 + if (!__access_ok(VERIFY_READ, src, size))
16373 + return size;
16374 + if (!__access_ok(VERIFY_WRITE, dst, size))
16375 + return size;
16376 +#endif
16377 +
16378 if (!__builtin_constant_p(size))
16379 - return copy_user_generic((__force void *)dst,
16380 - (__force void *)src, size);
16381 + return copy_user_generic((__force_kernel void *)____m(dst),
16382 + (__force_kernel const void *)____m(src), size);
16383 switch (size) {
16384 case 1: {
16385 u8 tmp;
16386 - __get_user_asm(tmp, (u8 __user *)src,
16387 + __get_user_asm(tmp, (const u8 __user *)src,
16388 ret, "b", "b", "=q", 1);
16389 if (likely(!ret))
16390 __put_user_asm(tmp, (u8 __user *)dst,
16391 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16392 }
16393 case 2: {
16394 u16 tmp;
16395 - __get_user_asm(tmp, (u16 __user *)src,
16396 + __get_user_asm(tmp, (const u16 __user *)src,
16397 ret, "w", "w", "=r", 2);
16398 if (likely(!ret))
16399 __put_user_asm(tmp, (u16 __user *)dst,
16400 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16401
16402 case 4: {
16403 u32 tmp;
16404 - __get_user_asm(tmp, (u32 __user *)src,
16405 + __get_user_asm(tmp, (const u32 __user *)src,
16406 ret, "l", "k", "=r", 4);
16407 if (likely(!ret))
16408 __put_user_asm(tmp, (u32 __user *)dst,
16409 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16410 }
16411 case 8: {
16412 u64 tmp;
16413 - __get_user_asm(tmp, (u64 __user *)src,
16414 + __get_user_asm(tmp, (const u64 __user *)src,
16415 ret, "q", "", "=r", 8);
16416 if (likely(!ret))
16417 __put_user_asm(tmp, (u64 __user *)dst,
16418 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16419 return ret;
16420 }
16421 default:
16422 - return copy_user_generic((__force void *)dst,
16423 - (__force void *)src, size);
16424 + return copy_user_generic((__force_kernel void *)____m(dst),
16425 + (__force_kernel const void *)____m(src), size);
16426 }
16427 }
16428
16429 static __must_check __always_inline int
16430 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16431 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16432 {
16433 - return copy_user_generic(dst, (__force const void *)src, size);
16434 + if (size > INT_MAX)
16435 + return size;
16436 +
16437 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16438 + if (!__access_ok(VERIFY_READ, src, size))
16439 + return size;
16440 +#endif
16441 +
16442 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16443 }
16444
16445 -static __must_check __always_inline int
16446 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16447 +static __must_check __always_inline unsigned long
16448 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16449 {
16450 - return copy_user_generic((__force void *)dst, src, size);
16451 + if (size > INT_MAX)
16452 + return size;
16453 +
16454 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16455 + if (!__access_ok(VERIFY_WRITE, dst, size))
16456 + return size;
16457 +#endif
16458 +
16459 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16460 }
16461
16462 -extern long __copy_user_nocache(void *dst, const void __user *src,
16463 - unsigned size, int zerorest);
16464 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16465 + unsigned long size, int zerorest) __size_overflow(3);
16466
16467 -static inline int
16468 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16469 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16470 {
16471 might_sleep();
16472 +
16473 + if (size > INT_MAX)
16474 + return size;
16475 +
16476 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16477 + if (!__access_ok(VERIFY_READ, src, size))
16478 + return size;
16479 +#endif
16480 +
16481 return __copy_user_nocache(dst, src, size, 1);
16482 }
16483
16484 -static inline int
16485 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16486 - unsigned size)
16487 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16488 + unsigned long size)
16489 {
16490 + if (size > INT_MAX)
16491 + return size;
16492 +
16493 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16494 + if (!__access_ok(VERIFY_READ, src, size))
16495 + return size;
16496 +#endif
16497 +
16498 return __copy_user_nocache(dst, src, size, 0);
16499 }
16500
16501 -unsigned long
16502 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16503 +extern unsigned long
16504 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16505
16506 #endif /* _ASM_X86_UACCESS_64_H */
16507 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16508 index 5b238981..77fdd78 100644
16509 --- a/arch/x86/include/asm/word-at-a-time.h
16510 +++ b/arch/x86/include/asm/word-at-a-time.h
16511 @@ -11,7 +11,7 @@
16512 * and shift, for example.
16513 */
16514 struct word_at_a_time {
16515 - const unsigned long one_bits, high_bits;
16516 + unsigned long one_bits, high_bits;
16517 };
16518
16519 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16520 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16521 index d8d9922..bf6cecb 100644
16522 --- a/arch/x86/include/asm/x86_init.h
16523 +++ b/arch/x86/include/asm/x86_init.h
16524 @@ -129,7 +129,7 @@ struct x86_init_ops {
16525 struct x86_init_timers timers;
16526 struct x86_init_iommu iommu;
16527 struct x86_init_pci pci;
16528 -};
16529 +} __no_const;
16530
16531 /**
16532 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16533 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16534 void (*setup_percpu_clockev)(void);
16535 void (*early_percpu_clock_init)(void);
16536 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16537 -};
16538 +} __no_const;
16539
16540 /**
16541 * struct x86_platform_ops - platform specific runtime functions
16542 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16543 void (*save_sched_clock_state)(void);
16544 void (*restore_sched_clock_state)(void);
16545 void (*apic_post_init)(void);
16546 -};
16547 +} __no_const;
16548
16549 struct pci_dev;
16550 struct msi_msg;
16551 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16552 void (*teardown_msi_irqs)(struct pci_dev *dev);
16553 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16554 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16555 -};
16556 +} __no_const;
16557
16558 struct IO_APIC_route_entry;
16559 struct io_apic_irq_attr;
16560 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16561 unsigned int destination, int vector,
16562 struct io_apic_irq_attr *attr);
16563 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16564 -};
16565 +} __no_const;
16566
16567 extern struct x86_init_ops x86_init;
16568 extern struct x86_cpuinit_ops x86_cpuinit;
16569 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16570 index 0415cda..b43d877 100644
16571 --- a/arch/x86/include/asm/xsave.h
16572 +++ b/arch/x86/include/asm/xsave.h
16573 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16574 return -EFAULT;
16575
16576 __asm__ __volatile__(ASM_STAC "\n"
16577 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16578 + "1:"
16579 + __copyuser_seg
16580 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16581 "2: " ASM_CLAC "\n"
16582 ".section .fixup,\"ax\"\n"
16583 "3: movl $-1,%[err]\n"
16584 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16585 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16586 {
16587 int err;
16588 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16589 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16590 u32 lmask = mask;
16591 u32 hmask = mask >> 32;
16592
16593 __asm__ __volatile__(ASM_STAC "\n"
16594 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16595 + "1:"
16596 + __copyuser_seg
16597 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16598 "2: " ASM_CLAC "\n"
16599 ".section .fixup,\"ax\"\n"
16600 "3: movl $-1,%[err]\n"
16601 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16602 index bbae024..e1528f9 100644
16603 --- a/arch/x86/include/uapi/asm/e820.h
16604 +++ b/arch/x86/include/uapi/asm/e820.h
16605 @@ -63,7 +63,7 @@ struct e820map {
16606 #define ISA_START_ADDRESS 0xa0000
16607 #define ISA_END_ADDRESS 0x100000
16608
16609 -#define BIOS_BEGIN 0x000a0000
16610 +#define BIOS_BEGIN 0x000c0000
16611 #define BIOS_END 0x00100000
16612
16613 #define BIOS_ROM_BASE 0xffe00000
16614 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16615 index 7bd3bd3..5dac791 100644
16616 --- a/arch/x86/kernel/Makefile
16617 +++ b/arch/x86/kernel/Makefile
16618 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16619 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16620 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16621 obj-y += probe_roms.o
16622 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16623 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16624 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16625 obj-y += syscall_$(BITS).o
16626 obj-$(CONFIG_X86_64) += vsyscall_64.o
16627 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16628 index 230c8ea..f915130 100644
16629 --- a/arch/x86/kernel/acpi/boot.c
16630 +++ b/arch/x86/kernel/acpi/boot.c
16631 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16632 * If your system is blacklisted here, but you find that acpi=force
16633 * works for you, please contact linux-acpi@vger.kernel.org
16634 */
16635 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16636 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16637 /*
16638 * Boxes that need ACPI disabled
16639 */
16640 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16641 };
16642
16643 /* second table for DMI checks that should run after early-quirks */
16644 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16645 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16646 /*
16647 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16648 * which includes some code which overrides all temperature
16649 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16650 index b44577b..27d8443 100644
16651 --- a/arch/x86/kernel/acpi/sleep.c
16652 +++ b/arch/x86/kernel/acpi/sleep.c
16653 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16654 #else /* CONFIG_64BIT */
16655 #ifdef CONFIG_SMP
16656 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16657 +
16658 + pax_open_kernel();
16659 early_gdt_descr.address =
16660 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16661 + pax_close_kernel();
16662 +
16663 initial_gs = per_cpu_offset(smp_processor_id());
16664 #endif
16665 initial_code = (unsigned long)wakeup_long64;
16666 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16667 index d1daa66..59fecba 100644
16668 --- a/arch/x86/kernel/acpi/wakeup_32.S
16669 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16670 @@ -29,13 +29,11 @@ wakeup_pmode_return:
16671 # and restore the stack ... but you need gdt for this to work
16672 movl saved_context_esp, %esp
16673
16674 - movl %cs:saved_magic, %eax
16675 - cmpl $0x12345678, %eax
16676 + cmpl $0x12345678, saved_magic
16677 jne bogus_magic
16678
16679 # jump to place where we left off
16680 - movl saved_eip, %eax
16681 - jmp *%eax
16682 + jmp *(saved_eip)
16683
16684 bogus_magic:
16685 jmp bogus_magic
16686 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16687 index c15cf9a..0e63558 100644
16688 --- a/arch/x86/kernel/alternative.c
16689 +++ b/arch/x86/kernel/alternative.c
16690 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16691 */
16692 for (a = start; a < end; a++) {
16693 instr = (u8 *)&a->instr_offset + a->instr_offset;
16694 +
16695 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16696 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16697 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16698 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16699 +#endif
16700 +
16701 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16702 BUG_ON(a->replacementlen > a->instrlen);
16703 BUG_ON(a->instrlen > sizeof(insnbuf));
16704 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16705 for (poff = start; poff < end; poff++) {
16706 u8 *ptr = (u8 *)poff + *poff;
16707
16708 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16709 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16710 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16711 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16712 +#endif
16713 +
16714 if (!*poff || ptr < text || ptr >= text_end)
16715 continue;
16716 /* turn DS segment override prefix into lock prefix */
16717 - if (*ptr == 0x3e)
16718 + if (*ktla_ktva(ptr) == 0x3e)
16719 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16720 }
16721 mutex_unlock(&text_mutex);
16722 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16723 for (poff = start; poff < end; poff++) {
16724 u8 *ptr = (u8 *)poff + *poff;
16725
16726 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16727 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16728 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16729 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16730 +#endif
16731 +
16732 if (!*poff || ptr < text || ptr >= text_end)
16733 continue;
16734 /* turn lock prefix into DS segment override prefix */
16735 - if (*ptr == 0xf0)
16736 + if (*ktla_ktva(ptr) == 0xf0)
16737 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16738 }
16739 mutex_unlock(&text_mutex);
16740 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16741
16742 BUG_ON(p->len > MAX_PATCH_LEN);
16743 /* prep the buffer with the original instructions */
16744 - memcpy(insnbuf, p->instr, p->len);
16745 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16746 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16747 (unsigned long)p->instr, p->len);
16748
16749 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16750 if (!uniproc_patched || num_possible_cpus() == 1)
16751 free_init_pages("SMP alternatives",
16752 (unsigned long)__smp_locks,
16753 - (unsigned long)__smp_locks_end);
16754 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16755 #endif
16756
16757 apply_paravirt(__parainstructions, __parainstructions_end);
16758 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16759 * instructions. And on the local CPU you need to be protected again NMI or MCE
16760 * handlers seeing an inconsistent instruction while you patch.
16761 */
16762 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16763 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16764 size_t len)
16765 {
16766 unsigned long flags;
16767 local_irq_save(flags);
16768 - memcpy(addr, opcode, len);
16769 +
16770 + pax_open_kernel();
16771 + memcpy(ktla_ktva(addr), opcode, len);
16772 sync_core();
16773 + pax_close_kernel();
16774 +
16775 local_irq_restore(flags);
16776 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16777 that causes hangs on some VIA CPUs. */
16778 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16779 */
16780 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16781 {
16782 - unsigned long flags;
16783 - char *vaddr;
16784 + unsigned char *vaddr = ktla_ktva(addr);
16785 struct page *pages[2];
16786 - int i;
16787 + size_t i;
16788
16789 if (!core_kernel_text((unsigned long)addr)) {
16790 - pages[0] = vmalloc_to_page(addr);
16791 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16792 + pages[0] = vmalloc_to_page(vaddr);
16793 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16794 } else {
16795 - pages[0] = virt_to_page(addr);
16796 + pages[0] = virt_to_page(vaddr);
16797 WARN_ON(!PageReserved(pages[0]));
16798 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16799 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16800 }
16801 BUG_ON(!pages[0]);
16802 - local_irq_save(flags);
16803 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16804 - if (pages[1])
16805 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16806 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16807 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16808 - clear_fixmap(FIX_TEXT_POKE0);
16809 - if (pages[1])
16810 - clear_fixmap(FIX_TEXT_POKE1);
16811 - local_flush_tlb();
16812 - sync_core();
16813 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16814 - that causes hangs on some VIA CPUs. */
16815 + text_poke_early(addr, opcode, len);
16816 for (i = 0; i < len; i++)
16817 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16818 - local_irq_restore(flags);
16819 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16820 return addr;
16821 }
16822
16823 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16824 index 904611b..004dde6 100644
16825 --- a/arch/x86/kernel/apic/apic.c
16826 +++ b/arch/x86/kernel/apic/apic.c
16827 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16828 /*
16829 * Debug level, exported for io_apic.c
16830 */
16831 -unsigned int apic_verbosity;
16832 +int apic_verbosity;
16833
16834 int pic_mode;
16835
16836 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16837 apic_write(APIC_ESR, 0);
16838 v1 = apic_read(APIC_ESR);
16839 ack_APIC_irq();
16840 - atomic_inc(&irq_err_count);
16841 + atomic_inc_unchecked(&irq_err_count);
16842
16843 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16844 smp_processor_id(), v0 , v1);
16845 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16846 index 00c77cf..2dc6a2d 100644
16847 --- a/arch/x86/kernel/apic/apic_flat_64.c
16848 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16849 @@ -157,7 +157,7 @@ static int flat_probe(void)
16850 return 1;
16851 }
16852
16853 -static struct apic apic_flat = {
16854 +static struct apic apic_flat __read_only = {
16855 .name = "flat",
16856 .probe = flat_probe,
16857 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16858 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16859 return 0;
16860 }
16861
16862 -static struct apic apic_physflat = {
16863 +static struct apic apic_physflat __read_only = {
16864
16865 .name = "physical flat",
16866 .probe = physflat_probe,
16867 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16868 index e145f28..2752888 100644
16869 --- a/arch/x86/kernel/apic/apic_noop.c
16870 +++ b/arch/x86/kernel/apic/apic_noop.c
16871 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16872 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16873 }
16874
16875 -struct apic apic_noop = {
16876 +struct apic apic_noop __read_only = {
16877 .name = "noop",
16878 .probe = noop_probe,
16879 .acpi_madt_oem_check = NULL,
16880 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16881 index d50e364..543bee3 100644
16882 --- a/arch/x86/kernel/apic/bigsmp_32.c
16883 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16884 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16885 return dmi_bigsmp;
16886 }
16887
16888 -static struct apic apic_bigsmp = {
16889 +static struct apic apic_bigsmp __read_only = {
16890
16891 .name = "bigsmp",
16892 .probe = probe_bigsmp,
16893 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16894 index 0874799..a7a7892 100644
16895 --- a/arch/x86/kernel/apic/es7000_32.c
16896 +++ b/arch/x86/kernel/apic/es7000_32.c
16897 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16898 return ret && es7000_apic_is_cluster();
16899 }
16900
16901 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16902 -static struct apic __refdata apic_es7000_cluster = {
16903 +static struct apic apic_es7000_cluster __read_only = {
16904
16905 .name = "es7000",
16906 .probe = probe_es7000,
16907 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16908 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16909 };
16910
16911 -static struct apic __refdata apic_es7000 = {
16912 +static struct apic apic_es7000 __read_only = {
16913
16914 .name = "es7000",
16915 .probe = probe_es7000,
16916 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16917 index 9ed796c..e930fe4 100644
16918 --- a/arch/x86/kernel/apic/io_apic.c
16919 +++ b/arch/x86/kernel/apic/io_apic.c
16920 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16921 }
16922 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16923
16924 -void lock_vector_lock(void)
16925 +void lock_vector_lock(void) __acquires(vector_lock)
16926 {
16927 /* Used to the online set of cpus does not change
16928 * during assign_irq_vector.
16929 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16930 raw_spin_lock(&vector_lock);
16931 }
16932
16933 -void unlock_vector_lock(void)
16934 +void unlock_vector_lock(void) __releases(vector_lock)
16935 {
16936 raw_spin_unlock(&vector_lock);
16937 }
16938 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16939 ack_APIC_irq();
16940 }
16941
16942 -atomic_t irq_mis_count;
16943 +atomic_unchecked_t irq_mis_count;
16944
16945 #ifdef CONFIG_GENERIC_PENDING_IRQ
16946 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16947 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16948 * at the cpu.
16949 */
16950 if (!(v & (1 << (i & 0x1f)))) {
16951 - atomic_inc(&irq_mis_count);
16952 + atomic_inc_unchecked(&irq_mis_count);
16953
16954 eoi_ioapic_irq(irq, cfg);
16955 }
16956 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16957 index d661ee9..791fd33 100644
16958 --- a/arch/x86/kernel/apic/numaq_32.c
16959 +++ b/arch/x86/kernel/apic/numaq_32.c
16960 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16961 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16962 }
16963
16964 -/* Use __refdata to keep false positive warning calm. */
16965 -static struct apic __refdata apic_numaq = {
16966 +static struct apic apic_numaq __read_only = {
16967
16968 .name = "NUMAQ",
16969 .probe = probe_numaq,
16970 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16971 index eb35ef9..f184a21 100644
16972 --- a/arch/x86/kernel/apic/probe_32.c
16973 +++ b/arch/x86/kernel/apic/probe_32.c
16974 @@ -72,7 +72,7 @@ static int probe_default(void)
16975 return 1;
16976 }
16977
16978 -static struct apic apic_default = {
16979 +static struct apic apic_default __read_only = {
16980
16981 .name = "default",
16982 .probe = probe_default,
16983 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16984 index 77c95c0..434f8a4 100644
16985 --- a/arch/x86/kernel/apic/summit_32.c
16986 +++ b/arch/x86/kernel/apic/summit_32.c
16987 @@ -486,7 +486,7 @@ void setup_summit(void)
16988 }
16989 #endif
16990
16991 -static struct apic apic_summit = {
16992 +static struct apic apic_summit __read_only = {
16993
16994 .name = "summit",
16995 .probe = probe_summit,
16996 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16997 index c88baa4..757aee1 100644
16998 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16999 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17000 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17001 return notifier_from_errno(err);
17002 }
17003
17004 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17005 +static struct notifier_block x2apic_cpu_notifier = {
17006 .notifier_call = update_clusterinfo,
17007 };
17008
17009 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17010 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17011 }
17012
17013 -static struct apic apic_x2apic_cluster = {
17014 +static struct apic apic_x2apic_cluster __read_only = {
17015
17016 .name = "cluster x2apic",
17017 .probe = x2apic_cluster_probe,
17018 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17019 index 562a76d..a003c0f 100644
17020 --- a/arch/x86/kernel/apic/x2apic_phys.c
17021 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17022 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17023 return apic == &apic_x2apic_phys;
17024 }
17025
17026 -static struct apic apic_x2apic_phys = {
17027 +static struct apic apic_x2apic_phys __read_only = {
17028
17029 .name = "physical x2apic",
17030 .probe = x2apic_phys_probe,
17031 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17032 index 794f6eb..67e1db2 100644
17033 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17034 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17035 @@ -342,7 +342,7 @@ static int uv_probe(void)
17036 return apic == &apic_x2apic_uv_x;
17037 }
17038
17039 -static struct apic __refdata apic_x2apic_uv_x = {
17040 +static struct apic apic_x2apic_uv_x __read_only = {
17041
17042 .name = "UV large system",
17043 .probe = uv_probe,
17044 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17045 index 53a4e27..038760a 100644
17046 --- a/arch/x86/kernel/apm_32.c
17047 +++ b/arch/x86/kernel/apm_32.c
17048 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
17049 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17050 * even though they are called in protected mode.
17051 */
17052 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17053 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17054 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17055
17056 static const char driver_version[] = "1.16ac"; /* no spaces */
17057 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
17058 BUG_ON(cpu != 0);
17059 gdt = get_cpu_gdt_table(cpu);
17060 save_desc_40 = gdt[0x40 / 8];
17061 +
17062 + pax_open_kernel();
17063 gdt[0x40 / 8] = bad_bios_desc;
17064 + pax_close_kernel();
17065
17066 apm_irq_save(flags);
17067 APM_DO_SAVE_SEGS;
17068 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
17069 &call->esi);
17070 APM_DO_RESTORE_SEGS;
17071 apm_irq_restore(flags);
17072 +
17073 + pax_open_kernel();
17074 gdt[0x40 / 8] = save_desc_40;
17075 + pax_close_kernel();
17076 +
17077 put_cpu();
17078
17079 return call->eax & 0xff;
17080 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
17081 BUG_ON(cpu != 0);
17082 gdt = get_cpu_gdt_table(cpu);
17083 save_desc_40 = gdt[0x40 / 8];
17084 +
17085 + pax_open_kernel();
17086 gdt[0x40 / 8] = bad_bios_desc;
17087 + pax_close_kernel();
17088
17089 apm_irq_save(flags);
17090 APM_DO_SAVE_SEGS;
17091 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
17092 &call->eax);
17093 APM_DO_RESTORE_SEGS;
17094 apm_irq_restore(flags);
17095 +
17096 + pax_open_kernel();
17097 gdt[0x40 / 8] = save_desc_40;
17098 + pax_close_kernel();
17099 +
17100 put_cpu();
17101 return error;
17102 }
17103 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
17104 * code to that CPU.
17105 */
17106 gdt = get_cpu_gdt_table(0);
17107 +
17108 + pax_open_kernel();
17109 set_desc_base(&gdt[APM_CS >> 3],
17110 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17111 set_desc_base(&gdt[APM_CS_16 >> 3],
17112 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17113 set_desc_base(&gdt[APM_DS >> 3],
17114 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17115 + pax_close_kernel();
17116
17117 proc_create("apm", 0, NULL, &apm_file_ops);
17118
17119 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17120 index 2861082..6d4718e 100644
17121 --- a/arch/x86/kernel/asm-offsets.c
17122 +++ b/arch/x86/kernel/asm-offsets.c
17123 @@ -33,6 +33,8 @@ void common(void) {
17124 OFFSET(TI_status, thread_info, status);
17125 OFFSET(TI_addr_limit, thread_info, addr_limit);
17126 OFFSET(TI_preempt_count, thread_info, preempt_count);
17127 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17128 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17129
17130 BLANK();
17131 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17132 @@ -53,8 +55,26 @@ void common(void) {
17133 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17134 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17135 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17136 +
17137 +#ifdef CONFIG_PAX_KERNEXEC
17138 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17139 #endif
17140
17141 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17142 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17143 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17144 +#ifdef CONFIG_X86_64
17145 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17146 +#endif
17147 +#endif
17148 +
17149 +#endif
17150 +
17151 + BLANK();
17152 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17153 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17154 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17155 +
17156 #ifdef CONFIG_XEN
17157 BLANK();
17158 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17159 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17160 index e7c798b..2b2019b 100644
17161 --- a/arch/x86/kernel/asm-offsets_64.c
17162 +++ b/arch/x86/kernel/asm-offsets_64.c
17163 @@ -77,6 +77,7 @@ int main(void)
17164 BLANK();
17165 #undef ENTRY
17166
17167 + DEFINE(TSS_size, sizeof(struct tss_struct));
17168 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17169 BLANK();
17170
17171 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17172 index b0684e4..22ccfd7 100644
17173 --- a/arch/x86/kernel/cpu/Makefile
17174 +++ b/arch/x86/kernel/cpu/Makefile
17175 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17176 CFLAGS_REMOVE_perf_event.o = -pg
17177 endif
17178
17179 -# Make sure load_percpu_segment has no stackprotector
17180 -nostackp := $(call cc-option, -fno-stack-protector)
17181 -CFLAGS_common.o := $(nostackp)
17182 -
17183 obj-y := intel_cacheinfo.o scattered.o topology.o
17184 obj-y += proc.o capflags.o powerflags.o common.o
17185 obj-y += rdrand.o
17186 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17187 index 5013a48..0782c53 100644
17188 --- a/arch/x86/kernel/cpu/amd.c
17189 +++ b/arch/x86/kernel/cpu/amd.c
17190 @@ -744,7 +744,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17191 unsigned int size)
17192 {
17193 /* AMD errata T13 (order #21922) */
17194 - if ((c->x86 == 6)) {
17195 + if (c->x86 == 6) {
17196 /* Duron Rev A0 */
17197 if (c->x86_model == 3 && c->x86_mask == 0)
17198 size = 64;
17199 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17200 index 22018f7..bc6f5e3 100644
17201 --- a/arch/x86/kernel/cpu/common.c
17202 +++ b/arch/x86/kernel/cpu/common.c
17203 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17204
17205 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17206
17207 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17208 -#ifdef CONFIG_X86_64
17209 - /*
17210 - * We need valid kernel segments for data and code in long mode too
17211 - * IRET will check the segment types kkeil 2000/10/28
17212 - * Also sysret mandates a special GDT layout
17213 - *
17214 - * TLS descriptors are currently at a different place compared to i386.
17215 - * Hopefully nobody expects them at a fixed place (Wine?)
17216 - */
17217 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17218 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17219 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17220 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17221 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17222 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17223 -#else
17224 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17225 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17226 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17227 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17228 - /*
17229 - * Segments used for calling PnP BIOS have byte granularity.
17230 - * They code segments and data segments have fixed 64k limits,
17231 - * the transfer segment sizes are set at run time.
17232 - */
17233 - /* 32-bit code */
17234 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17235 - /* 16-bit code */
17236 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17237 - /* 16-bit data */
17238 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17239 - /* 16-bit data */
17240 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17241 - /* 16-bit data */
17242 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17243 - /*
17244 - * The APM segments have byte granularity and their bases
17245 - * are set at run time. All have 64k limits.
17246 - */
17247 - /* 32-bit code */
17248 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17249 - /* 16-bit code */
17250 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17251 - /* data */
17252 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17253 -
17254 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17255 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17256 - GDT_STACK_CANARY_INIT
17257 -#endif
17258 -} };
17259 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17260 -
17261 static int __init x86_xsave_setup(char *s)
17262 {
17263 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17264 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17265 {
17266 struct desc_ptr gdt_descr;
17267
17268 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17269 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17270 gdt_descr.size = GDT_SIZE - 1;
17271 load_gdt(&gdt_descr);
17272 /* Reload the per-cpu base */
17273 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17274 /* Filter out anything that depends on CPUID levels we don't have */
17275 filter_cpuid_features(c, true);
17276
17277 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17278 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17279 +#endif
17280 +
17281 /* If the model name is still unset, do table lookup. */
17282 if (!c->x86_model_id[0]) {
17283 const char *p;
17284 @@ -1069,10 +1019,12 @@ static __init int setup_disablecpuid(char *arg)
17285 }
17286 __setup("clearcpuid=", setup_disablecpuid);
17287
17288 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17289 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17290 +
17291 #ifdef CONFIG_X86_64
17292 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17293 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17294 - (unsigned long) nmi_idt_table };
17295 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17296
17297 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17298 irq_stack_union) __aligned(PAGE_SIZE);
17299 @@ -1086,7 +1038,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17300 EXPORT_PER_CPU_SYMBOL(current_task);
17301
17302 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17303 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17304 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17305 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17306
17307 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17308 @@ -1231,7 +1183,7 @@ void __cpuinit cpu_init(void)
17309 load_ucode_ap();
17310
17311 cpu = stack_smp_processor_id();
17312 - t = &per_cpu(init_tss, cpu);
17313 + t = init_tss + cpu;
17314 oist = &per_cpu(orig_ist, cpu);
17315
17316 #ifdef CONFIG_NUMA
17317 @@ -1257,7 +1209,7 @@ void __cpuinit cpu_init(void)
17318 switch_to_new_gdt(cpu);
17319 loadsegment(fs, 0);
17320
17321 - load_idt((const struct desc_ptr *)&idt_descr);
17322 + load_idt(&idt_descr);
17323
17324 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17325 syscall_init();
17326 @@ -1266,7 +1218,6 @@ void __cpuinit cpu_init(void)
17327 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17328 barrier();
17329
17330 - x86_configure_nx();
17331 enable_x2apic();
17332
17333 /*
17334 @@ -1318,7 +1269,7 @@ void __cpuinit cpu_init(void)
17335 {
17336 int cpu = smp_processor_id();
17337 struct task_struct *curr = current;
17338 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17339 + struct tss_struct *t = init_tss + cpu;
17340 struct thread_struct *thread = &curr->thread;
17341
17342 show_ucode_info_early();
17343 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17344 index 7c6f7d5..8cac382 100644
17345 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17346 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17347 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17348 };
17349
17350 #ifdef CONFIG_AMD_NB
17351 +static struct attribute *default_attrs_amd_nb[] = {
17352 + &type.attr,
17353 + &level.attr,
17354 + &coherency_line_size.attr,
17355 + &physical_line_partition.attr,
17356 + &ways_of_associativity.attr,
17357 + &number_of_sets.attr,
17358 + &size.attr,
17359 + &shared_cpu_map.attr,
17360 + &shared_cpu_list.attr,
17361 + NULL,
17362 + NULL,
17363 + NULL,
17364 + NULL
17365 +};
17366 +
17367 static struct attribute ** __cpuinit amd_l3_attrs(void)
17368 {
17369 static struct attribute **attrs;
17370 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17371
17372 n = ARRAY_SIZE(default_attrs);
17373
17374 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17375 - n += 2;
17376 -
17377 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17378 - n += 1;
17379 -
17380 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17381 - if (attrs == NULL)
17382 - return attrs = default_attrs;
17383 -
17384 - for (n = 0; default_attrs[n]; n++)
17385 - attrs[n] = default_attrs[n];
17386 + attrs = default_attrs_amd_nb;
17387
17388 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17389 attrs[n++] = &cache_disable_0.attr;
17390 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17391 .default_attrs = default_attrs,
17392 };
17393
17394 +#ifdef CONFIG_AMD_NB
17395 +static struct kobj_type ktype_cache_amd_nb = {
17396 + .sysfs_ops = &sysfs_ops,
17397 + .default_attrs = default_attrs_amd_nb,
17398 +};
17399 +#endif
17400 +
17401 static struct kobj_type ktype_percpu_entry = {
17402 .sysfs_ops = &sysfs_ops,
17403 };
17404 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17405 return retval;
17406 }
17407
17408 +#ifdef CONFIG_AMD_NB
17409 + amd_l3_attrs();
17410 +#endif
17411 +
17412 for (i = 0; i < num_cache_leaves; i++) {
17413 + struct kobj_type *ktype;
17414 +
17415 this_object = INDEX_KOBJECT_PTR(cpu, i);
17416 this_object->cpu = cpu;
17417 this_object->index = i;
17418
17419 this_leaf = CPUID4_INFO_IDX(cpu, i);
17420
17421 - ktype_cache.default_attrs = default_attrs;
17422 + ktype = &ktype_cache;
17423 #ifdef CONFIG_AMD_NB
17424 if (this_leaf->base.nb)
17425 - ktype_cache.default_attrs = amd_l3_attrs();
17426 + ktype = &ktype_cache_amd_nb;
17427 #endif
17428 retval = kobject_init_and_add(&(this_object->kobj),
17429 - &ktype_cache,
17430 + ktype,
17431 per_cpu(ici_cache_kobject, cpu),
17432 "index%1lu", i);
17433 if (unlikely(retval)) {
17434 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17435 return NOTIFY_OK;
17436 }
17437
17438 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17439 +static struct notifier_block cacheinfo_cpu_notifier = {
17440 .notifier_call = cacheinfo_cpu_callback,
17441 };
17442
17443 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17444 index 9239504..b2471ce 100644
17445 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17446 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17447 @@ -45,6 +45,7 @@
17448 #include <asm/processor.h>
17449 #include <asm/mce.h>
17450 #include <asm/msr.h>
17451 +#include <asm/local.h>
17452
17453 #include "mce-internal.h"
17454
17455 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17456 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17457 m->cs, m->ip);
17458
17459 - if (m->cs == __KERNEL_CS)
17460 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17461 print_symbol("{%s}", m->ip);
17462 pr_cont("\n");
17463 }
17464 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17465
17466 #define PANIC_TIMEOUT 5 /* 5 seconds */
17467
17468 -static atomic_t mce_paniced;
17469 +static atomic_unchecked_t mce_paniced;
17470
17471 static int fake_panic;
17472 -static atomic_t mce_fake_paniced;
17473 +static atomic_unchecked_t mce_fake_paniced;
17474
17475 /* Panic in progress. Enable interrupts and wait for final IPI */
17476 static void wait_for_panic(void)
17477 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17478 /*
17479 * Make sure only one CPU runs in machine check panic
17480 */
17481 - if (atomic_inc_return(&mce_paniced) > 1)
17482 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17483 wait_for_panic();
17484 barrier();
17485
17486 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17487 console_verbose();
17488 } else {
17489 /* Don't log too much for fake panic */
17490 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17491 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17492 return;
17493 }
17494 /* First print corrected ones that are still unlogged */
17495 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17496 if (!fake_panic) {
17497 if (panic_timeout == 0)
17498 panic_timeout = mca_cfg.panic_timeout;
17499 - panic(msg);
17500 + panic("%s", msg);
17501 } else
17502 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
17503 }
17504 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17505 * might have been modified by someone else.
17506 */
17507 rmb();
17508 - if (atomic_read(&mce_paniced))
17509 + if (atomic_read_unchecked(&mce_paniced))
17510 wait_for_panic();
17511 if (!mca_cfg.monarch_timeout)
17512 goto out;
17513 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17514 }
17515
17516 /* Call the installed machine check handler for this CPU setup. */
17517 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17518 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17519 unexpected_machine_check;
17520
17521 /*
17522 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17523 return;
17524 }
17525
17526 + pax_open_kernel();
17527 machine_check_vector = do_machine_check;
17528 + pax_close_kernel();
17529
17530 __mcheck_cpu_init_generic();
17531 __mcheck_cpu_init_vendor(c);
17532 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17533 */
17534
17535 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17536 -static int mce_chrdev_open_count; /* #times opened */
17537 +static local_t mce_chrdev_open_count; /* #times opened */
17538 static int mce_chrdev_open_exclu; /* already open exclusive? */
17539
17540 static int mce_chrdev_open(struct inode *inode, struct file *file)
17541 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17542 spin_lock(&mce_chrdev_state_lock);
17543
17544 if (mce_chrdev_open_exclu ||
17545 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17546 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17547 spin_unlock(&mce_chrdev_state_lock);
17548
17549 return -EBUSY;
17550 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17551
17552 if (file->f_flags & O_EXCL)
17553 mce_chrdev_open_exclu = 1;
17554 - mce_chrdev_open_count++;
17555 + local_inc(&mce_chrdev_open_count);
17556
17557 spin_unlock(&mce_chrdev_state_lock);
17558
17559 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17560 {
17561 spin_lock(&mce_chrdev_state_lock);
17562
17563 - mce_chrdev_open_count--;
17564 + local_dec(&mce_chrdev_open_count);
17565 mce_chrdev_open_exclu = 0;
17566
17567 spin_unlock(&mce_chrdev_state_lock);
17568 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17569 return NOTIFY_OK;
17570 }
17571
17572 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17573 +static struct notifier_block mce_cpu_notifier = {
17574 .notifier_call = mce_cpu_callback,
17575 };
17576
17577 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17578
17579 for (i = 0; i < mca_cfg.banks; i++) {
17580 struct mce_bank *b = &mce_banks[i];
17581 - struct device_attribute *a = &b->attr;
17582 + device_attribute_no_const *a = &b->attr;
17583
17584 sysfs_attr_init(&a->attr);
17585 a->attr.name = b->attrname;
17586 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17587 static void mce_reset(void)
17588 {
17589 cpu_missing = 0;
17590 - atomic_set(&mce_fake_paniced, 0);
17591 + atomic_set_unchecked(&mce_fake_paniced, 0);
17592 atomic_set(&mce_executing, 0);
17593 atomic_set(&mce_callin, 0);
17594 atomic_set(&global_nwo, 0);
17595 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17596 index 1c044b1..37a2a43 100644
17597 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17598 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17599 @@ -11,6 +11,7 @@
17600 #include <asm/processor.h>
17601 #include <asm/mce.h>
17602 #include <asm/msr.h>
17603 +#include <asm/pgtable.h>
17604
17605 /* By default disabled */
17606 int mce_p5_enabled __read_mostly;
17607 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17608 if (!cpu_has(c, X86_FEATURE_MCE))
17609 return;
17610
17611 + pax_open_kernel();
17612 machine_check_vector = pentium_machine_check;
17613 + pax_close_kernel();
17614 /* Make sure the vector pointer is visible before we enable MCEs: */
17615 wmb();
17616
17617 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17618 index 47a1870..8c019a7 100644
17619 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17620 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17621 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17622 return notifier_from_errno(err);
17623 }
17624
17625 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17626 +static struct notifier_block thermal_throttle_cpu_notifier =
17627 {
17628 .notifier_call = thermal_throttle_cpu_callback,
17629 };
17630 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17631 index e9a701a..35317d6 100644
17632 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17633 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17634 @@ -10,6 +10,7 @@
17635 #include <asm/processor.h>
17636 #include <asm/mce.h>
17637 #include <asm/msr.h>
17638 +#include <asm/pgtable.h>
17639
17640 /* Machine check handler for WinChip C6: */
17641 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17642 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17643 {
17644 u32 lo, hi;
17645
17646 + pax_open_kernel();
17647 machine_check_vector = winchip_machine_check;
17648 + pax_close_kernel();
17649 /* Make sure the vector pointer is visible before we enable MCEs: */
17650 wmb();
17651
17652 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17653 index 726bf96..81f0526 100644
17654 --- a/arch/x86/kernel/cpu/mtrr/main.c
17655 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17656 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17657 u64 size_or_mask, size_and_mask;
17658 static bool mtrr_aps_delayed_init;
17659
17660 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17661 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17662
17663 const struct mtrr_ops *mtrr_if;
17664
17665 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17666 index df5e41f..816c719 100644
17667 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17668 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17669 @@ -25,7 +25,7 @@ struct mtrr_ops {
17670 int (*validate_add_page)(unsigned long base, unsigned long size,
17671 unsigned int type);
17672 int (*have_wrcomb)(void);
17673 -};
17674 +} __do_const;
17675
17676 extern int generic_get_free_region(unsigned long base, unsigned long size,
17677 int replace_reg);
17678 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17679 index 1025f3c..824f677 100644
17680 --- a/arch/x86/kernel/cpu/perf_event.c
17681 +++ b/arch/x86/kernel/cpu/perf_event.c
17682 @@ -1311,7 +1311,7 @@ static void __init pmu_check_apic(void)
17683 pr_info("no hardware sampling interrupt available.\n");
17684 }
17685
17686 -static struct attribute_group x86_pmu_format_group = {
17687 +static attribute_group_no_const x86_pmu_format_group = {
17688 .name = "format",
17689 .attrs = NULL,
17690 };
17691 @@ -1410,7 +1410,7 @@ static struct attribute *events_attr[] = {
17692 NULL,
17693 };
17694
17695 -static struct attribute_group x86_pmu_events_group = {
17696 +static attribute_group_no_const x86_pmu_events_group = {
17697 .name = "events",
17698 .attrs = events_attr,
17699 };
17700 @@ -1920,7 +1920,7 @@ static unsigned long get_segment_base(unsigned int segment)
17701 if (idx > GDT_ENTRIES)
17702 return 0;
17703
17704 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17705 + desc = get_cpu_gdt_table(smp_processor_id());
17706 }
17707
17708 return get_desc_base(desc + idx);
17709 @@ -2010,7 +2010,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17710 break;
17711
17712 perf_callchain_store(entry, frame.return_address);
17713 - fp = frame.next_frame;
17714 + fp = (const void __force_user *)frame.next_frame;
17715 }
17716 }
17717
17718 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17719 index a9e2207..d70c83a 100644
17720 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17721 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17722 @@ -2022,10 +2022,10 @@ __init int intel_pmu_init(void)
17723 * v2 and above have a perf capabilities MSR
17724 */
17725 if (version > 1) {
17726 - u64 capabilities;
17727 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17728
17729 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17730 - x86_pmu.intel_cap.capabilities = capabilities;
17731 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17732 + x86_pmu.intel_cap.capabilities = capabilities;
17733 }
17734
17735 intel_ds_init();
17736 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17737 index 52441a2..f94fae8 100644
17738 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17739 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17740 @@ -3093,7 +3093,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17741 static int __init uncore_type_init(struct intel_uncore_type *type)
17742 {
17743 struct intel_uncore_pmu *pmus;
17744 - struct attribute_group *attr_group;
17745 + attribute_group_no_const *attr_group;
17746 struct attribute **attrs;
17747 int i, j;
17748
17749 @@ -3518,7 +3518,7 @@ static int
17750 return NOTIFY_OK;
17751 }
17752
17753 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17754 +static struct notifier_block uncore_cpu_nb = {
17755 .notifier_call = uncore_cpu_notifier,
17756 /*
17757 * to migrate uncore events, our notifier should be executed
17758 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17759 index f952891..4722ad4 100644
17760 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17761 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17762 @@ -488,7 +488,7 @@ struct intel_uncore_box {
17763 struct uncore_event_desc {
17764 struct kobj_attribute attr;
17765 const char *config;
17766 -};
17767 +} __do_const;
17768
17769 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17770 { \
17771 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17772 index 1e4dbcf..b9a34c2 100644
17773 --- a/arch/x86/kernel/cpuid.c
17774 +++ b/arch/x86/kernel/cpuid.c
17775 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17776 return notifier_from_errno(err);
17777 }
17778
17779 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17780 +static struct notifier_block cpuid_class_cpu_notifier =
17781 {
17782 .notifier_call = cpuid_class_cpu_callback,
17783 };
17784 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17785 index 74467fe..18793d5 100644
17786 --- a/arch/x86/kernel/crash.c
17787 +++ b/arch/x86/kernel/crash.c
17788 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17789 {
17790 #ifdef CONFIG_X86_32
17791 struct pt_regs fixed_regs;
17792 -#endif
17793
17794 -#ifdef CONFIG_X86_32
17795 - if (!user_mode_vm(regs)) {
17796 + if (!user_mode(regs)) {
17797 crash_fixup_ss_esp(&fixed_regs, regs);
17798 regs = &fixed_regs;
17799 }
17800 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17801 index afa64ad..dce67dd 100644
17802 --- a/arch/x86/kernel/crash_dump_64.c
17803 +++ b/arch/x86/kernel/crash_dump_64.c
17804 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17805 return -ENOMEM;
17806
17807 if (userbuf) {
17808 - if (copy_to_user(buf, vaddr + offset, csize)) {
17809 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17810 iounmap(vaddr);
17811 return -EFAULT;
17812 }
17813 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17814 index 155a13f..1672b9b 100644
17815 --- a/arch/x86/kernel/doublefault_32.c
17816 +++ b/arch/x86/kernel/doublefault_32.c
17817 @@ -11,7 +11,7 @@
17818
17819 #define DOUBLEFAULT_STACKSIZE (1024)
17820 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17821 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17822 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17823
17824 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17825
17826 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17827 unsigned long gdt, tss;
17828
17829 native_store_gdt(&gdt_desc);
17830 - gdt = gdt_desc.address;
17831 + gdt = (unsigned long)gdt_desc.address;
17832
17833 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17834
17835 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17836 /* 0x2 bit is always set */
17837 .flags = X86_EFLAGS_SF | 0x2,
17838 .sp = STACK_START,
17839 - .es = __USER_DS,
17840 + .es = __KERNEL_DS,
17841 .cs = __KERNEL_CS,
17842 .ss = __KERNEL_DS,
17843 - .ds = __USER_DS,
17844 + .ds = __KERNEL_DS,
17845 .fs = __KERNEL_PERCPU,
17846
17847 .__cr3 = __pa_nodebug(swapper_pg_dir),
17848 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17849 index deb6421..76bbc12 100644
17850 --- a/arch/x86/kernel/dumpstack.c
17851 +++ b/arch/x86/kernel/dumpstack.c
17852 @@ -2,6 +2,9 @@
17853 * Copyright (C) 1991, 1992 Linus Torvalds
17854 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17855 */
17856 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17857 +#define __INCLUDED_BY_HIDESYM 1
17858 +#endif
17859 #include <linux/kallsyms.h>
17860 #include <linux/kprobes.h>
17861 #include <linux/uaccess.h>
17862 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17863 static void
17864 print_ftrace_graph_addr(unsigned long addr, void *data,
17865 const struct stacktrace_ops *ops,
17866 - struct thread_info *tinfo, int *graph)
17867 + struct task_struct *task, int *graph)
17868 {
17869 - struct task_struct *task;
17870 unsigned long ret_addr;
17871 int index;
17872
17873 if (addr != (unsigned long)return_to_handler)
17874 return;
17875
17876 - task = tinfo->task;
17877 index = task->curr_ret_stack;
17878
17879 if (!task->ret_stack || index < *graph)
17880 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17881 static inline void
17882 print_ftrace_graph_addr(unsigned long addr, void *data,
17883 const struct stacktrace_ops *ops,
17884 - struct thread_info *tinfo, int *graph)
17885 + struct task_struct *task, int *graph)
17886 { }
17887 #endif
17888
17889 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17890 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17891 */
17892
17893 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17894 - void *p, unsigned int size, void *end)
17895 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17896 {
17897 - void *t = tinfo;
17898 if (end) {
17899 if (p < end && p >= (end-THREAD_SIZE))
17900 return 1;
17901 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17902 }
17903
17904 unsigned long
17905 -print_context_stack(struct thread_info *tinfo,
17906 +print_context_stack(struct task_struct *task, void *stack_start,
17907 unsigned long *stack, unsigned long bp,
17908 const struct stacktrace_ops *ops, void *data,
17909 unsigned long *end, int *graph)
17910 {
17911 struct stack_frame *frame = (struct stack_frame *)bp;
17912
17913 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17914 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17915 unsigned long addr;
17916
17917 addr = *stack;
17918 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17919 } else {
17920 ops->address(data, addr, 0);
17921 }
17922 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17923 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17924 }
17925 stack++;
17926 }
17927 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17928 EXPORT_SYMBOL_GPL(print_context_stack);
17929
17930 unsigned long
17931 -print_context_stack_bp(struct thread_info *tinfo,
17932 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17933 unsigned long *stack, unsigned long bp,
17934 const struct stacktrace_ops *ops, void *data,
17935 unsigned long *end, int *graph)
17936 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17937 struct stack_frame *frame = (struct stack_frame *)bp;
17938 unsigned long *ret_addr = &frame->return_address;
17939
17940 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17941 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17942 unsigned long addr = *ret_addr;
17943
17944 if (!__kernel_text_address(addr))
17945 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17946 ops->address(data, addr, 1);
17947 frame = frame->next_frame;
17948 ret_addr = &frame->return_address;
17949 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17950 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17951 }
17952
17953 return (unsigned long)frame;
17954 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
17955 static void print_trace_address(void *data, unsigned long addr, int reliable)
17956 {
17957 touch_nmi_watchdog();
17958 - printk(data);
17959 + printk("%s", (char *)data);
17960 printk_address(addr, reliable);
17961 }
17962
17963 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
17964 }
17965 EXPORT_SYMBOL_GPL(oops_begin);
17966
17967 +extern void gr_handle_kernel_exploit(void);
17968 +
17969 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17970 {
17971 if (regs && kexec_should_crash(current))
17972 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17973 panic("Fatal exception in interrupt");
17974 if (panic_on_oops)
17975 panic("Fatal exception");
17976 - do_exit(signr);
17977 +
17978 + gr_handle_kernel_exploit();
17979 +
17980 + do_group_exit(signr);
17981 }
17982
17983 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17984 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17985 print_modules();
17986 show_regs(regs);
17987 #ifdef CONFIG_X86_32
17988 - if (user_mode_vm(regs)) {
17989 + if (user_mode(regs)) {
17990 sp = regs->sp;
17991 ss = regs->ss & 0xffff;
17992 } else {
17993 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17994 unsigned long flags = oops_begin();
17995 int sig = SIGSEGV;
17996
17997 - if (!user_mode_vm(regs))
17998 + if (!user_mode(regs))
17999 report_bug(regs->ip, regs);
18000
18001 if (__die(str, regs, err))
18002 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18003 index f2a1770..540657f 100644
18004 --- a/arch/x86/kernel/dumpstack_32.c
18005 +++ b/arch/x86/kernel/dumpstack_32.c
18006 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18007 bp = stack_frame(task, regs);
18008
18009 for (;;) {
18010 - struct thread_info *context;
18011 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18012
18013 - context = (struct thread_info *)
18014 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18015 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18016 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18017
18018 - stack = (unsigned long *)context->previous_esp;
18019 - if (!stack)
18020 + if (stack_start == task_stack_page(task))
18021 break;
18022 + stack = *(unsigned long **)stack_start;
18023 if (ops->stack(data, "IRQ") < 0)
18024 break;
18025 touch_nmi_watchdog();
18026 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
18027 int i;
18028
18029 show_regs_print_info(KERN_EMERG);
18030 - __show_regs(regs, !user_mode_vm(regs));
18031 + __show_regs(regs, !user_mode(regs));
18032
18033 /*
18034 * When in-kernel, we also print out the stack and code at the
18035 * time of the fault..
18036 */
18037 - if (!user_mode_vm(regs)) {
18038 + if (!user_mode(regs)) {
18039 unsigned int code_prologue = code_bytes * 43 / 64;
18040 unsigned int code_len = code_bytes;
18041 unsigned char c;
18042 u8 *ip;
18043 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18044
18045 pr_emerg("Stack:\n");
18046 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18047
18048 pr_emerg("Code:");
18049
18050 - ip = (u8 *)regs->ip - code_prologue;
18051 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18052 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18053 /* try starting at IP */
18054 - ip = (u8 *)regs->ip;
18055 + ip = (u8 *)regs->ip + cs_base;
18056 code_len = code_len - code_prologue + 1;
18057 }
18058 for (i = 0; i < code_len; i++, ip++) {
18059 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
18060 pr_cont(" Bad EIP value.");
18061 break;
18062 }
18063 - if (ip == (u8 *)regs->ip)
18064 + if (ip == (u8 *)regs->ip + cs_base)
18065 pr_cont(" <%02x>", c);
18066 else
18067 pr_cont(" %02x", c);
18068 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
18069 {
18070 unsigned short ud2;
18071
18072 + ip = ktla_ktva(ip);
18073 if (ip < PAGE_OFFSET)
18074 return 0;
18075 if (probe_kernel_address((unsigned short *)ip, ud2))
18076 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
18077
18078 return ud2 == 0x0b0f;
18079 }
18080 +
18081 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18082 +void pax_check_alloca(unsigned long size)
18083 +{
18084 + unsigned long sp = (unsigned long)&sp, stack_left;
18085 +
18086 + /* all kernel stacks are of the same size */
18087 + stack_left = sp & (THREAD_SIZE - 1);
18088 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18089 +}
18090 +EXPORT_SYMBOL(pax_check_alloca);
18091 +#endif
18092 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18093 index addb207..99635fa 100644
18094 --- a/arch/x86/kernel/dumpstack_64.c
18095 +++ b/arch/x86/kernel/dumpstack_64.c
18096 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18097 unsigned long *irq_stack_end =
18098 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18099 unsigned used = 0;
18100 - struct thread_info *tinfo;
18101 int graph = 0;
18102 unsigned long dummy;
18103 + void *stack_start;
18104
18105 if (!task)
18106 task = current;
18107 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18108 * current stack address. If the stacks consist of nested
18109 * exceptions
18110 */
18111 - tinfo = task_thread_info(task);
18112 for (;;) {
18113 char *id;
18114 unsigned long *estack_end;
18115 +
18116 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18117 &used, &id);
18118
18119 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18120 if (ops->stack(data, id) < 0)
18121 break;
18122
18123 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18124 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18125 data, estack_end, &graph);
18126 ops->stack(data, "<EOE>");
18127 /*
18128 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18129 * second-to-last pointer (index -2 to end) in the
18130 * exception stack:
18131 */
18132 + if ((u16)estack_end[-1] != __KERNEL_DS)
18133 + goto out;
18134 stack = (unsigned long *) estack_end[-2];
18135 continue;
18136 }
18137 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18138 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18139 if (ops->stack(data, "IRQ") < 0)
18140 break;
18141 - bp = ops->walk_stack(tinfo, stack, bp,
18142 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18143 ops, data, irq_stack_end, &graph);
18144 /*
18145 * We link to the next stack (which would be
18146 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18147 /*
18148 * This handles the process stack:
18149 */
18150 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18151 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18152 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18153 +out:
18154 put_cpu();
18155 }
18156 EXPORT_SYMBOL(dump_trace);
18157 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
18158
18159 return ud2 == 0x0b0f;
18160 }
18161 +
18162 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18163 +void pax_check_alloca(unsigned long size)
18164 +{
18165 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18166 + unsigned cpu, used;
18167 + char *id;
18168 +
18169 + /* check the process stack first */
18170 + stack_start = (unsigned long)task_stack_page(current);
18171 + stack_end = stack_start + THREAD_SIZE;
18172 + if (likely(stack_start <= sp && sp < stack_end)) {
18173 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18174 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18175 + return;
18176 + }
18177 +
18178 + cpu = get_cpu();
18179 +
18180 + /* check the irq stacks */
18181 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18182 + stack_start = stack_end - IRQ_STACK_SIZE;
18183 + if (stack_start <= sp && sp < stack_end) {
18184 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18185 + put_cpu();
18186 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18187 + return;
18188 + }
18189 +
18190 + /* check the exception stacks */
18191 + used = 0;
18192 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18193 + stack_start = stack_end - EXCEPTION_STKSZ;
18194 + if (stack_end && stack_start <= sp && sp < stack_end) {
18195 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18196 + put_cpu();
18197 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18198 + return;
18199 + }
18200 +
18201 + put_cpu();
18202 +
18203 + /* unknown stack */
18204 + BUG();
18205 +}
18206 +EXPORT_SYMBOL(pax_check_alloca);
18207 +#endif
18208 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
18209 index d32abea..74daf4f 100644
18210 --- a/arch/x86/kernel/e820.c
18211 +++ b/arch/x86/kernel/e820.c
18212 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
18213
18214 static void early_panic(char *msg)
18215 {
18216 - early_printk(msg);
18217 - panic(msg);
18218 + early_printk("%s", msg);
18219 + panic("%s", msg);
18220 }
18221
18222 static int userdef __initdata;
18223 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18224 index d15f575..d692043 100644
18225 --- a/arch/x86/kernel/early_printk.c
18226 +++ b/arch/x86/kernel/early_printk.c
18227 @@ -7,6 +7,7 @@
18228 #include <linux/pci_regs.h>
18229 #include <linux/pci_ids.h>
18230 #include <linux/errno.h>
18231 +#include <linux/sched.h>
18232 #include <asm/io.h>
18233 #include <asm/processor.h>
18234 #include <asm/fcntl.h>
18235 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18236 index 8f3e2de..caecc4e 100644
18237 --- a/arch/x86/kernel/entry_32.S
18238 +++ b/arch/x86/kernel/entry_32.S
18239 @@ -177,13 +177,153 @@
18240 /*CFI_REL_OFFSET gs, PT_GS*/
18241 .endm
18242 .macro SET_KERNEL_GS reg
18243 +
18244 +#ifdef CONFIG_CC_STACKPROTECTOR
18245 movl $(__KERNEL_STACK_CANARY), \reg
18246 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18247 + movl $(__USER_DS), \reg
18248 +#else
18249 + xorl \reg, \reg
18250 +#endif
18251 +
18252 movl \reg, %gs
18253 .endm
18254
18255 #endif /* CONFIG_X86_32_LAZY_GS */
18256
18257 -.macro SAVE_ALL
18258 +.macro pax_enter_kernel
18259 +#ifdef CONFIG_PAX_KERNEXEC
18260 + call pax_enter_kernel
18261 +#endif
18262 +.endm
18263 +
18264 +.macro pax_exit_kernel
18265 +#ifdef CONFIG_PAX_KERNEXEC
18266 + call pax_exit_kernel
18267 +#endif
18268 +.endm
18269 +
18270 +#ifdef CONFIG_PAX_KERNEXEC
18271 +ENTRY(pax_enter_kernel)
18272 +#ifdef CONFIG_PARAVIRT
18273 + pushl %eax
18274 + pushl %ecx
18275 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18276 + mov %eax, %esi
18277 +#else
18278 + mov %cr0, %esi
18279 +#endif
18280 + bts $16, %esi
18281 + jnc 1f
18282 + mov %cs, %esi
18283 + cmp $__KERNEL_CS, %esi
18284 + jz 3f
18285 + ljmp $__KERNEL_CS, $3f
18286 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18287 +2:
18288 +#ifdef CONFIG_PARAVIRT
18289 + mov %esi, %eax
18290 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18291 +#else
18292 + mov %esi, %cr0
18293 +#endif
18294 +3:
18295 +#ifdef CONFIG_PARAVIRT
18296 + popl %ecx
18297 + popl %eax
18298 +#endif
18299 + ret
18300 +ENDPROC(pax_enter_kernel)
18301 +
18302 +ENTRY(pax_exit_kernel)
18303 +#ifdef CONFIG_PARAVIRT
18304 + pushl %eax
18305 + pushl %ecx
18306 +#endif
18307 + mov %cs, %esi
18308 + cmp $__KERNEXEC_KERNEL_CS, %esi
18309 + jnz 2f
18310 +#ifdef CONFIG_PARAVIRT
18311 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18312 + mov %eax, %esi
18313 +#else
18314 + mov %cr0, %esi
18315 +#endif
18316 + btr $16, %esi
18317 + ljmp $__KERNEL_CS, $1f
18318 +1:
18319 +#ifdef CONFIG_PARAVIRT
18320 + mov %esi, %eax
18321 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18322 +#else
18323 + mov %esi, %cr0
18324 +#endif
18325 +2:
18326 +#ifdef CONFIG_PARAVIRT
18327 + popl %ecx
18328 + popl %eax
18329 +#endif
18330 + ret
18331 +ENDPROC(pax_exit_kernel)
18332 +#endif
18333 +
18334 + .macro pax_erase_kstack
18335 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18336 + call pax_erase_kstack
18337 +#endif
18338 + .endm
18339 +
18340 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18341 +/*
18342 + * ebp: thread_info
18343 + */
18344 +ENTRY(pax_erase_kstack)
18345 + pushl %edi
18346 + pushl %ecx
18347 + pushl %eax
18348 +
18349 + mov TI_lowest_stack(%ebp), %edi
18350 + mov $-0xBEEF, %eax
18351 + std
18352 +
18353 +1: mov %edi, %ecx
18354 + and $THREAD_SIZE_asm - 1, %ecx
18355 + shr $2, %ecx
18356 + repne scasl
18357 + jecxz 2f
18358 +
18359 + cmp $2*16, %ecx
18360 + jc 2f
18361 +
18362 + mov $2*16, %ecx
18363 + repe scasl
18364 + jecxz 2f
18365 + jne 1b
18366 +
18367 +2: cld
18368 + mov %esp, %ecx
18369 + sub %edi, %ecx
18370 +
18371 + cmp $THREAD_SIZE_asm, %ecx
18372 + jb 3f
18373 + ud2
18374 +3:
18375 +
18376 + shr $2, %ecx
18377 + rep stosl
18378 +
18379 + mov TI_task_thread_sp0(%ebp), %edi
18380 + sub $128, %edi
18381 + mov %edi, TI_lowest_stack(%ebp)
18382 +
18383 + popl %eax
18384 + popl %ecx
18385 + popl %edi
18386 + ret
18387 +ENDPROC(pax_erase_kstack)
18388 +#endif
18389 +
18390 +.macro __SAVE_ALL _DS
18391 cld
18392 PUSH_GS
18393 pushl_cfi %fs
18394 @@ -206,7 +346,7 @@
18395 CFI_REL_OFFSET ecx, 0
18396 pushl_cfi %ebx
18397 CFI_REL_OFFSET ebx, 0
18398 - movl $(__USER_DS), %edx
18399 + movl $\_DS, %edx
18400 movl %edx, %ds
18401 movl %edx, %es
18402 movl $(__KERNEL_PERCPU), %edx
18403 @@ -214,6 +354,15 @@
18404 SET_KERNEL_GS %edx
18405 .endm
18406
18407 +.macro SAVE_ALL
18408 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18409 + __SAVE_ALL __KERNEL_DS
18410 + pax_enter_kernel
18411 +#else
18412 + __SAVE_ALL __USER_DS
18413 +#endif
18414 +.endm
18415 +
18416 .macro RESTORE_INT_REGS
18417 popl_cfi %ebx
18418 CFI_RESTORE ebx
18419 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18420 popfl_cfi
18421 jmp syscall_exit
18422 CFI_ENDPROC
18423 -END(ret_from_fork)
18424 +ENDPROC(ret_from_fork)
18425
18426 ENTRY(ret_from_kernel_thread)
18427 CFI_STARTPROC
18428 @@ -344,7 +493,15 @@ ret_from_intr:
18429 andl $SEGMENT_RPL_MASK, %eax
18430 #endif
18431 cmpl $USER_RPL, %eax
18432 +
18433 +#ifdef CONFIG_PAX_KERNEXEC
18434 + jae resume_userspace
18435 +
18436 + pax_exit_kernel
18437 + jmp resume_kernel
18438 +#else
18439 jb resume_kernel # not returning to v8086 or userspace
18440 +#endif
18441
18442 ENTRY(resume_userspace)
18443 LOCKDEP_SYS_EXIT
18444 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18445 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18446 # int/exception return?
18447 jne work_pending
18448 - jmp restore_all
18449 -END(ret_from_exception)
18450 + jmp restore_all_pax
18451 +ENDPROC(ret_from_exception)
18452
18453 #ifdef CONFIG_PREEMPT
18454 ENTRY(resume_kernel)
18455 @@ -372,7 +529,7 @@ need_resched:
18456 jz restore_all
18457 call preempt_schedule_irq
18458 jmp need_resched
18459 -END(resume_kernel)
18460 +ENDPROC(resume_kernel)
18461 #endif
18462 CFI_ENDPROC
18463 /*
18464 @@ -406,30 +563,45 @@ sysenter_past_esp:
18465 /*CFI_REL_OFFSET cs, 0*/
18466 /*
18467 * Push current_thread_info()->sysenter_return to the stack.
18468 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18469 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18470 */
18471 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18472 + pushl_cfi $0
18473 CFI_REL_OFFSET eip, 0
18474
18475 pushl_cfi %eax
18476 SAVE_ALL
18477 + GET_THREAD_INFO(%ebp)
18478 + movl TI_sysenter_return(%ebp),%ebp
18479 + movl %ebp,PT_EIP(%esp)
18480 ENABLE_INTERRUPTS(CLBR_NONE)
18481
18482 /*
18483 * Load the potential sixth argument from user stack.
18484 * Careful about security.
18485 */
18486 + movl PT_OLDESP(%esp),%ebp
18487 +
18488 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18489 + mov PT_OLDSS(%esp),%ds
18490 +1: movl %ds:(%ebp),%ebp
18491 + push %ss
18492 + pop %ds
18493 +#else
18494 cmpl $__PAGE_OFFSET-3,%ebp
18495 jae syscall_fault
18496 ASM_STAC
18497 1: movl (%ebp),%ebp
18498 ASM_CLAC
18499 +#endif
18500 +
18501 movl %ebp,PT_EBP(%esp)
18502 _ASM_EXTABLE(1b,syscall_fault)
18503
18504 GET_THREAD_INFO(%ebp)
18505
18506 +#ifdef CONFIG_PAX_RANDKSTACK
18507 + pax_erase_kstack
18508 +#endif
18509 +
18510 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18511 jnz sysenter_audit
18512 sysenter_do_call:
18513 @@ -444,12 +616,24 @@ sysenter_do_call:
18514 testl $_TIF_ALLWORK_MASK, %ecx
18515 jne sysexit_audit
18516 sysenter_exit:
18517 +
18518 +#ifdef CONFIG_PAX_RANDKSTACK
18519 + pushl_cfi %eax
18520 + movl %esp, %eax
18521 + call pax_randomize_kstack
18522 + popl_cfi %eax
18523 +#endif
18524 +
18525 + pax_erase_kstack
18526 +
18527 /* if something modifies registers it must also disable sysexit */
18528 movl PT_EIP(%esp), %edx
18529 movl PT_OLDESP(%esp), %ecx
18530 xorl %ebp,%ebp
18531 TRACE_IRQS_ON
18532 1: mov PT_FS(%esp), %fs
18533 +2: mov PT_DS(%esp), %ds
18534 +3: mov PT_ES(%esp), %es
18535 PTGS_TO_GS
18536 ENABLE_INTERRUPTS_SYSEXIT
18537
18538 @@ -466,6 +650,9 @@ sysenter_audit:
18539 movl %eax,%edx /* 2nd arg: syscall number */
18540 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18541 call __audit_syscall_entry
18542 +
18543 + pax_erase_kstack
18544 +
18545 pushl_cfi %ebx
18546 movl PT_EAX(%esp),%eax /* reload syscall number */
18547 jmp sysenter_do_call
18548 @@ -491,10 +678,16 @@ sysexit_audit:
18549
18550 CFI_ENDPROC
18551 .pushsection .fixup,"ax"
18552 -2: movl $0,PT_FS(%esp)
18553 +4: movl $0,PT_FS(%esp)
18554 + jmp 1b
18555 +5: movl $0,PT_DS(%esp)
18556 + jmp 1b
18557 +6: movl $0,PT_ES(%esp)
18558 jmp 1b
18559 .popsection
18560 - _ASM_EXTABLE(1b,2b)
18561 + _ASM_EXTABLE(1b,4b)
18562 + _ASM_EXTABLE(2b,5b)
18563 + _ASM_EXTABLE(3b,6b)
18564 PTGS_TO_GS_EX
18565 ENDPROC(ia32_sysenter_target)
18566
18567 @@ -509,6 +702,11 @@ ENTRY(system_call)
18568 pushl_cfi %eax # save orig_eax
18569 SAVE_ALL
18570 GET_THREAD_INFO(%ebp)
18571 +
18572 +#ifdef CONFIG_PAX_RANDKSTACK
18573 + pax_erase_kstack
18574 +#endif
18575 +
18576 # system call tracing in operation / emulation
18577 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18578 jnz syscall_trace_entry
18579 @@ -527,6 +725,15 @@ syscall_exit:
18580 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18581 jne syscall_exit_work
18582
18583 +restore_all_pax:
18584 +
18585 +#ifdef CONFIG_PAX_RANDKSTACK
18586 + movl %esp, %eax
18587 + call pax_randomize_kstack
18588 +#endif
18589 +
18590 + pax_erase_kstack
18591 +
18592 restore_all:
18593 TRACE_IRQS_IRET
18594 restore_all_notrace:
18595 @@ -583,14 +790,34 @@ ldt_ss:
18596 * compensating for the offset by changing to the ESPFIX segment with
18597 * a base address that matches for the difference.
18598 */
18599 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18600 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18601 mov %esp, %edx /* load kernel esp */
18602 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18603 mov %dx, %ax /* eax: new kernel esp */
18604 sub %eax, %edx /* offset (low word is 0) */
18605 +#ifdef CONFIG_SMP
18606 + movl PER_CPU_VAR(cpu_number), %ebx
18607 + shll $PAGE_SHIFT_asm, %ebx
18608 + addl $cpu_gdt_table, %ebx
18609 +#else
18610 + movl $cpu_gdt_table, %ebx
18611 +#endif
18612 shr $16, %edx
18613 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18614 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18615 +
18616 +#ifdef CONFIG_PAX_KERNEXEC
18617 + mov %cr0, %esi
18618 + btr $16, %esi
18619 + mov %esi, %cr0
18620 +#endif
18621 +
18622 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18623 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18624 +
18625 +#ifdef CONFIG_PAX_KERNEXEC
18626 + bts $16, %esi
18627 + mov %esi, %cr0
18628 +#endif
18629 +
18630 pushl_cfi $__ESPFIX_SS
18631 pushl_cfi %eax /* new kernel esp */
18632 /* Disable interrupts, but do not irqtrace this section: we
18633 @@ -619,20 +846,18 @@ work_resched:
18634 movl TI_flags(%ebp), %ecx
18635 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18636 # than syscall tracing?
18637 - jz restore_all
18638 + jz restore_all_pax
18639 testb $_TIF_NEED_RESCHED, %cl
18640 jnz work_resched
18641
18642 work_notifysig: # deal with pending signals and
18643 # notify-resume requests
18644 + movl %esp, %eax
18645 #ifdef CONFIG_VM86
18646 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18647 - movl %esp, %eax
18648 jne work_notifysig_v86 # returning to kernel-space or
18649 # vm86-space
18650 1:
18651 -#else
18652 - movl %esp, %eax
18653 #endif
18654 TRACE_IRQS_ON
18655 ENABLE_INTERRUPTS(CLBR_NONE)
18656 @@ -653,7 +878,7 @@ work_notifysig_v86:
18657 movl %eax, %esp
18658 jmp 1b
18659 #endif
18660 -END(work_pending)
18661 +ENDPROC(work_pending)
18662
18663 # perform syscall exit tracing
18664 ALIGN
18665 @@ -661,11 +886,14 @@ syscall_trace_entry:
18666 movl $-ENOSYS,PT_EAX(%esp)
18667 movl %esp, %eax
18668 call syscall_trace_enter
18669 +
18670 + pax_erase_kstack
18671 +
18672 /* What it returned is what we'll actually use. */
18673 cmpl $(NR_syscalls), %eax
18674 jnae syscall_call
18675 jmp syscall_exit
18676 -END(syscall_trace_entry)
18677 +ENDPROC(syscall_trace_entry)
18678
18679 # perform syscall exit tracing
18680 ALIGN
18681 @@ -678,21 +906,25 @@ syscall_exit_work:
18682 movl %esp, %eax
18683 call syscall_trace_leave
18684 jmp resume_userspace
18685 -END(syscall_exit_work)
18686 +ENDPROC(syscall_exit_work)
18687 CFI_ENDPROC
18688
18689 RING0_INT_FRAME # can't unwind into user space anyway
18690 syscall_fault:
18691 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18692 + push %ss
18693 + pop %ds
18694 +#endif
18695 ASM_CLAC
18696 GET_THREAD_INFO(%ebp)
18697 movl $-EFAULT,PT_EAX(%esp)
18698 jmp resume_userspace
18699 -END(syscall_fault)
18700 +ENDPROC(syscall_fault)
18701
18702 syscall_badsys:
18703 movl $-ENOSYS,PT_EAX(%esp)
18704 jmp resume_userspace
18705 -END(syscall_badsys)
18706 +ENDPROC(syscall_badsys)
18707 CFI_ENDPROC
18708 /*
18709 * End of kprobes section
18710 @@ -708,8 +940,15 @@ END(syscall_badsys)
18711 * normal stack and adjusts ESP with the matching offset.
18712 */
18713 /* fixup the stack */
18714 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18715 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18716 +#ifdef CONFIG_SMP
18717 + movl PER_CPU_VAR(cpu_number), %ebx
18718 + shll $PAGE_SHIFT_asm, %ebx
18719 + addl $cpu_gdt_table, %ebx
18720 +#else
18721 + movl $cpu_gdt_table, %ebx
18722 +#endif
18723 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18724 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18725 shl $16, %eax
18726 addl %esp, %eax /* the adjusted stack pointer */
18727 pushl_cfi $__KERNEL_DS
18728 @@ -762,7 +1001,7 @@ vector=vector+1
18729 .endr
18730 2: jmp common_interrupt
18731 .endr
18732 -END(irq_entries_start)
18733 +ENDPROC(irq_entries_start)
18734
18735 .previous
18736 END(interrupt)
18737 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18738 pushl_cfi $do_coprocessor_error
18739 jmp error_code
18740 CFI_ENDPROC
18741 -END(coprocessor_error)
18742 +ENDPROC(coprocessor_error)
18743
18744 ENTRY(simd_coprocessor_error)
18745 RING0_INT_FRAME
18746 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18747 #endif
18748 jmp error_code
18749 CFI_ENDPROC
18750 -END(simd_coprocessor_error)
18751 +ENDPROC(simd_coprocessor_error)
18752
18753 ENTRY(device_not_available)
18754 RING0_INT_FRAME
18755 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18756 pushl_cfi $do_device_not_available
18757 jmp error_code
18758 CFI_ENDPROC
18759 -END(device_not_available)
18760 +ENDPROC(device_not_available)
18761
18762 #ifdef CONFIG_PARAVIRT
18763 ENTRY(native_iret)
18764 iret
18765 _ASM_EXTABLE(native_iret, iret_exc)
18766 -END(native_iret)
18767 +ENDPROC(native_iret)
18768
18769 ENTRY(native_irq_enable_sysexit)
18770 sti
18771 sysexit
18772 -END(native_irq_enable_sysexit)
18773 +ENDPROC(native_irq_enable_sysexit)
18774 #endif
18775
18776 ENTRY(overflow)
18777 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18778 pushl_cfi $do_overflow
18779 jmp error_code
18780 CFI_ENDPROC
18781 -END(overflow)
18782 +ENDPROC(overflow)
18783
18784 ENTRY(bounds)
18785 RING0_INT_FRAME
18786 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18787 pushl_cfi $do_bounds
18788 jmp error_code
18789 CFI_ENDPROC
18790 -END(bounds)
18791 +ENDPROC(bounds)
18792
18793 ENTRY(invalid_op)
18794 RING0_INT_FRAME
18795 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18796 pushl_cfi $do_invalid_op
18797 jmp error_code
18798 CFI_ENDPROC
18799 -END(invalid_op)
18800 +ENDPROC(invalid_op)
18801
18802 ENTRY(coprocessor_segment_overrun)
18803 RING0_INT_FRAME
18804 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18805 pushl_cfi $do_coprocessor_segment_overrun
18806 jmp error_code
18807 CFI_ENDPROC
18808 -END(coprocessor_segment_overrun)
18809 +ENDPROC(coprocessor_segment_overrun)
18810
18811 ENTRY(invalid_TSS)
18812 RING0_EC_FRAME
18813 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18814 pushl_cfi $do_invalid_TSS
18815 jmp error_code
18816 CFI_ENDPROC
18817 -END(invalid_TSS)
18818 +ENDPROC(invalid_TSS)
18819
18820 ENTRY(segment_not_present)
18821 RING0_EC_FRAME
18822 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18823 pushl_cfi $do_segment_not_present
18824 jmp error_code
18825 CFI_ENDPROC
18826 -END(segment_not_present)
18827 +ENDPROC(segment_not_present)
18828
18829 ENTRY(stack_segment)
18830 RING0_EC_FRAME
18831 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18832 pushl_cfi $do_stack_segment
18833 jmp error_code
18834 CFI_ENDPROC
18835 -END(stack_segment)
18836 +ENDPROC(stack_segment)
18837
18838 ENTRY(alignment_check)
18839 RING0_EC_FRAME
18840 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18841 pushl_cfi $do_alignment_check
18842 jmp error_code
18843 CFI_ENDPROC
18844 -END(alignment_check)
18845 +ENDPROC(alignment_check)
18846
18847 ENTRY(divide_error)
18848 RING0_INT_FRAME
18849 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18850 pushl_cfi $do_divide_error
18851 jmp error_code
18852 CFI_ENDPROC
18853 -END(divide_error)
18854 +ENDPROC(divide_error)
18855
18856 #ifdef CONFIG_X86_MCE
18857 ENTRY(machine_check)
18858 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18859 pushl_cfi machine_check_vector
18860 jmp error_code
18861 CFI_ENDPROC
18862 -END(machine_check)
18863 +ENDPROC(machine_check)
18864 #endif
18865
18866 ENTRY(spurious_interrupt_bug)
18867 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18868 pushl_cfi $do_spurious_interrupt_bug
18869 jmp error_code
18870 CFI_ENDPROC
18871 -END(spurious_interrupt_bug)
18872 +ENDPROC(spurious_interrupt_bug)
18873 /*
18874 * End of kprobes section
18875 */
18876 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18877
18878 ENTRY(mcount)
18879 ret
18880 -END(mcount)
18881 +ENDPROC(mcount)
18882
18883 ENTRY(ftrace_caller)
18884 cmpl $0, function_trace_stop
18885 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18886 .globl ftrace_stub
18887 ftrace_stub:
18888 ret
18889 -END(ftrace_caller)
18890 +ENDPROC(ftrace_caller)
18891
18892 ENTRY(ftrace_regs_caller)
18893 pushf /* push flags before compare (in cs location) */
18894 @@ -1197,7 +1436,7 @@ trace:
18895 popl %ecx
18896 popl %eax
18897 jmp ftrace_stub
18898 -END(mcount)
18899 +ENDPROC(mcount)
18900 #endif /* CONFIG_DYNAMIC_FTRACE */
18901 #endif /* CONFIG_FUNCTION_TRACER */
18902
18903 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18904 popl %ecx
18905 popl %eax
18906 ret
18907 -END(ftrace_graph_caller)
18908 +ENDPROC(ftrace_graph_caller)
18909
18910 .globl return_to_handler
18911 return_to_handler:
18912 @@ -1271,15 +1510,18 @@ error_code:
18913 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18914 REG_TO_PTGS %ecx
18915 SET_KERNEL_GS %ecx
18916 - movl $(__USER_DS), %ecx
18917 + movl $(__KERNEL_DS), %ecx
18918 movl %ecx, %ds
18919 movl %ecx, %es
18920 +
18921 + pax_enter_kernel
18922 +
18923 TRACE_IRQS_OFF
18924 movl %esp,%eax # pt_regs pointer
18925 call *%edi
18926 jmp ret_from_exception
18927 CFI_ENDPROC
18928 -END(page_fault)
18929 +ENDPROC(page_fault)
18930
18931 /*
18932 * Debug traps and NMI can happen at the one SYSENTER instruction
18933 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18934 call do_debug
18935 jmp ret_from_exception
18936 CFI_ENDPROC
18937 -END(debug)
18938 +ENDPROC(debug)
18939
18940 /*
18941 * NMI is doubly nasty. It can happen _while_ we're handling
18942 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18943 xorl %edx,%edx # zero error code
18944 movl %esp,%eax # pt_regs pointer
18945 call do_nmi
18946 +
18947 + pax_exit_kernel
18948 +
18949 jmp restore_all_notrace
18950 CFI_ENDPROC
18951
18952 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18953 FIXUP_ESPFIX_STACK # %eax == %esp
18954 xorl %edx,%edx # zero error code
18955 call do_nmi
18956 +
18957 + pax_exit_kernel
18958 +
18959 RESTORE_REGS
18960 lss 12+4(%esp), %esp # back to espfix stack
18961 CFI_ADJUST_CFA_OFFSET -24
18962 jmp irq_return
18963 CFI_ENDPROC
18964 -END(nmi)
18965 +ENDPROC(nmi)
18966
18967 ENTRY(int3)
18968 RING0_INT_FRAME
18969 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18970 call do_int3
18971 jmp ret_from_exception
18972 CFI_ENDPROC
18973 -END(int3)
18974 +ENDPROC(int3)
18975
18976 ENTRY(general_protection)
18977 RING0_EC_FRAME
18978 pushl_cfi $do_general_protection
18979 jmp error_code
18980 CFI_ENDPROC
18981 -END(general_protection)
18982 +ENDPROC(general_protection)
18983
18984 #ifdef CONFIG_KVM_GUEST
18985 ENTRY(async_page_fault)
18986 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18987 pushl_cfi $do_async_page_fault
18988 jmp error_code
18989 CFI_ENDPROC
18990 -END(async_page_fault)
18991 +ENDPROC(async_page_fault)
18992 #endif
18993
18994 /*
18995 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18996 index 7272089..6204f9c5 100644
18997 --- a/arch/x86/kernel/entry_64.S
18998 +++ b/arch/x86/kernel/entry_64.S
18999 @@ -59,6 +59,8 @@
19000 #include <asm/context_tracking.h>
19001 #include <asm/smap.h>
19002 #include <linux/err.h>
19003 +#include <asm/pgtable.h>
19004 +#include <asm/alternative-asm.h>
19005
19006 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19007 #include <linux/elf-em.h>
19008 @@ -80,8 +82,9 @@
19009 #ifdef CONFIG_DYNAMIC_FTRACE
19010
19011 ENTRY(function_hook)
19012 + pax_force_retaddr
19013 retq
19014 -END(function_hook)
19015 +ENDPROC(function_hook)
19016
19017 /* skip is set if stack has been adjusted */
19018 .macro ftrace_caller_setup skip=0
19019 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19020 #endif
19021
19022 GLOBAL(ftrace_stub)
19023 + pax_force_retaddr
19024 retq
19025 -END(ftrace_caller)
19026 +ENDPROC(ftrace_caller)
19027
19028 ENTRY(ftrace_regs_caller)
19029 /* Save the current flags before compare (in SS location)*/
19030 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19031 popfq
19032 jmp ftrace_stub
19033
19034 -END(ftrace_regs_caller)
19035 +ENDPROC(ftrace_regs_caller)
19036
19037
19038 #else /* ! CONFIG_DYNAMIC_FTRACE */
19039 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19040 #endif
19041
19042 GLOBAL(ftrace_stub)
19043 + pax_force_retaddr
19044 retq
19045
19046 trace:
19047 @@ -225,12 +230,13 @@ trace:
19048 #endif
19049 subq $MCOUNT_INSN_SIZE, %rdi
19050
19051 + pax_force_fptr ftrace_trace_function
19052 call *ftrace_trace_function
19053
19054 MCOUNT_RESTORE_FRAME
19055
19056 jmp ftrace_stub
19057 -END(function_hook)
19058 +ENDPROC(function_hook)
19059 #endif /* CONFIG_DYNAMIC_FTRACE */
19060 #endif /* CONFIG_FUNCTION_TRACER */
19061
19062 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19063
19064 MCOUNT_RESTORE_FRAME
19065
19066 + pax_force_retaddr
19067 retq
19068 -END(ftrace_graph_caller)
19069 +ENDPROC(ftrace_graph_caller)
19070
19071 GLOBAL(return_to_handler)
19072 subq $24, %rsp
19073 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19074 movq 8(%rsp), %rdx
19075 movq (%rsp), %rax
19076 addq $24, %rsp
19077 + pax_force_fptr %rdi
19078 jmp *%rdi
19079 +ENDPROC(return_to_handler)
19080 #endif
19081
19082
19083 @@ -284,6 +293,309 @@ ENTRY(native_usergs_sysret64)
19084 ENDPROC(native_usergs_sysret64)
19085 #endif /* CONFIG_PARAVIRT */
19086
19087 + .macro ljmpq sel, off
19088 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19089 + .byte 0x48; ljmp *1234f(%rip)
19090 + .pushsection .rodata
19091 + .align 16
19092 + 1234: .quad \off; .word \sel
19093 + .popsection
19094 +#else
19095 + pushq $\sel
19096 + pushq $\off
19097 + lretq
19098 +#endif
19099 + .endm
19100 +
19101 + .macro pax_enter_kernel
19102 + pax_set_fptr_mask
19103 +#ifdef CONFIG_PAX_KERNEXEC
19104 + call pax_enter_kernel
19105 +#endif
19106 + .endm
19107 +
19108 + .macro pax_exit_kernel
19109 +#ifdef CONFIG_PAX_KERNEXEC
19110 + call pax_exit_kernel
19111 +#endif
19112 + .endm
19113 +
19114 +#ifdef CONFIG_PAX_KERNEXEC
19115 +ENTRY(pax_enter_kernel)
19116 + pushq %rdi
19117 +
19118 +#ifdef CONFIG_PARAVIRT
19119 + PV_SAVE_REGS(CLBR_RDI)
19120 +#endif
19121 +
19122 + GET_CR0_INTO_RDI
19123 + bts $16,%rdi
19124 + jnc 3f
19125 + mov %cs,%edi
19126 + cmp $__KERNEL_CS,%edi
19127 + jnz 2f
19128 +1:
19129 +
19130 +#ifdef CONFIG_PARAVIRT
19131 + PV_RESTORE_REGS(CLBR_RDI)
19132 +#endif
19133 +
19134 + popq %rdi
19135 + pax_force_retaddr
19136 + retq
19137 +
19138 +2: ljmpq __KERNEL_CS,1b
19139 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19140 +4: SET_RDI_INTO_CR0
19141 + jmp 1b
19142 +ENDPROC(pax_enter_kernel)
19143 +
19144 +ENTRY(pax_exit_kernel)
19145 + pushq %rdi
19146 +
19147 +#ifdef CONFIG_PARAVIRT
19148 + PV_SAVE_REGS(CLBR_RDI)
19149 +#endif
19150 +
19151 + mov %cs,%rdi
19152 + cmp $__KERNEXEC_KERNEL_CS,%edi
19153 + jz 2f
19154 + GET_CR0_INTO_RDI
19155 + bts $16,%rdi
19156 + jnc 4f
19157 +1:
19158 +
19159 +#ifdef CONFIG_PARAVIRT
19160 + PV_RESTORE_REGS(CLBR_RDI);
19161 +#endif
19162 +
19163 + popq %rdi
19164 + pax_force_retaddr
19165 + retq
19166 +
19167 +2: GET_CR0_INTO_RDI
19168 + btr $16,%rdi
19169 + jnc 4f
19170 + ljmpq __KERNEL_CS,3f
19171 +3: SET_RDI_INTO_CR0
19172 + jmp 1b
19173 +4: ud2
19174 + jmp 4b
19175 +ENDPROC(pax_exit_kernel)
19176 +#endif
19177 +
19178 + .macro pax_enter_kernel_user
19179 + pax_set_fptr_mask
19180 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19181 + call pax_enter_kernel_user
19182 +#endif
19183 + .endm
19184 +
19185 + .macro pax_exit_kernel_user
19186 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19187 + call pax_exit_kernel_user
19188 +#endif
19189 +#ifdef CONFIG_PAX_RANDKSTACK
19190 + pushq %rax
19191 + pushq %r11
19192 + call pax_randomize_kstack
19193 + popq %r11
19194 + popq %rax
19195 +#endif
19196 + .endm
19197 +
19198 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19199 +ENTRY(pax_enter_kernel_user)
19200 + pushq %rdi
19201 + pushq %rbx
19202 +
19203 +#ifdef CONFIG_PARAVIRT
19204 + PV_SAVE_REGS(CLBR_RDI)
19205 +#endif
19206 +
19207 + GET_CR3_INTO_RDI
19208 + mov %rdi,%rbx
19209 + add $__START_KERNEL_map,%rbx
19210 + sub phys_base(%rip),%rbx
19211 +
19212 +#ifdef CONFIG_PARAVIRT
19213 + cmpl $0, pv_info+PARAVIRT_enabled
19214 + jz 1f
19215 + pushq %rdi
19216 + i = 0
19217 + .rept USER_PGD_PTRS
19218 + mov i*8(%rbx),%rsi
19219 + mov $0,%sil
19220 + lea i*8(%rbx),%rdi
19221 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19222 + i = i + 1
19223 + .endr
19224 + popq %rdi
19225 + jmp 2f
19226 +1:
19227 +#endif
19228 +
19229 + i = 0
19230 + .rept USER_PGD_PTRS
19231 + movb $0,i*8(%rbx)
19232 + i = i + 1
19233 + .endr
19234 +
19235 +#ifdef CONFIG_PARAVIRT
19236 +2:
19237 +#endif
19238 + SET_RDI_INTO_CR3
19239 +
19240 +#ifdef CONFIG_PAX_KERNEXEC
19241 + GET_CR0_INTO_RDI
19242 + bts $16,%rdi
19243 + SET_RDI_INTO_CR0
19244 +#endif
19245 +
19246 +#ifdef CONFIG_PARAVIRT
19247 + PV_RESTORE_REGS(CLBR_RDI)
19248 +#endif
19249 +
19250 + popq %rbx
19251 + popq %rdi
19252 + pax_force_retaddr
19253 + retq
19254 +ENDPROC(pax_enter_kernel_user)
19255 +
19256 +ENTRY(pax_exit_kernel_user)
19257 + pushq %rdi
19258 + pushq %rbx
19259 +
19260 +#ifdef CONFIG_PARAVIRT
19261 + PV_SAVE_REGS(CLBR_RDI)
19262 +#endif
19263 +
19264 +#ifdef CONFIG_PAX_KERNEXEC
19265 + GET_CR0_INTO_RDI
19266 + btr $16,%rdi
19267 + jnc 3f
19268 + SET_RDI_INTO_CR0
19269 +#endif
19270 +
19271 + GET_CR3_INTO_RDI
19272 + mov %rdi,%rbx
19273 + add $__START_KERNEL_map,%rbx
19274 + sub phys_base(%rip),%rbx
19275 +
19276 +#ifdef CONFIG_PARAVIRT
19277 + cmpl $0, pv_info+PARAVIRT_enabled
19278 + jz 1f
19279 + i = 0
19280 + .rept USER_PGD_PTRS
19281 + mov i*8(%rbx),%rsi
19282 + mov $0x67,%sil
19283 + lea i*8(%rbx),%rdi
19284 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19285 + i = i + 1
19286 + .endr
19287 + jmp 2f
19288 +1:
19289 +#endif
19290 +
19291 + i = 0
19292 + .rept USER_PGD_PTRS
19293 + movb $0x67,i*8(%rbx)
19294 + i = i + 1
19295 + .endr
19296 +
19297 +#ifdef CONFIG_PARAVIRT
19298 +2: PV_RESTORE_REGS(CLBR_RDI)
19299 +#endif
19300 +
19301 + popq %rbx
19302 + popq %rdi
19303 + pax_force_retaddr
19304 + retq
19305 +3: ud2
19306 + jmp 3b
19307 +ENDPROC(pax_exit_kernel_user)
19308 +#endif
19309 +
19310 + .macro pax_enter_kernel_nmi
19311 + pax_set_fptr_mask
19312 +
19313 +#ifdef CONFIG_PAX_KERNEXEC
19314 + GET_CR0_INTO_RDI
19315 + bts $16,%rdi
19316 + jc 110f
19317 + SET_RDI_INTO_CR0
19318 + or $2,%ebx
19319 +110:
19320 +#endif
19321 + .endm
19322 +
19323 + .macro pax_exit_kernel_nmi
19324 +#ifdef CONFIG_PAX_KERNEXEC
19325 + btr $1,%ebx
19326 + jnc 110f
19327 + GET_CR0_INTO_RDI
19328 + btr $16,%rdi
19329 + SET_RDI_INTO_CR0
19330 +110:
19331 +#endif
19332 + .endm
19333 +
19334 + .macro pax_erase_kstack
19335 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19336 + call pax_erase_kstack
19337 +#endif
19338 + .endm
19339 +
19340 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19341 +ENTRY(pax_erase_kstack)
19342 + pushq %rdi
19343 + pushq %rcx
19344 + pushq %rax
19345 + pushq %r11
19346 +
19347 + GET_THREAD_INFO(%r11)
19348 + mov TI_lowest_stack(%r11), %rdi
19349 + mov $-0xBEEF, %rax
19350 + std
19351 +
19352 +1: mov %edi, %ecx
19353 + and $THREAD_SIZE_asm - 1, %ecx
19354 + shr $3, %ecx
19355 + repne scasq
19356 + jecxz 2f
19357 +
19358 + cmp $2*8, %ecx
19359 + jc 2f
19360 +
19361 + mov $2*8, %ecx
19362 + repe scasq
19363 + jecxz 2f
19364 + jne 1b
19365 +
19366 +2: cld
19367 + mov %esp, %ecx
19368 + sub %edi, %ecx
19369 +
19370 + cmp $THREAD_SIZE_asm, %rcx
19371 + jb 3f
19372 + ud2
19373 +3:
19374 +
19375 + shr $3, %ecx
19376 + rep stosq
19377 +
19378 + mov TI_task_thread_sp0(%r11), %rdi
19379 + sub $256, %rdi
19380 + mov %rdi, TI_lowest_stack(%r11)
19381 +
19382 + popq %r11
19383 + popq %rax
19384 + popq %rcx
19385 + popq %rdi
19386 + pax_force_retaddr
19387 + ret
19388 +ENDPROC(pax_erase_kstack)
19389 +#endif
19390
19391 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19392 #ifdef CONFIG_TRACE_IRQFLAGS
19393 @@ -375,8 +687,8 @@ ENDPROC(native_usergs_sysret64)
19394 .endm
19395
19396 .macro UNFAKE_STACK_FRAME
19397 - addq $8*6, %rsp
19398 - CFI_ADJUST_CFA_OFFSET -(6*8)
19399 + addq $8*6 + ARG_SKIP, %rsp
19400 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19401 .endm
19402
19403 /*
19404 @@ -463,7 +775,7 @@ ENDPROC(native_usergs_sysret64)
19405 movq %rsp, %rsi
19406
19407 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19408 - testl $3, CS-RBP(%rsi)
19409 + testb $3, CS-RBP(%rsi)
19410 je 1f
19411 SWAPGS
19412 /*
19413 @@ -498,9 +810,10 @@ ENTRY(save_rest)
19414 movq_cfi r15, R15+16
19415 movq %r11, 8(%rsp) /* return address */
19416 FIXUP_TOP_OF_STACK %r11, 16
19417 + pax_force_retaddr
19418 ret
19419 CFI_ENDPROC
19420 -END(save_rest)
19421 +ENDPROC(save_rest)
19422
19423 /* save complete stack frame */
19424 .pushsection .kprobes.text, "ax"
19425 @@ -529,9 +842,10 @@ ENTRY(save_paranoid)
19426 js 1f /* negative -> in kernel */
19427 SWAPGS
19428 xorl %ebx,%ebx
19429 -1: ret
19430 +1: pax_force_retaddr_bts
19431 + ret
19432 CFI_ENDPROC
19433 -END(save_paranoid)
19434 +ENDPROC(save_paranoid)
19435 .popsection
19436
19437 /*
19438 @@ -553,7 +867,7 @@ ENTRY(ret_from_fork)
19439
19440 RESTORE_REST
19441
19442 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19443 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19444 jz 1f
19445
19446 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19447 @@ -571,7 +885,7 @@ ENTRY(ret_from_fork)
19448 RESTORE_REST
19449 jmp int_ret_from_sys_call
19450 CFI_ENDPROC
19451 -END(ret_from_fork)
19452 +ENDPROC(ret_from_fork)
19453
19454 /*
19455 * System call entry. Up to 6 arguments in registers are supported.
19456 @@ -608,7 +922,7 @@ END(ret_from_fork)
19457 ENTRY(system_call)
19458 CFI_STARTPROC simple
19459 CFI_SIGNAL_FRAME
19460 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19461 + CFI_DEF_CFA rsp,0
19462 CFI_REGISTER rip,rcx
19463 /*CFI_REGISTER rflags,r11*/
19464 SWAPGS_UNSAFE_STACK
19465 @@ -621,16 +935,23 @@ GLOBAL(system_call_after_swapgs)
19466
19467 movq %rsp,PER_CPU_VAR(old_rsp)
19468 movq PER_CPU_VAR(kernel_stack),%rsp
19469 + SAVE_ARGS 8*6,0
19470 + pax_enter_kernel_user
19471 +
19472 +#ifdef CONFIG_PAX_RANDKSTACK
19473 + pax_erase_kstack
19474 +#endif
19475 +
19476 /*
19477 * No need to follow this irqs off/on section - it's straight
19478 * and short:
19479 */
19480 ENABLE_INTERRUPTS(CLBR_NONE)
19481 - SAVE_ARGS 8,0
19482 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19483 movq %rcx,RIP-ARGOFFSET(%rsp)
19484 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19485 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19486 + GET_THREAD_INFO(%rcx)
19487 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19488 jnz tracesys
19489 system_call_fastpath:
19490 #if __SYSCALL_MASK == ~0
19491 @@ -640,7 +961,7 @@ system_call_fastpath:
19492 cmpl $__NR_syscall_max,%eax
19493 #endif
19494 ja badsys
19495 - movq %r10,%rcx
19496 + movq R10-ARGOFFSET(%rsp),%rcx
19497 call *sys_call_table(,%rax,8) # XXX: rip relative
19498 movq %rax,RAX-ARGOFFSET(%rsp)
19499 /*
19500 @@ -654,10 +975,13 @@ sysret_check:
19501 LOCKDEP_SYS_EXIT
19502 DISABLE_INTERRUPTS(CLBR_NONE)
19503 TRACE_IRQS_OFF
19504 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19505 + GET_THREAD_INFO(%rcx)
19506 + movl TI_flags(%rcx),%edx
19507 andl %edi,%edx
19508 jnz sysret_careful
19509 CFI_REMEMBER_STATE
19510 + pax_exit_kernel_user
19511 + pax_erase_kstack
19512 /*
19513 * sysretq will re-enable interrupts:
19514 */
19515 @@ -709,14 +1033,18 @@ badsys:
19516 * jump back to the normal fast path.
19517 */
19518 auditsys:
19519 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19520 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19521 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19522 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19523 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19524 movq %rax,%rsi /* 2nd arg: syscall number */
19525 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19526 call __audit_syscall_entry
19527 +
19528 + pax_erase_kstack
19529 +
19530 LOAD_ARGS 0 /* reload call-clobbered registers */
19531 + pax_set_fptr_mask
19532 jmp system_call_fastpath
19533
19534 /*
19535 @@ -737,7 +1065,7 @@ sysret_audit:
19536 /* Do syscall tracing */
19537 tracesys:
19538 #ifdef CONFIG_AUDITSYSCALL
19539 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19540 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19541 jz auditsys
19542 #endif
19543 SAVE_REST
19544 @@ -745,12 +1073,16 @@ tracesys:
19545 FIXUP_TOP_OF_STACK %rdi
19546 movq %rsp,%rdi
19547 call syscall_trace_enter
19548 +
19549 + pax_erase_kstack
19550 +
19551 /*
19552 * Reload arg registers from stack in case ptrace changed them.
19553 * We don't reload %rax because syscall_trace_enter() returned
19554 * the value it wants us to use in the table lookup.
19555 */
19556 LOAD_ARGS ARGOFFSET, 1
19557 + pax_set_fptr_mask
19558 RESTORE_REST
19559 #if __SYSCALL_MASK == ~0
19560 cmpq $__NR_syscall_max,%rax
19561 @@ -759,7 +1091,7 @@ tracesys:
19562 cmpl $__NR_syscall_max,%eax
19563 #endif
19564 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19565 - movq %r10,%rcx /* fixup for C */
19566 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19567 call *sys_call_table(,%rax,8)
19568 movq %rax,RAX-ARGOFFSET(%rsp)
19569 /* Use IRET because user could have changed frame */
19570 @@ -780,7 +1112,9 @@ GLOBAL(int_with_check)
19571 andl %edi,%edx
19572 jnz int_careful
19573 andl $~TS_COMPAT,TI_status(%rcx)
19574 - jmp retint_swapgs
19575 + pax_exit_kernel_user
19576 + pax_erase_kstack
19577 + jmp retint_swapgs_pax
19578
19579 /* Either reschedule or signal or syscall exit tracking needed. */
19580 /* First do a reschedule test. */
19581 @@ -826,7 +1160,7 @@ int_restore_rest:
19582 TRACE_IRQS_OFF
19583 jmp int_with_check
19584 CFI_ENDPROC
19585 -END(system_call)
19586 +ENDPROC(system_call)
19587
19588 .macro FORK_LIKE func
19589 ENTRY(stub_\func)
19590 @@ -839,9 +1173,10 @@ ENTRY(stub_\func)
19591 DEFAULT_FRAME 0 8 /* offset 8: return address */
19592 call sys_\func
19593 RESTORE_TOP_OF_STACK %r11, 8
19594 + pax_force_retaddr
19595 ret $REST_SKIP /* pop extended registers */
19596 CFI_ENDPROC
19597 -END(stub_\func)
19598 +ENDPROC(stub_\func)
19599 .endm
19600
19601 .macro FIXED_FRAME label,func
19602 @@ -851,9 +1186,10 @@ ENTRY(\label)
19603 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19604 call \func
19605 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19606 + pax_force_retaddr
19607 ret
19608 CFI_ENDPROC
19609 -END(\label)
19610 +ENDPROC(\label)
19611 .endm
19612
19613 FORK_LIKE clone
19614 @@ -870,9 +1206,10 @@ ENTRY(ptregscall_common)
19615 movq_cfi_restore R12+8, r12
19616 movq_cfi_restore RBP+8, rbp
19617 movq_cfi_restore RBX+8, rbx
19618 + pax_force_retaddr
19619 ret $REST_SKIP /* pop extended registers */
19620 CFI_ENDPROC
19621 -END(ptregscall_common)
19622 +ENDPROC(ptregscall_common)
19623
19624 ENTRY(stub_execve)
19625 CFI_STARTPROC
19626 @@ -885,7 +1222,7 @@ ENTRY(stub_execve)
19627 RESTORE_REST
19628 jmp int_ret_from_sys_call
19629 CFI_ENDPROC
19630 -END(stub_execve)
19631 +ENDPROC(stub_execve)
19632
19633 /*
19634 * sigreturn is special because it needs to restore all registers on return.
19635 @@ -902,7 +1239,7 @@ ENTRY(stub_rt_sigreturn)
19636 RESTORE_REST
19637 jmp int_ret_from_sys_call
19638 CFI_ENDPROC
19639 -END(stub_rt_sigreturn)
19640 +ENDPROC(stub_rt_sigreturn)
19641
19642 #ifdef CONFIG_X86_X32_ABI
19643 ENTRY(stub_x32_rt_sigreturn)
19644 @@ -916,7 +1253,7 @@ ENTRY(stub_x32_rt_sigreturn)
19645 RESTORE_REST
19646 jmp int_ret_from_sys_call
19647 CFI_ENDPROC
19648 -END(stub_x32_rt_sigreturn)
19649 +ENDPROC(stub_x32_rt_sigreturn)
19650
19651 ENTRY(stub_x32_execve)
19652 CFI_STARTPROC
19653 @@ -930,7 +1267,7 @@ ENTRY(stub_x32_execve)
19654 RESTORE_REST
19655 jmp int_ret_from_sys_call
19656 CFI_ENDPROC
19657 -END(stub_x32_execve)
19658 +ENDPROC(stub_x32_execve)
19659
19660 #endif
19661
19662 @@ -967,7 +1304,7 @@ vector=vector+1
19663 2: jmp common_interrupt
19664 .endr
19665 CFI_ENDPROC
19666 -END(irq_entries_start)
19667 +ENDPROC(irq_entries_start)
19668
19669 .previous
19670 END(interrupt)
19671 @@ -987,6 +1324,16 @@ END(interrupt)
19672 subq $ORIG_RAX-RBP, %rsp
19673 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19674 SAVE_ARGS_IRQ
19675 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19676 + testb $3, CS(%rdi)
19677 + jnz 1f
19678 + pax_enter_kernel
19679 + jmp 2f
19680 +1: pax_enter_kernel_user
19681 +2:
19682 +#else
19683 + pax_enter_kernel
19684 +#endif
19685 call \func
19686 .endm
19687
19688 @@ -1019,7 +1366,7 @@ ret_from_intr:
19689
19690 exit_intr:
19691 GET_THREAD_INFO(%rcx)
19692 - testl $3,CS-ARGOFFSET(%rsp)
19693 + testb $3,CS-ARGOFFSET(%rsp)
19694 je retint_kernel
19695
19696 /* Interrupt came from user space */
19697 @@ -1041,12 +1388,16 @@ retint_swapgs: /* return to user-space */
19698 * The iretq could re-enable interrupts:
19699 */
19700 DISABLE_INTERRUPTS(CLBR_ANY)
19701 + pax_exit_kernel_user
19702 +retint_swapgs_pax:
19703 TRACE_IRQS_IRETQ
19704 SWAPGS
19705 jmp restore_args
19706
19707 retint_restore_args: /* return to kernel space */
19708 DISABLE_INTERRUPTS(CLBR_ANY)
19709 + pax_exit_kernel
19710 + pax_force_retaddr (RIP-ARGOFFSET)
19711 /*
19712 * The iretq could re-enable interrupts:
19713 */
19714 @@ -1129,7 +1480,7 @@ ENTRY(retint_kernel)
19715 #endif
19716
19717 CFI_ENDPROC
19718 -END(common_interrupt)
19719 +ENDPROC(common_interrupt)
19720 /*
19721 * End of kprobes section
19722 */
19723 @@ -1147,7 +1498,7 @@ ENTRY(\sym)
19724 interrupt \do_sym
19725 jmp ret_from_intr
19726 CFI_ENDPROC
19727 -END(\sym)
19728 +ENDPROC(\sym)
19729 .endm
19730
19731 #ifdef CONFIG_SMP
19732 @@ -1208,12 +1559,22 @@ ENTRY(\sym)
19733 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19734 call error_entry
19735 DEFAULT_FRAME 0
19736 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19737 + testb $3, CS(%rsp)
19738 + jnz 1f
19739 + pax_enter_kernel
19740 + jmp 2f
19741 +1: pax_enter_kernel_user
19742 +2:
19743 +#else
19744 + pax_enter_kernel
19745 +#endif
19746 movq %rsp,%rdi /* pt_regs pointer */
19747 xorl %esi,%esi /* no error code */
19748 call \do_sym
19749 jmp error_exit /* %ebx: no swapgs flag */
19750 CFI_ENDPROC
19751 -END(\sym)
19752 +ENDPROC(\sym)
19753 .endm
19754
19755 .macro paranoidzeroentry sym do_sym
19756 @@ -1226,15 +1587,25 @@ ENTRY(\sym)
19757 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19758 call save_paranoid
19759 TRACE_IRQS_OFF
19760 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19761 + testb $3, CS(%rsp)
19762 + jnz 1f
19763 + pax_enter_kernel
19764 + jmp 2f
19765 +1: pax_enter_kernel_user
19766 +2:
19767 +#else
19768 + pax_enter_kernel
19769 +#endif
19770 movq %rsp,%rdi /* pt_regs pointer */
19771 xorl %esi,%esi /* no error code */
19772 call \do_sym
19773 jmp paranoid_exit /* %ebx: no swapgs flag */
19774 CFI_ENDPROC
19775 -END(\sym)
19776 +ENDPROC(\sym)
19777 .endm
19778
19779 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19780 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19781 .macro paranoidzeroentry_ist sym do_sym ist
19782 ENTRY(\sym)
19783 INTR_FRAME
19784 @@ -1245,14 +1616,30 @@ ENTRY(\sym)
19785 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19786 call save_paranoid
19787 TRACE_IRQS_OFF_DEBUG
19788 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19789 + testb $3, CS(%rsp)
19790 + jnz 1f
19791 + pax_enter_kernel
19792 + jmp 2f
19793 +1: pax_enter_kernel_user
19794 +2:
19795 +#else
19796 + pax_enter_kernel
19797 +#endif
19798 movq %rsp,%rdi /* pt_regs pointer */
19799 xorl %esi,%esi /* no error code */
19800 +#ifdef CONFIG_SMP
19801 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19802 + lea init_tss(%r12), %r12
19803 +#else
19804 + lea init_tss(%rip), %r12
19805 +#endif
19806 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19807 call \do_sym
19808 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19809 jmp paranoid_exit /* %ebx: no swapgs flag */
19810 CFI_ENDPROC
19811 -END(\sym)
19812 +ENDPROC(\sym)
19813 .endm
19814
19815 .macro errorentry sym do_sym
19816 @@ -1264,13 +1651,23 @@ ENTRY(\sym)
19817 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19818 call error_entry
19819 DEFAULT_FRAME 0
19820 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19821 + testb $3, CS(%rsp)
19822 + jnz 1f
19823 + pax_enter_kernel
19824 + jmp 2f
19825 +1: pax_enter_kernel_user
19826 +2:
19827 +#else
19828 + pax_enter_kernel
19829 +#endif
19830 movq %rsp,%rdi /* pt_regs pointer */
19831 movq ORIG_RAX(%rsp),%rsi /* get error code */
19832 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19833 call \do_sym
19834 jmp error_exit /* %ebx: no swapgs flag */
19835 CFI_ENDPROC
19836 -END(\sym)
19837 +ENDPROC(\sym)
19838 .endm
19839
19840 /* error code is on the stack already */
19841 @@ -1284,13 +1681,23 @@ ENTRY(\sym)
19842 call save_paranoid
19843 DEFAULT_FRAME 0
19844 TRACE_IRQS_OFF
19845 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19846 + testb $3, CS(%rsp)
19847 + jnz 1f
19848 + pax_enter_kernel
19849 + jmp 2f
19850 +1: pax_enter_kernel_user
19851 +2:
19852 +#else
19853 + pax_enter_kernel
19854 +#endif
19855 movq %rsp,%rdi /* pt_regs pointer */
19856 movq ORIG_RAX(%rsp),%rsi /* get error code */
19857 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19858 call \do_sym
19859 jmp paranoid_exit /* %ebx: no swapgs flag */
19860 CFI_ENDPROC
19861 -END(\sym)
19862 +ENDPROC(\sym)
19863 .endm
19864
19865 zeroentry divide_error do_divide_error
19866 @@ -1320,9 +1727,10 @@ gs_change:
19867 2: mfence /* workaround */
19868 SWAPGS
19869 popfq_cfi
19870 + pax_force_retaddr
19871 ret
19872 CFI_ENDPROC
19873 -END(native_load_gs_index)
19874 +ENDPROC(native_load_gs_index)
19875
19876 _ASM_EXTABLE(gs_change,bad_gs)
19877 .section .fixup,"ax"
19878 @@ -1350,9 +1758,10 @@ ENTRY(call_softirq)
19879 CFI_DEF_CFA_REGISTER rsp
19880 CFI_ADJUST_CFA_OFFSET -8
19881 decl PER_CPU_VAR(irq_count)
19882 + pax_force_retaddr
19883 ret
19884 CFI_ENDPROC
19885 -END(call_softirq)
19886 +ENDPROC(call_softirq)
19887
19888 #ifdef CONFIG_XEN
19889 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19890 @@ -1390,7 +1799,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19891 decl PER_CPU_VAR(irq_count)
19892 jmp error_exit
19893 CFI_ENDPROC
19894 -END(xen_do_hypervisor_callback)
19895 +ENDPROC(xen_do_hypervisor_callback)
19896
19897 /*
19898 * Hypervisor uses this for application faults while it executes.
19899 @@ -1449,7 +1858,7 @@ ENTRY(xen_failsafe_callback)
19900 SAVE_ALL
19901 jmp error_exit
19902 CFI_ENDPROC
19903 -END(xen_failsafe_callback)
19904 +ENDPROC(xen_failsafe_callback)
19905
19906 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19907 xen_hvm_callback_vector xen_evtchn_do_upcall
19908 @@ -1501,18 +1910,33 @@ ENTRY(paranoid_exit)
19909 DEFAULT_FRAME
19910 DISABLE_INTERRUPTS(CLBR_NONE)
19911 TRACE_IRQS_OFF_DEBUG
19912 - testl %ebx,%ebx /* swapgs needed? */
19913 + testl $1,%ebx /* swapgs needed? */
19914 jnz paranoid_restore
19915 - testl $3,CS(%rsp)
19916 + testb $3,CS(%rsp)
19917 jnz paranoid_userspace
19918 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19919 + pax_exit_kernel
19920 + TRACE_IRQS_IRETQ 0
19921 + SWAPGS_UNSAFE_STACK
19922 + RESTORE_ALL 8
19923 + pax_force_retaddr_bts
19924 + jmp irq_return
19925 +#endif
19926 paranoid_swapgs:
19927 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19928 + pax_exit_kernel_user
19929 +#else
19930 + pax_exit_kernel
19931 +#endif
19932 TRACE_IRQS_IRETQ 0
19933 SWAPGS_UNSAFE_STACK
19934 RESTORE_ALL 8
19935 jmp irq_return
19936 paranoid_restore:
19937 + pax_exit_kernel
19938 TRACE_IRQS_IRETQ_DEBUG 0
19939 RESTORE_ALL 8
19940 + pax_force_retaddr_bts
19941 jmp irq_return
19942 paranoid_userspace:
19943 GET_THREAD_INFO(%rcx)
19944 @@ -1541,7 +1965,7 @@ paranoid_schedule:
19945 TRACE_IRQS_OFF
19946 jmp paranoid_userspace
19947 CFI_ENDPROC
19948 -END(paranoid_exit)
19949 +ENDPROC(paranoid_exit)
19950
19951 /*
19952 * Exception entry point. This expects an error code/orig_rax on the stack.
19953 @@ -1568,12 +1992,13 @@ ENTRY(error_entry)
19954 movq_cfi r14, R14+8
19955 movq_cfi r15, R15+8
19956 xorl %ebx,%ebx
19957 - testl $3,CS+8(%rsp)
19958 + testb $3,CS+8(%rsp)
19959 je error_kernelspace
19960 error_swapgs:
19961 SWAPGS
19962 error_sti:
19963 TRACE_IRQS_OFF
19964 + pax_force_retaddr_bts
19965 ret
19966
19967 /*
19968 @@ -1600,7 +2025,7 @@ bstep_iret:
19969 movq %rcx,RIP+8(%rsp)
19970 jmp error_swapgs
19971 CFI_ENDPROC
19972 -END(error_entry)
19973 +ENDPROC(error_entry)
19974
19975
19976 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19977 @@ -1611,7 +2036,7 @@ ENTRY(error_exit)
19978 DISABLE_INTERRUPTS(CLBR_NONE)
19979 TRACE_IRQS_OFF
19980 GET_THREAD_INFO(%rcx)
19981 - testl %eax,%eax
19982 + testl $1,%eax
19983 jne retint_kernel
19984 LOCKDEP_SYS_EXIT_IRQ
19985 movl TI_flags(%rcx),%edx
19986 @@ -1620,7 +2045,7 @@ ENTRY(error_exit)
19987 jnz retint_careful
19988 jmp retint_swapgs
19989 CFI_ENDPROC
19990 -END(error_exit)
19991 +ENDPROC(error_exit)
19992
19993 /*
19994 * Test if a given stack is an NMI stack or not.
19995 @@ -1678,9 +2103,11 @@ ENTRY(nmi)
19996 * If %cs was not the kernel segment, then the NMI triggered in user
19997 * space, which means it is definitely not nested.
19998 */
19999 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20000 + je 1f
20001 cmpl $__KERNEL_CS, 16(%rsp)
20002 jne first_nmi
20003 -
20004 +1:
20005 /*
20006 * Check the special variable on the stack to see if NMIs are
20007 * executing.
20008 @@ -1714,8 +2141,7 @@ nested_nmi:
20009
20010 1:
20011 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20012 - leaq -1*8(%rsp), %rdx
20013 - movq %rdx, %rsp
20014 + subq $8, %rsp
20015 CFI_ADJUST_CFA_OFFSET 1*8
20016 leaq -10*8(%rsp), %rdx
20017 pushq_cfi $__KERNEL_DS
20018 @@ -1733,6 +2159,7 @@ nested_nmi_out:
20019 CFI_RESTORE rdx
20020
20021 /* No need to check faults here */
20022 +# pax_force_retaddr_bts
20023 INTERRUPT_RETURN
20024
20025 CFI_RESTORE_STATE
20026 @@ -1849,6 +2276,8 @@ end_repeat_nmi:
20027 */
20028 movq %cr2, %r12
20029
20030 + pax_enter_kernel_nmi
20031 +
20032 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20033 movq %rsp,%rdi
20034 movq $-1,%rsi
20035 @@ -1861,26 +2290,31 @@ end_repeat_nmi:
20036 movq %r12, %cr2
20037 1:
20038
20039 - testl %ebx,%ebx /* swapgs needed? */
20040 + testl $1,%ebx /* swapgs needed? */
20041 jnz nmi_restore
20042 nmi_swapgs:
20043 SWAPGS_UNSAFE_STACK
20044 nmi_restore:
20045 + pax_exit_kernel_nmi
20046 /* Pop the extra iret frame at once */
20047 RESTORE_ALL 6*8
20048 + testb $3, 8(%rsp)
20049 + jnz 1f
20050 + pax_force_retaddr_bts
20051 +1:
20052
20053 /* Clear the NMI executing stack variable */
20054 movq $0, 5*8(%rsp)
20055 jmp irq_return
20056 CFI_ENDPROC
20057 -END(nmi)
20058 +ENDPROC(nmi)
20059
20060 ENTRY(ignore_sysret)
20061 CFI_STARTPROC
20062 mov $-ENOSYS,%eax
20063 sysret
20064 CFI_ENDPROC
20065 -END(ignore_sysret)
20066 +ENDPROC(ignore_sysret)
20067
20068 /*
20069 * End of kprobes section
20070 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20071 index 42a392a..fbbd930 100644
20072 --- a/arch/x86/kernel/ftrace.c
20073 +++ b/arch/x86/kernel/ftrace.c
20074 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20075 {
20076 unsigned char replaced[MCOUNT_INSN_SIZE];
20077
20078 + ip = ktla_ktva(ip);
20079 +
20080 /*
20081 * Note: Due to modules and __init, code can
20082 * disappear and change, we need to protect against faulting
20083 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20084 unsigned char old[MCOUNT_INSN_SIZE], *new;
20085 int ret;
20086
20087 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20088 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20089 new = ftrace_call_replace(ip, (unsigned long)func);
20090
20091 /* See comment above by declaration of modifying_ftrace_code */
20092 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20093 /* Also update the regs callback function */
20094 if (!ret) {
20095 ip = (unsigned long)(&ftrace_regs_call);
20096 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20097 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20098 new = ftrace_call_replace(ip, (unsigned long)func);
20099 ret = ftrace_modify_code(ip, old, new);
20100 }
20101 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20102 * kernel identity mapping to modify code.
20103 */
20104 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20105 - ip = (unsigned long)__va(__pa_symbol(ip));
20106 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20107
20108 return probe_kernel_write((void *)ip, val, size);
20109 }
20110 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20111 unsigned char replaced[MCOUNT_INSN_SIZE];
20112 unsigned char brk = BREAKPOINT_INSTRUCTION;
20113
20114 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20115 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20116 return -EFAULT;
20117
20118 /* Make sure it is what we expect it to be */
20119 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20120 return ret;
20121
20122 fail_update:
20123 - probe_kernel_write((void *)ip, &old_code[0], 1);
20124 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20125 goto out;
20126 }
20127
20128 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20129 {
20130 unsigned char code[MCOUNT_INSN_SIZE];
20131
20132 + ip = ktla_ktva(ip);
20133 +
20134 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20135 return -EFAULT;
20136
20137 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20138 index 55b6761..a6456fc 100644
20139 --- a/arch/x86/kernel/head64.c
20140 +++ b/arch/x86/kernel/head64.c
20141 @@ -67,12 +67,12 @@ again:
20142 pgd = *pgd_p;
20143
20144 /*
20145 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
20146 - * critical -- __PAGE_OFFSET would point us back into the dynamic
20147 + * The use of __early_va rather than __va here is critical:
20148 + * __va would point us back into the dynamic
20149 * range and we might end up looping forever...
20150 */
20151 if (pgd)
20152 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20153 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
20154 else {
20155 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20156 reset_early_page_tables();
20157 @@ -82,13 +82,13 @@ again:
20158 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
20159 for (i = 0; i < PTRS_PER_PUD; i++)
20160 pud_p[i] = 0;
20161 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20162 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
20163 }
20164 pud_p += pud_index(address);
20165 pud = *pud_p;
20166
20167 if (pud)
20168 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20169 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
20170 else {
20171 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20172 reset_early_page_tables();
20173 @@ -98,7 +98,7 @@ again:
20174 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
20175 for (i = 0; i < PTRS_PER_PMD; i++)
20176 pmd_p[i] = 0;
20177 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20178 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
20179 }
20180 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
20181 pmd_p[pmd_index(address)] = pmd;
20182 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20183 if (console_loglevel == 10)
20184 early_printk("Kernel alive\n");
20185
20186 - clear_page(init_level4_pgt);
20187 /* set init_level4_pgt kernel high mapping*/
20188 init_level4_pgt[511] = early_level4_pgt[511];
20189
20190 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20191 index 73afd11..d1670f5 100644
20192 --- a/arch/x86/kernel/head_32.S
20193 +++ b/arch/x86/kernel/head_32.S
20194 @@ -26,6 +26,12 @@
20195 /* Physical address */
20196 #define pa(X) ((X) - __PAGE_OFFSET)
20197
20198 +#ifdef CONFIG_PAX_KERNEXEC
20199 +#define ta(X) (X)
20200 +#else
20201 +#define ta(X) ((X) - __PAGE_OFFSET)
20202 +#endif
20203 +
20204 /*
20205 * References to members of the new_cpu_data structure.
20206 */
20207 @@ -55,11 +61,7 @@
20208 * and small than max_low_pfn, otherwise will waste some page table entries
20209 */
20210
20211 -#if PTRS_PER_PMD > 1
20212 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20213 -#else
20214 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20215 -#endif
20216 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20217
20218 /* Number of possible pages in the lowmem region */
20219 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20220 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20221 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20222
20223 /*
20224 + * Real beginning of normal "text" segment
20225 + */
20226 +ENTRY(stext)
20227 +ENTRY(_stext)
20228 +
20229 +/*
20230 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20231 * %esi points to the real-mode code as a 32-bit pointer.
20232 * CS and DS must be 4 GB flat segments, but we don't depend on
20233 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20234 * can.
20235 */
20236 __HEAD
20237 +
20238 +#ifdef CONFIG_PAX_KERNEXEC
20239 + jmp startup_32
20240 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20241 +.fill PAGE_SIZE-5,1,0xcc
20242 +#endif
20243 +
20244 ENTRY(startup_32)
20245 movl pa(stack_start),%ecx
20246
20247 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20248 2:
20249 leal -__PAGE_OFFSET(%ecx),%esp
20250
20251 +#ifdef CONFIG_SMP
20252 + movl $pa(cpu_gdt_table),%edi
20253 + movl $__per_cpu_load,%eax
20254 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20255 + rorl $16,%eax
20256 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20257 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20258 + movl $__per_cpu_end - 1,%eax
20259 + subl $__per_cpu_start,%eax
20260 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20261 +#endif
20262 +
20263 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20264 + movl $NR_CPUS,%ecx
20265 + movl $pa(cpu_gdt_table),%edi
20266 +1:
20267 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20268 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20269 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20270 + addl $PAGE_SIZE_asm,%edi
20271 + loop 1b
20272 +#endif
20273 +
20274 +#ifdef CONFIG_PAX_KERNEXEC
20275 + movl $pa(boot_gdt),%edi
20276 + movl $__LOAD_PHYSICAL_ADDR,%eax
20277 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20278 + rorl $16,%eax
20279 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20280 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20281 + rorl $16,%eax
20282 +
20283 + ljmp $(__BOOT_CS),$1f
20284 +1:
20285 +
20286 + movl $NR_CPUS,%ecx
20287 + movl $pa(cpu_gdt_table),%edi
20288 + addl $__PAGE_OFFSET,%eax
20289 +1:
20290 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20291 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20292 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20293 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20294 + rorl $16,%eax
20295 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20296 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20297 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20298 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20299 + rorl $16,%eax
20300 + addl $PAGE_SIZE_asm,%edi
20301 + loop 1b
20302 +#endif
20303 +
20304 /*
20305 * Clear BSS first so that there are no surprises...
20306 */
20307 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20308 movl %eax, pa(max_pfn_mapped)
20309
20310 /* Do early initialization of the fixmap area */
20311 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20312 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20313 +#ifdef CONFIG_COMPAT_VDSO
20314 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20315 +#else
20316 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20317 +#endif
20318 #else /* Not PAE */
20319
20320 page_pde_offset = (__PAGE_OFFSET >> 20);
20321 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20322 movl %eax, pa(max_pfn_mapped)
20323
20324 /* Do early initialization of the fixmap area */
20325 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20326 - movl %eax,pa(initial_page_table+0xffc)
20327 +#ifdef CONFIG_COMPAT_VDSO
20328 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20329 +#else
20330 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20331 +#endif
20332 #endif
20333
20334 #ifdef CONFIG_PARAVIRT
20335 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20336 cmpl $num_subarch_entries, %eax
20337 jae bad_subarch
20338
20339 - movl pa(subarch_entries)(,%eax,4), %eax
20340 - subl $__PAGE_OFFSET, %eax
20341 - jmp *%eax
20342 + jmp *pa(subarch_entries)(,%eax,4)
20343
20344 bad_subarch:
20345 WEAK(lguest_entry)
20346 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20347 __INITDATA
20348
20349 subarch_entries:
20350 - .long default_entry /* normal x86/PC */
20351 - .long lguest_entry /* lguest hypervisor */
20352 - .long xen_entry /* Xen hypervisor */
20353 - .long default_entry /* Moorestown MID */
20354 + .long ta(default_entry) /* normal x86/PC */
20355 + .long ta(lguest_entry) /* lguest hypervisor */
20356 + .long ta(xen_entry) /* Xen hypervisor */
20357 + .long ta(default_entry) /* Moorestown MID */
20358 num_subarch_entries = (. - subarch_entries) / 4
20359 .previous
20360 #else
20361 @@ -355,6 +427,7 @@ default_entry:
20362 movl pa(mmu_cr4_features),%eax
20363 movl %eax,%cr4
20364
20365 +#ifdef CONFIG_X86_PAE
20366 testb $X86_CR4_PAE, %al # check if PAE is enabled
20367 jz enable_paging
20368
20369 @@ -383,6 +456,9 @@ default_entry:
20370 /* Make changes effective */
20371 wrmsr
20372
20373 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20374 +#endif
20375 +
20376 enable_paging:
20377
20378 /*
20379 @@ -451,14 +527,20 @@ is486:
20380 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20381 movl %eax,%ss # after changing gdt.
20382
20383 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20384 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20385 movl %eax,%ds
20386 movl %eax,%es
20387
20388 movl $(__KERNEL_PERCPU), %eax
20389 movl %eax,%fs # set this cpu's percpu
20390
20391 +#ifdef CONFIG_CC_STACKPROTECTOR
20392 movl $(__KERNEL_STACK_CANARY),%eax
20393 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20394 + movl $(__USER_DS),%eax
20395 +#else
20396 + xorl %eax,%eax
20397 +#endif
20398 movl %eax,%gs
20399
20400 xorl %eax,%eax # Clear LDT
20401 @@ -534,8 +616,11 @@ setup_once:
20402 * relocation. Manually set base address in stack canary
20403 * segment descriptor.
20404 */
20405 - movl $gdt_page,%eax
20406 + movl $cpu_gdt_table,%eax
20407 movl $stack_canary,%ecx
20408 +#ifdef CONFIG_SMP
20409 + addl $__per_cpu_load,%ecx
20410 +#endif
20411 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20412 shrl $16, %ecx
20413 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20414 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20415 /* This is global to keep gas from relaxing the jumps */
20416 ENTRY(early_idt_handler)
20417 cld
20418 - cmpl $2,%ss:early_recursion_flag
20419 + cmpl $1,%ss:early_recursion_flag
20420 je hlt_loop
20421 incl %ss:early_recursion_flag
20422
20423 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20424 pushl (20+6*4)(%esp) /* trapno */
20425 pushl $fault_msg
20426 call printk
20427 -#endif
20428 call dump_stack
20429 +#endif
20430 hlt_loop:
20431 hlt
20432 jmp hlt_loop
20433 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20434 /* This is the default interrupt "handler" :-) */
20435 ALIGN
20436 ignore_int:
20437 - cld
20438 #ifdef CONFIG_PRINTK
20439 + cmpl $2,%ss:early_recursion_flag
20440 + je hlt_loop
20441 + incl %ss:early_recursion_flag
20442 + cld
20443 pushl %eax
20444 pushl %ecx
20445 pushl %edx
20446 @@ -634,9 +722,6 @@ ignore_int:
20447 movl $(__KERNEL_DS),%eax
20448 movl %eax,%ds
20449 movl %eax,%es
20450 - cmpl $2,early_recursion_flag
20451 - je hlt_loop
20452 - incl early_recursion_flag
20453 pushl 16(%esp)
20454 pushl 24(%esp)
20455 pushl 32(%esp)
20456 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20457 /*
20458 * BSS section
20459 */
20460 -__PAGE_ALIGNED_BSS
20461 - .align PAGE_SIZE
20462 #ifdef CONFIG_X86_PAE
20463 +.section .initial_pg_pmd,"a",@progbits
20464 initial_pg_pmd:
20465 .fill 1024*KPMDS,4,0
20466 #else
20467 +.section .initial_page_table,"a",@progbits
20468 ENTRY(initial_page_table)
20469 .fill 1024,4,0
20470 #endif
20471 +.section .initial_pg_fixmap,"a",@progbits
20472 initial_pg_fixmap:
20473 .fill 1024,4,0
20474 +.section .empty_zero_page,"a",@progbits
20475 ENTRY(empty_zero_page)
20476 .fill 4096,1,0
20477 +.section .swapper_pg_dir,"a",@progbits
20478 ENTRY(swapper_pg_dir)
20479 +#ifdef CONFIG_X86_PAE
20480 + .fill 4,8,0
20481 +#else
20482 .fill 1024,4,0
20483 +#endif
20484 +
20485 +/*
20486 + * The IDT has to be page-aligned to simplify the Pentium
20487 + * F0 0F bug workaround.. We have a special link segment
20488 + * for this.
20489 + */
20490 +.section .idt,"a",@progbits
20491 +ENTRY(idt_table)
20492 + .fill 256,8,0
20493
20494 /*
20495 * This starts the data section.
20496 */
20497 #ifdef CONFIG_X86_PAE
20498 -__PAGE_ALIGNED_DATA
20499 - /* Page-aligned for the benefit of paravirt? */
20500 - .align PAGE_SIZE
20501 +.section .initial_page_table,"a",@progbits
20502 ENTRY(initial_page_table)
20503 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20504 # if KPMDS == 3
20505 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20506 # error "Kernel PMDs should be 1, 2 or 3"
20507 # endif
20508 .align PAGE_SIZE /* needs to be page-sized too */
20509 +
20510 +#ifdef CONFIG_PAX_PER_CPU_PGD
20511 +ENTRY(cpu_pgd)
20512 + .rept NR_CPUS
20513 + .fill 4,8,0
20514 + .endr
20515 +#endif
20516 +
20517 #endif
20518
20519 .data
20520 .balign 4
20521 ENTRY(stack_start)
20522 - .long init_thread_union+THREAD_SIZE
20523 + .long init_thread_union+THREAD_SIZE-8
20524
20525 __INITRODATA
20526 int_msg:
20527 @@ -744,7 +851,7 @@ fault_msg:
20528 * segment size, and 32-bit linear address value:
20529 */
20530
20531 - .data
20532 +.section .rodata,"a",@progbits
20533 .globl boot_gdt_descr
20534 .globl idt_descr
20535
20536 @@ -753,7 +860,7 @@ fault_msg:
20537 .word 0 # 32 bit align gdt_desc.address
20538 boot_gdt_descr:
20539 .word __BOOT_DS+7
20540 - .long boot_gdt - __PAGE_OFFSET
20541 + .long pa(boot_gdt)
20542
20543 .word 0 # 32-bit align idt_desc.address
20544 idt_descr:
20545 @@ -764,7 +871,7 @@ idt_descr:
20546 .word 0 # 32 bit align gdt_desc.address
20547 ENTRY(early_gdt_descr)
20548 .word GDT_ENTRIES*8-1
20549 - .long gdt_page /* Overwritten for secondary CPUs */
20550 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20551
20552 /*
20553 * The boot_gdt must mirror the equivalent in setup.S and is
20554 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20555 .align L1_CACHE_BYTES
20556 ENTRY(boot_gdt)
20557 .fill GDT_ENTRY_BOOT_CS,8,0
20558 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20559 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20560 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20561 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20562 +
20563 + .align PAGE_SIZE_asm
20564 +ENTRY(cpu_gdt_table)
20565 + .rept NR_CPUS
20566 + .quad 0x0000000000000000 /* NULL descriptor */
20567 + .quad 0x0000000000000000 /* 0x0b reserved */
20568 + .quad 0x0000000000000000 /* 0x13 reserved */
20569 + .quad 0x0000000000000000 /* 0x1b reserved */
20570 +
20571 +#ifdef CONFIG_PAX_KERNEXEC
20572 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20573 +#else
20574 + .quad 0x0000000000000000 /* 0x20 unused */
20575 +#endif
20576 +
20577 + .quad 0x0000000000000000 /* 0x28 unused */
20578 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20579 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20580 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20581 + .quad 0x0000000000000000 /* 0x4b reserved */
20582 + .quad 0x0000000000000000 /* 0x53 reserved */
20583 + .quad 0x0000000000000000 /* 0x5b reserved */
20584 +
20585 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20586 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20587 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20588 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20589 +
20590 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20591 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20592 +
20593 + /*
20594 + * Segments used for calling PnP BIOS have byte granularity.
20595 + * The code segments and data segments have fixed 64k limits,
20596 + * the transfer segment sizes are set at run time.
20597 + */
20598 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20599 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20600 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20601 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20602 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20603 +
20604 + /*
20605 + * The APM segments have byte granularity and their bases
20606 + * are set at run time. All have 64k limits.
20607 + */
20608 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20609 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20610 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20611 +
20612 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20613 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20614 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20615 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20616 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20617 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20618 +
20619 + /* Be sure this is zeroed to avoid false validations in Xen */
20620 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20621 + .endr
20622 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20623 index 321d65e..863089b 100644
20624 --- a/arch/x86/kernel/head_64.S
20625 +++ b/arch/x86/kernel/head_64.S
20626 @@ -20,6 +20,8 @@
20627 #include <asm/processor-flags.h>
20628 #include <asm/percpu.h>
20629 #include <asm/nops.h>
20630 +#include <asm/cpufeature.h>
20631 +#include <asm/alternative-asm.h>
20632
20633 #ifdef CONFIG_PARAVIRT
20634 #include <asm/asm-offsets.h>
20635 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20636 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20637 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20638 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20639 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20640 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20641 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20642 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20643 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20644 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20645
20646 .text
20647 __HEAD
20648 @@ -89,11 +97,23 @@ startup_64:
20649 * Fixup the physical addresses in the page table
20650 */
20651 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20652 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20653 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20654 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20655 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20656 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20657
20658 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20659 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20660 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
20661 +#ifndef CONFIG_XEN
20662 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
20663 +#endif
20664
20665 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20666 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20667 +
20668 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20669 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
20670 +
20671 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20672
20673 /*
20674 * Set up the identity mapping for the switchover. These
20675 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
20676 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20677 1:
20678
20679 - /* Enable PAE mode and PGE */
20680 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20681 + /* Enable PAE mode and PSE/PGE */
20682 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20683 movq %rcx, %cr4
20684
20685 /* Setup early boot stage 4 level pagetables. */
20686 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
20687 movl $MSR_EFER, %ecx
20688 rdmsr
20689 btsl $_EFER_SCE, %eax /* Enable System Call */
20690 - btl $20,%edi /* No Execute supported? */
20691 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20692 jnc 1f
20693 btsl $_EFER_NX, %eax
20694 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20695 + leaq init_level4_pgt(%rip), %rdi
20696 +#ifndef CONFIG_EFI
20697 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20698 +#endif
20699 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20700 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20701 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20702 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20703 1: wrmsr /* Make changes effective */
20704
20705 /* Setup cr0 */
20706 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
20707 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20708 * address given in m16:64.
20709 */
20710 + pax_set_fptr_mask
20711 movq initial_code(%rip),%rax
20712 pushq $0 # fake return address to stop unwinder
20713 pushq $__KERNEL_CS # set correct cs
20714 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
20715 call dump_stack
20716 #ifdef CONFIG_KALLSYMS
20717 leaq early_idt_ripmsg(%rip),%rdi
20718 - movq 40(%rsp),%rsi # %rip again
20719 + movq 88(%rsp),%rsi # %rip again
20720 call __print_symbol
20721 #endif
20722 #endif /* EARLY_PRINTK */
20723 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
20724 early_recursion_flag:
20725 .long 0
20726
20727 + .section .rodata,"a",@progbits
20728 #ifdef CONFIG_EARLY_PRINTK
20729 early_idt_msg:
20730 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20731 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
20732 NEXT_PAGE(early_dynamic_pgts)
20733 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
20734
20735 - .data
20736 + .section .rodata,"a",@progbits
20737
20738 -#ifndef CONFIG_XEN
20739 NEXT_PAGE(init_level4_pgt)
20740 - .fill 512,8,0
20741 -#else
20742 -NEXT_PAGE(init_level4_pgt)
20743 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20744 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20745 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20746 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20747 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20748 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20749 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20750 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20751 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20752 .org init_level4_pgt + L4_START_KERNEL*8, 0
20753 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20754 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20755
20756 +#ifdef CONFIG_PAX_PER_CPU_PGD
20757 +NEXT_PAGE(cpu_pgd)
20758 + .rept NR_CPUS
20759 + .fill 512,8,0
20760 + .endr
20761 +#endif
20762 +
20763 NEXT_PAGE(level3_ident_pgt)
20764 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20765 +#ifdef CONFIG_XEN
20766 .fill 511, 8, 0
20767 +#else
20768 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20769 + .fill 510,8,0
20770 +#endif
20771 +
20772 +NEXT_PAGE(level3_vmalloc_start_pgt)
20773 + .fill 512,8,0
20774 +
20775 +NEXT_PAGE(level3_vmalloc_end_pgt)
20776 + .fill 512,8,0
20777 +
20778 +NEXT_PAGE(level3_vmemmap_pgt)
20779 + .fill L3_VMEMMAP_START,8,0
20780 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20781 +
20782 NEXT_PAGE(level2_ident_pgt)
20783 - /* Since I easily can, map the first 1G.
20784 + /* Since I easily can, map the first 2G.
20785 * Don't set NX because code runs from these pages.
20786 */
20787 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20788 -#endif
20789 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20790
20791 NEXT_PAGE(level3_kernel_pgt)
20792 .fill L3_START_KERNEL,8,0
20793 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
20794 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20795 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20796
20797 +NEXT_PAGE(level2_vmemmap_pgt)
20798 + .fill 512,8,0
20799 +
20800 NEXT_PAGE(level2_kernel_pgt)
20801 /*
20802 * 512 MB kernel mapping. We spend a full page on this pagetable
20803 @@ -488,39 +544,64 @@ NEXT_PAGE(level2_kernel_pgt)
20804 KERNEL_IMAGE_SIZE/PMD_SIZE)
20805
20806 NEXT_PAGE(level2_fixmap_pgt)
20807 - .fill 506,8,0
20808 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20809 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20810 - .fill 5,8,0
20811 + .fill 507,8,0
20812 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20813 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20814 + .fill 4,8,0
20815
20816 -NEXT_PAGE(level1_fixmap_pgt)
20817 +NEXT_PAGE(level1_vsyscall_pgt)
20818 .fill 512,8,0
20819
20820 #undef PMDS
20821
20822 - .data
20823 + .align PAGE_SIZE
20824 +ENTRY(cpu_gdt_table)
20825 + .rept NR_CPUS
20826 + .quad 0x0000000000000000 /* NULL descriptor */
20827 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20828 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20829 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20830 + .quad 0x00cffb000000ffff /* __USER32_CS */
20831 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20832 + .quad 0x00affb000000ffff /* __USER_CS */
20833 +
20834 +#ifdef CONFIG_PAX_KERNEXEC
20835 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20836 +#else
20837 + .quad 0x0 /* unused */
20838 +#endif
20839 +
20840 + .quad 0,0 /* TSS */
20841 + .quad 0,0 /* LDT */
20842 + .quad 0,0,0 /* three TLS descriptors */
20843 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20844 + /* asm/segment.h:GDT_ENTRIES must match this */
20845 +
20846 + /* zero the remaining page */
20847 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20848 + .endr
20849 +
20850 .align 16
20851 .globl early_gdt_descr
20852 early_gdt_descr:
20853 .word GDT_ENTRIES*8-1
20854 early_gdt_descr_base:
20855 - .quad INIT_PER_CPU_VAR(gdt_page)
20856 + .quad cpu_gdt_table
20857
20858 ENTRY(phys_base)
20859 /* This must match the first entry in level2_kernel_pgt */
20860 .quad 0x0000000000000000
20861
20862 #include "../../x86/xen/xen-head.S"
20863 -
20864 - .section .bss, "aw", @nobits
20865 - .align L1_CACHE_BYTES
20866 -ENTRY(idt_table)
20867 - .skip IDT_ENTRIES * 16
20868
20869 - .align L1_CACHE_BYTES
20870 -ENTRY(nmi_idt_table)
20871 - .skip IDT_ENTRIES * 16
20872 -
20873 - __PAGE_ALIGNED_BSS
20874 + .section .rodata,"a",@progbits
20875 NEXT_PAGE(empty_zero_page)
20876 .skip PAGE_SIZE
20877 +
20878 + .align L1_CACHE_BYTES
20879 +ENTRY(idt_table)
20880 + .fill 512,8,0
20881 +
20882 + .align L1_CACHE_BYTES
20883 +ENTRY(nmi_idt_table)
20884 + .fill 512,8,0
20885 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20886 index 0fa6912..37fce70 100644
20887 --- a/arch/x86/kernel/i386_ksyms_32.c
20888 +++ b/arch/x86/kernel/i386_ksyms_32.c
20889 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20890 EXPORT_SYMBOL(cmpxchg8b_emu);
20891 #endif
20892
20893 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20894 +
20895 /* Networking helper routines. */
20896 EXPORT_SYMBOL(csum_partial_copy_generic);
20897 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20898 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20899
20900 EXPORT_SYMBOL(__get_user_1);
20901 EXPORT_SYMBOL(__get_user_2);
20902 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20903
20904 EXPORT_SYMBOL(csum_partial);
20905 EXPORT_SYMBOL(empty_zero_page);
20906 +
20907 +#ifdef CONFIG_PAX_KERNEXEC
20908 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20909 +#endif
20910 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20911 index cb33909..1163b40 100644
20912 --- a/arch/x86/kernel/i387.c
20913 +++ b/arch/x86/kernel/i387.c
20914 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20915 static inline bool interrupted_user_mode(void)
20916 {
20917 struct pt_regs *regs = get_irq_regs();
20918 - return regs && user_mode_vm(regs);
20919 + return regs && user_mode(regs);
20920 }
20921
20922 /*
20923 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20924 index 9a5c460..84868423 100644
20925 --- a/arch/x86/kernel/i8259.c
20926 +++ b/arch/x86/kernel/i8259.c
20927 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20928 static void make_8259A_irq(unsigned int irq)
20929 {
20930 disable_irq_nosync(irq);
20931 - io_apic_irqs &= ~(1<<irq);
20932 + io_apic_irqs &= ~(1UL<<irq);
20933 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20934 i8259A_chip.name);
20935 enable_irq(irq);
20936 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20937 "spurious 8259A interrupt: IRQ%d.\n", irq);
20938 spurious_irq_mask |= irqmask;
20939 }
20940 - atomic_inc(&irq_err_count);
20941 + atomic_inc_unchecked(&irq_err_count);
20942 /*
20943 * Theoretically we do not have to handle this IRQ,
20944 * but in Linux this does not cause problems and is
20945 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20946 /* (slave's support for AEOI in flat mode is to be investigated) */
20947 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20948
20949 + pax_open_kernel();
20950 if (auto_eoi)
20951 /*
20952 * In AEOI mode we just have to mask the interrupt
20953 * when acking.
20954 */
20955 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20956 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20957 else
20958 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20959 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20960 + pax_close_kernel();
20961
20962 udelay(100); /* wait for 8259A to initialize */
20963
20964 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20965 index a979b5b..1d6db75 100644
20966 --- a/arch/x86/kernel/io_delay.c
20967 +++ b/arch/x86/kernel/io_delay.c
20968 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20969 * Quirk table for systems that misbehave (lock up, etc.) if port
20970 * 0x80 is used:
20971 */
20972 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20973 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20974 {
20975 .callback = dmi_io_delay_0xed_port,
20976 .ident = "Compaq Presario V6000",
20977 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20978 index 4ddaf66..6292f4e 100644
20979 --- a/arch/x86/kernel/ioport.c
20980 +++ b/arch/x86/kernel/ioport.c
20981 @@ -6,6 +6,7 @@
20982 #include <linux/sched.h>
20983 #include <linux/kernel.h>
20984 #include <linux/capability.h>
20985 +#include <linux/security.h>
20986 #include <linux/errno.h>
20987 #include <linux/types.h>
20988 #include <linux/ioport.h>
20989 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20990
20991 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20992 return -EINVAL;
20993 +#ifdef CONFIG_GRKERNSEC_IO
20994 + if (turn_on && grsec_disable_privio) {
20995 + gr_handle_ioperm();
20996 + return -EPERM;
20997 + }
20998 +#endif
20999 if (turn_on && !capable(CAP_SYS_RAWIO))
21000 return -EPERM;
21001
21002 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21003 * because the ->io_bitmap_max value must match the bitmap
21004 * contents:
21005 */
21006 - tss = &per_cpu(init_tss, get_cpu());
21007 + tss = init_tss + get_cpu();
21008
21009 if (turn_on)
21010 bitmap_clear(t->io_bitmap_ptr, from, num);
21011 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
21012 return -EINVAL;
21013 /* Trying to gain more privileges? */
21014 if (level > old) {
21015 +#ifdef CONFIG_GRKERNSEC_IO
21016 + if (grsec_disable_privio) {
21017 + gr_handle_iopl();
21018 + return -EPERM;
21019 + }
21020 +#endif
21021 if (!capable(CAP_SYS_RAWIO))
21022 return -EPERM;
21023 }
21024 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21025 index ac0631d..ff7cb62 100644
21026 --- a/arch/x86/kernel/irq.c
21027 +++ b/arch/x86/kernel/irq.c
21028 @@ -18,7 +18,7 @@
21029 #include <asm/mce.h>
21030 #include <asm/hw_irq.h>
21031
21032 -atomic_t irq_err_count;
21033 +atomic_unchecked_t irq_err_count;
21034
21035 /* Function pointer for generic interrupt vector handling */
21036 void (*x86_platform_ipi_callback)(void) = NULL;
21037 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21038 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21039 seq_printf(p, " Machine check polls\n");
21040 #endif
21041 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21042 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21043 #if defined(CONFIG_X86_IO_APIC)
21044 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21045 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21046 #endif
21047 return 0;
21048 }
21049 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21050
21051 u64 arch_irq_stat(void)
21052 {
21053 - u64 sum = atomic_read(&irq_err_count);
21054 + u64 sum = atomic_read_unchecked(&irq_err_count);
21055 return sum;
21056 }
21057
21058 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21059 index 344faf8..355f60d 100644
21060 --- a/arch/x86/kernel/irq_32.c
21061 +++ b/arch/x86/kernel/irq_32.c
21062 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21063 __asm__ __volatile__("andl %%esp,%0" :
21064 "=r" (sp) : "0" (THREAD_SIZE - 1));
21065
21066 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21067 + return sp < STACK_WARN;
21068 }
21069
21070 static void print_stack_overflow(void)
21071 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21072 * per-CPU IRQ handling contexts (thread information and stack)
21073 */
21074 union irq_ctx {
21075 - struct thread_info tinfo;
21076 - u32 stack[THREAD_SIZE/sizeof(u32)];
21077 + unsigned long previous_esp;
21078 + u32 stack[THREAD_SIZE/sizeof(u32)];
21079 } __attribute__((aligned(THREAD_SIZE)));
21080
21081 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21082 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21083 static inline int
21084 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21085 {
21086 - union irq_ctx *curctx, *irqctx;
21087 + union irq_ctx *irqctx;
21088 u32 *isp, arg1, arg2;
21089
21090 - curctx = (union irq_ctx *) current_thread_info();
21091 irqctx = __this_cpu_read(hardirq_ctx);
21092
21093 /*
21094 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21095 * handler) we can't do that and just have to keep using the
21096 * current stack (which is the irq stack already after all)
21097 */
21098 - if (unlikely(curctx == irqctx))
21099 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21100 return 0;
21101
21102 /* build the stack frame on the IRQ stack */
21103 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21104 - irqctx->tinfo.task = curctx->tinfo.task;
21105 - irqctx->tinfo.previous_esp = current_stack_pointer;
21106 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21107 + irqctx->previous_esp = current_stack_pointer;
21108
21109 - /* Copy the preempt_count so that the [soft]irq checks work. */
21110 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21111 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21112 + __set_fs(MAKE_MM_SEG(0));
21113 +#endif
21114
21115 if (unlikely(overflow))
21116 call_on_stack(print_stack_overflow, isp);
21117 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21118 : "0" (irq), "1" (desc), "2" (isp),
21119 "D" (desc->handle_irq)
21120 : "memory", "cc", "ecx");
21121 +
21122 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21123 + __set_fs(current_thread_info()->addr_limit);
21124 +#endif
21125 +
21126 return 1;
21127 }
21128
21129 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21130 */
21131 void __cpuinit irq_ctx_init(int cpu)
21132 {
21133 - union irq_ctx *irqctx;
21134 -
21135 if (per_cpu(hardirq_ctx, cpu))
21136 return;
21137
21138 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21139 - THREADINFO_GFP,
21140 - THREAD_SIZE_ORDER));
21141 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21142 - irqctx->tinfo.cpu = cpu;
21143 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21144 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21145 -
21146 - per_cpu(hardirq_ctx, cpu) = irqctx;
21147 -
21148 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21149 - THREADINFO_GFP,
21150 - THREAD_SIZE_ORDER));
21151 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21152 - irqctx->tinfo.cpu = cpu;
21153 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21154 -
21155 - per_cpu(softirq_ctx, cpu) = irqctx;
21156 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21157 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21158 +
21159 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21160 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21161
21162 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21163 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21164 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21165 asmlinkage void do_softirq(void)
21166 {
21167 unsigned long flags;
21168 - struct thread_info *curctx;
21169 union irq_ctx *irqctx;
21170 u32 *isp;
21171
21172 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21173 local_irq_save(flags);
21174
21175 if (local_softirq_pending()) {
21176 - curctx = current_thread_info();
21177 irqctx = __this_cpu_read(softirq_ctx);
21178 - irqctx->tinfo.task = curctx->task;
21179 - irqctx->tinfo.previous_esp = current_stack_pointer;
21180 + irqctx->previous_esp = current_stack_pointer;
21181
21182 /* build the stack frame on the softirq stack */
21183 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21184 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21185 +
21186 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21187 + __set_fs(MAKE_MM_SEG(0));
21188 +#endif
21189
21190 call_on_stack(__do_softirq, isp);
21191 +
21192 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21193 + __set_fs(current_thread_info()->addr_limit);
21194 +#endif
21195 +
21196 /*
21197 * Shouldn't happen, we returned above if in_interrupt():
21198 */
21199 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21200 if (unlikely(!desc))
21201 return false;
21202
21203 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21204 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21205 if (unlikely(overflow))
21206 print_stack_overflow();
21207 desc->handle_irq(irq, desc);
21208 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21209 index d04d3ec..ea4b374 100644
21210 --- a/arch/x86/kernel/irq_64.c
21211 +++ b/arch/x86/kernel/irq_64.c
21212 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21213 u64 estack_top, estack_bottom;
21214 u64 curbase = (u64)task_stack_page(current);
21215
21216 - if (user_mode_vm(regs))
21217 + if (user_mode(regs))
21218 return;
21219
21220 if (regs->sp >= curbase + sizeof(struct thread_info) +
21221 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21222 index dc1404b..bbc43e7 100644
21223 --- a/arch/x86/kernel/kdebugfs.c
21224 +++ b/arch/x86/kernel/kdebugfs.c
21225 @@ -27,7 +27,7 @@ struct setup_data_node {
21226 u32 len;
21227 };
21228
21229 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21230 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21231 size_t count, loff_t *ppos)
21232 {
21233 struct setup_data_node *node = file->private_data;
21234 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21235 index 836f832..a8bda67 100644
21236 --- a/arch/x86/kernel/kgdb.c
21237 +++ b/arch/x86/kernel/kgdb.c
21238 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21239 #ifdef CONFIG_X86_32
21240 switch (regno) {
21241 case GDB_SS:
21242 - if (!user_mode_vm(regs))
21243 + if (!user_mode(regs))
21244 *(unsigned long *)mem = __KERNEL_DS;
21245 break;
21246 case GDB_SP:
21247 - if (!user_mode_vm(regs))
21248 + if (!user_mode(regs))
21249 *(unsigned long *)mem = kernel_stack_pointer(regs);
21250 break;
21251 case GDB_GS:
21252 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21253 bp->attr.bp_addr = breakinfo[breakno].addr;
21254 bp->attr.bp_len = breakinfo[breakno].len;
21255 bp->attr.bp_type = breakinfo[breakno].type;
21256 - info->address = breakinfo[breakno].addr;
21257 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21258 + info->address = ktla_ktva(breakinfo[breakno].addr);
21259 + else
21260 + info->address = breakinfo[breakno].addr;
21261 info->len = breakinfo[breakno].len;
21262 info->type = breakinfo[breakno].type;
21263 val = arch_install_hw_breakpoint(bp);
21264 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21265 case 'k':
21266 /* clear the trace bit */
21267 linux_regs->flags &= ~X86_EFLAGS_TF;
21268 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21269 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21270
21271 /* set the trace bit if we're stepping */
21272 if (remcomInBuffer[0] == 's') {
21273 linux_regs->flags |= X86_EFLAGS_TF;
21274 - atomic_set(&kgdb_cpu_doing_single_step,
21275 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21276 raw_smp_processor_id());
21277 }
21278
21279 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21280
21281 switch (cmd) {
21282 case DIE_DEBUG:
21283 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21284 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21285 if (user_mode(regs))
21286 return single_step_cont(regs, args);
21287 break;
21288 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21289 #endif /* CONFIG_DEBUG_RODATA */
21290
21291 bpt->type = BP_BREAKPOINT;
21292 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21293 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21294 BREAK_INSTR_SIZE);
21295 if (err)
21296 return err;
21297 - err = probe_kernel_write((char *)bpt->bpt_addr,
21298 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21299 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21300 #ifdef CONFIG_DEBUG_RODATA
21301 if (!err)
21302 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21303 return -EBUSY;
21304 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21305 BREAK_INSTR_SIZE);
21306 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21307 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21308 if (err)
21309 return err;
21310 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21311 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21312 if (mutex_is_locked(&text_mutex))
21313 goto knl_write;
21314 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21315 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21316 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21317 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21318 goto knl_write;
21319 return err;
21320 knl_write:
21321 #endif /* CONFIG_DEBUG_RODATA */
21322 - return probe_kernel_write((char *)bpt->bpt_addr,
21323 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21324 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21325 }
21326
21327 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21328 index 211bce4..6e2580a 100644
21329 --- a/arch/x86/kernel/kprobes/core.c
21330 +++ b/arch/x86/kernel/kprobes/core.c
21331 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21332 s32 raddr;
21333 } __packed *insn;
21334
21335 - insn = (struct __arch_relative_insn *)from;
21336 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21337 +
21338 + pax_open_kernel();
21339 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21340 insn->op = op;
21341 + pax_close_kernel();
21342 }
21343
21344 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21345 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21346 kprobe_opcode_t opcode;
21347 kprobe_opcode_t *orig_opcodes = opcodes;
21348
21349 - if (search_exception_tables((unsigned long)opcodes))
21350 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21351 return 0; /* Page fault may occur on this address. */
21352
21353 retry:
21354 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21355 * for the first byte, we can recover the original instruction
21356 * from it and kp->opcode.
21357 */
21358 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21359 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21360 buf[0] = kp->opcode;
21361 - return (unsigned long)buf;
21362 + return ktva_ktla((unsigned long)buf);
21363 }
21364
21365 /*
21366 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21367 /* Another subsystem puts a breakpoint, failed to recover */
21368 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21369 return 0;
21370 + pax_open_kernel();
21371 memcpy(dest, insn.kaddr, insn.length);
21372 + pax_close_kernel();
21373
21374 #ifdef CONFIG_X86_64
21375 if (insn_rip_relative(&insn)) {
21376 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21377 return 0;
21378 }
21379 disp = (u8 *) dest + insn_offset_displacement(&insn);
21380 + pax_open_kernel();
21381 *(s32 *) disp = (s32) newdisp;
21382 + pax_close_kernel();
21383 }
21384 #endif
21385 return insn.length;
21386 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21387 * nor set current_kprobe, because it doesn't use single
21388 * stepping.
21389 */
21390 - regs->ip = (unsigned long)p->ainsn.insn;
21391 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21392 preempt_enable_no_resched();
21393 return;
21394 }
21395 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21396 regs->flags &= ~X86_EFLAGS_IF;
21397 /* single step inline if the instruction is an int3 */
21398 if (p->opcode == BREAKPOINT_INSTRUCTION)
21399 - regs->ip = (unsigned long)p->addr;
21400 + regs->ip = ktla_ktva((unsigned long)p->addr);
21401 else
21402 - regs->ip = (unsigned long)p->ainsn.insn;
21403 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21404 }
21405
21406 /*
21407 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21408 setup_singlestep(p, regs, kcb, 0);
21409 return 1;
21410 }
21411 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21412 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21413 /*
21414 * The breakpoint instruction was removed right
21415 * after we hit it. Another cpu has removed
21416 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21417 " movq %rax, 152(%rsp)\n"
21418 RESTORE_REGS_STRING
21419 " popfq\n"
21420 +#ifdef KERNEXEC_PLUGIN
21421 + " btsq $63,(%rsp)\n"
21422 +#endif
21423 #else
21424 " pushf\n"
21425 SAVE_REGS_STRING
21426 @@ -779,7 +789,7 @@ static void __kprobes
21427 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21428 {
21429 unsigned long *tos = stack_addr(regs);
21430 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21431 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21432 unsigned long orig_ip = (unsigned long)p->addr;
21433 kprobe_opcode_t *insn = p->ainsn.insn;
21434
21435 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21436 struct die_args *args = data;
21437 int ret = NOTIFY_DONE;
21438
21439 - if (args->regs && user_mode_vm(args->regs))
21440 + if (args->regs && user_mode(args->regs))
21441 return ret;
21442
21443 switch (val) {
21444 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21445 index 76dc6f0..66bdfc3 100644
21446 --- a/arch/x86/kernel/kprobes/opt.c
21447 +++ b/arch/x86/kernel/kprobes/opt.c
21448 @@ -79,6 +79,7 @@ found:
21449 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21450 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21451 {
21452 + pax_open_kernel();
21453 #ifdef CONFIG_X86_64
21454 *addr++ = 0x48;
21455 *addr++ = 0xbf;
21456 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21457 *addr++ = 0xb8;
21458 #endif
21459 *(unsigned long *)addr = val;
21460 + pax_close_kernel();
21461 }
21462
21463 static void __used __kprobes kprobes_optinsn_template_holder(void)
21464 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21465 * Verify if the address gap is in 2GB range, because this uses
21466 * a relative jump.
21467 */
21468 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21469 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21470 if (abs(rel) > 0x7fffffff)
21471 return -ERANGE;
21472
21473 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21474 op->optinsn.size = ret;
21475
21476 /* Copy arch-dep-instance from template */
21477 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21478 + pax_open_kernel();
21479 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21480 + pax_close_kernel();
21481
21482 /* Set probe information */
21483 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21484
21485 /* Set probe function call */
21486 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21487 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21488
21489 /* Set returning jmp instruction at the tail of out-of-line buffer */
21490 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21491 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21492 (u8 *)op->kp.addr + op->optinsn.size);
21493
21494 flush_icache_range((unsigned long) buf,
21495 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21496 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21497
21498 /* Backup instructions which will be replaced by jump address */
21499 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21500 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21501 RELATIVE_ADDR_SIZE);
21502
21503 insn_buf[0] = RELATIVEJUMP_OPCODE;
21504 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21505 /* This kprobe is really able to run optimized path. */
21506 op = container_of(p, struct optimized_kprobe, kp);
21507 /* Detour through copied instructions */
21508 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21509 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21510 if (!reenter)
21511 reset_current_kprobe();
21512 preempt_enable_no_resched();
21513 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21514 index cd6d9a5..16245a4 100644
21515 --- a/arch/x86/kernel/kvm.c
21516 +++ b/arch/x86/kernel/kvm.c
21517 @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21518 return NOTIFY_OK;
21519 }
21520
21521 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21522 +static struct notifier_block kvm_cpu_notifier = {
21523 .notifier_call = kvm_cpu_notify,
21524 };
21525 #endif
21526 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21527 index ebc9873..1b9724b 100644
21528 --- a/arch/x86/kernel/ldt.c
21529 +++ b/arch/x86/kernel/ldt.c
21530 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21531 if (reload) {
21532 #ifdef CONFIG_SMP
21533 preempt_disable();
21534 - load_LDT(pc);
21535 + load_LDT_nolock(pc);
21536 if (!cpumask_equal(mm_cpumask(current->mm),
21537 cpumask_of(smp_processor_id())))
21538 smp_call_function(flush_ldt, current->mm, 1);
21539 preempt_enable();
21540 #else
21541 - load_LDT(pc);
21542 + load_LDT_nolock(pc);
21543 #endif
21544 }
21545 if (oldsize) {
21546 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21547 return err;
21548
21549 for (i = 0; i < old->size; i++)
21550 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21551 + write_ldt_entry(new->ldt, i, old->ldt + i);
21552 return 0;
21553 }
21554
21555 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21556 retval = copy_ldt(&mm->context, &old_mm->context);
21557 mutex_unlock(&old_mm->context.lock);
21558 }
21559 +
21560 + if (tsk == current) {
21561 + mm->context.vdso = 0;
21562 +
21563 +#ifdef CONFIG_X86_32
21564 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21565 + mm->context.user_cs_base = 0UL;
21566 + mm->context.user_cs_limit = ~0UL;
21567 +
21568 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21569 + cpus_clear(mm->context.cpu_user_cs_mask);
21570 +#endif
21571 +
21572 +#endif
21573 +#endif
21574 +
21575 + }
21576 +
21577 return retval;
21578 }
21579
21580 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21581 }
21582 }
21583
21584 +#ifdef CONFIG_PAX_SEGMEXEC
21585 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21586 + error = -EINVAL;
21587 + goto out_unlock;
21588 + }
21589 +#endif
21590 +
21591 fill_ldt(&ldt, &ldt_info);
21592 if (oldmode)
21593 ldt.avl = 0;
21594 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21595 index 5b19e4d..6476a76 100644
21596 --- a/arch/x86/kernel/machine_kexec_32.c
21597 +++ b/arch/x86/kernel/machine_kexec_32.c
21598 @@ -26,7 +26,7 @@
21599 #include <asm/cacheflush.h>
21600 #include <asm/debugreg.h>
21601
21602 -static void set_idt(void *newidt, __u16 limit)
21603 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21604 {
21605 struct desc_ptr curidt;
21606
21607 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21608 }
21609
21610
21611 -static void set_gdt(void *newgdt, __u16 limit)
21612 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21613 {
21614 struct desc_ptr curgdt;
21615
21616 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21617 }
21618
21619 control_page = page_address(image->control_code_page);
21620 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21621 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21622
21623 relocate_kernel_ptr = control_page;
21624 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21625 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21626 index 22db92b..d546bec 100644
21627 --- a/arch/x86/kernel/microcode_core.c
21628 +++ b/arch/x86/kernel/microcode_core.c
21629 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21630 return NOTIFY_OK;
21631 }
21632
21633 -static struct notifier_block __refdata mc_cpu_notifier = {
21634 +static struct notifier_block mc_cpu_notifier = {
21635 .notifier_call = mc_cpu_callback,
21636 };
21637
21638 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21639 index 5fb2ceb..3ae90bb 100644
21640 --- a/arch/x86/kernel/microcode_intel.c
21641 +++ b/arch/x86/kernel/microcode_intel.c
21642 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21643
21644 static int get_ucode_user(void *to, const void *from, size_t n)
21645 {
21646 - return copy_from_user(to, from, n);
21647 + return copy_from_user(to, (const void __force_user *)from, n);
21648 }
21649
21650 static enum ucode_state
21651 request_microcode_user(int cpu, const void __user *buf, size_t size)
21652 {
21653 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21654 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21655 }
21656
21657 static void microcode_fini_cpu(int cpu)
21658 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21659 index 216a4d7..228255a 100644
21660 --- a/arch/x86/kernel/module.c
21661 +++ b/arch/x86/kernel/module.c
21662 @@ -43,15 +43,60 @@ do { \
21663 } while (0)
21664 #endif
21665
21666 -void *module_alloc(unsigned long size)
21667 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21668 {
21669 - if (PAGE_ALIGN(size) > MODULES_LEN)
21670 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21671 return NULL;
21672 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21673 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21674 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21675 -1, __builtin_return_address(0));
21676 }
21677
21678 +void *module_alloc(unsigned long size)
21679 +{
21680 +
21681 +#ifdef CONFIG_PAX_KERNEXEC
21682 + return __module_alloc(size, PAGE_KERNEL);
21683 +#else
21684 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21685 +#endif
21686 +
21687 +}
21688 +
21689 +#ifdef CONFIG_PAX_KERNEXEC
21690 +#ifdef CONFIG_X86_32
21691 +void *module_alloc_exec(unsigned long size)
21692 +{
21693 + struct vm_struct *area;
21694 +
21695 + if (size == 0)
21696 + return NULL;
21697 +
21698 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21699 + return area ? area->addr : NULL;
21700 +}
21701 +EXPORT_SYMBOL(module_alloc_exec);
21702 +
21703 +void module_free_exec(struct module *mod, void *module_region)
21704 +{
21705 + vunmap(module_region);
21706 +}
21707 +EXPORT_SYMBOL(module_free_exec);
21708 +#else
21709 +void module_free_exec(struct module *mod, void *module_region)
21710 +{
21711 + module_free(mod, module_region);
21712 +}
21713 +EXPORT_SYMBOL(module_free_exec);
21714 +
21715 +void *module_alloc_exec(unsigned long size)
21716 +{
21717 + return __module_alloc(size, PAGE_KERNEL_RX);
21718 +}
21719 +EXPORT_SYMBOL(module_alloc_exec);
21720 +#endif
21721 +#endif
21722 +
21723 #ifdef CONFIG_X86_32
21724 int apply_relocate(Elf32_Shdr *sechdrs,
21725 const char *strtab,
21726 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21727 unsigned int i;
21728 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21729 Elf32_Sym *sym;
21730 - uint32_t *location;
21731 + uint32_t *plocation, location;
21732
21733 DEBUGP("Applying relocate section %u to %u\n",
21734 relsec, sechdrs[relsec].sh_info);
21735 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21736 /* This is where to make the change */
21737 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21738 - + rel[i].r_offset;
21739 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21740 + location = (uint32_t)plocation;
21741 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21742 + plocation = ktla_ktva((void *)plocation);
21743 /* This is the symbol it is referring to. Note that all
21744 undefined symbols have been resolved. */
21745 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21746 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21747 switch (ELF32_R_TYPE(rel[i].r_info)) {
21748 case R_386_32:
21749 /* We add the value into the location given */
21750 - *location += sym->st_value;
21751 + pax_open_kernel();
21752 + *plocation += sym->st_value;
21753 + pax_close_kernel();
21754 break;
21755 case R_386_PC32:
21756 /* Add the value, subtract its position */
21757 - *location += sym->st_value - (uint32_t)location;
21758 + pax_open_kernel();
21759 + *plocation += sym->st_value - location;
21760 + pax_close_kernel();
21761 break;
21762 default:
21763 pr_err("%s: Unknown relocation: %u\n",
21764 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21765 case R_X86_64_NONE:
21766 break;
21767 case R_X86_64_64:
21768 + pax_open_kernel();
21769 *(u64 *)loc = val;
21770 + pax_close_kernel();
21771 break;
21772 case R_X86_64_32:
21773 + pax_open_kernel();
21774 *(u32 *)loc = val;
21775 + pax_close_kernel();
21776 if (val != *(u32 *)loc)
21777 goto overflow;
21778 break;
21779 case R_X86_64_32S:
21780 + pax_open_kernel();
21781 *(s32 *)loc = val;
21782 + pax_close_kernel();
21783 if ((s64)val != *(s32 *)loc)
21784 goto overflow;
21785 break;
21786 case R_X86_64_PC32:
21787 val -= (u64)loc;
21788 + pax_open_kernel();
21789 *(u32 *)loc = val;
21790 + pax_close_kernel();
21791 +
21792 #if 0
21793 if ((s64)val != *(s32 *)loc)
21794 goto overflow;
21795 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21796 index ce13049..e2e9c3c 100644
21797 --- a/arch/x86/kernel/msr.c
21798 +++ b/arch/x86/kernel/msr.c
21799 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21800 return notifier_from_errno(err);
21801 }
21802
21803 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21804 +static struct notifier_block msr_class_cpu_notifier = {
21805 .notifier_call = msr_class_cpu_callback,
21806 };
21807
21808 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21809 index 6030805..2d33f21 100644
21810 --- a/arch/x86/kernel/nmi.c
21811 +++ b/arch/x86/kernel/nmi.c
21812 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21813 return handled;
21814 }
21815
21816 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21817 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21818 {
21819 struct nmi_desc *desc = nmi_to_desc(type);
21820 unsigned long flags;
21821 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21822 * event confuses some handlers (kdump uses this flag)
21823 */
21824 if (action->flags & NMI_FLAG_FIRST)
21825 - list_add_rcu(&action->list, &desc->head);
21826 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21827 else
21828 - list_add_tail_rcu(&action->list, &desc->head);
21829 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21830
21831 spin_unlock_irqrestore(&desc->lock, flags);
21832 return 0;
21833 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21834 if (!strcmp(n->name, name)) {
21835 WARN(in_nmi(),
21836 "Trying to free NMI (%s) from NMI context!\n", n->name);
21837 - list_del_rcu(&n->list);
21838 + pax_list_del_rcu((struct list_head *)&n->list);
21839 break;
21840 }
21841 }
21842 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21843 dotraplinkage notrace __kprobes void
21844 do_nmi(struct pt_regs *regs, long error_code)
21845 {
21846 +
21847 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21848 + if (!user_mode(regs)) {
21849 + unsigned long cs = regs->cs & 0xFFFF;
21850 + unsigned long ip = ktva_ktla(regs->ip);
21851 +
21852 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21853 + regs->ip = ip;
21854 + }
21855 +#endif
21856 +
21857 nmi_nesting_preprocess(regs);
21858
21859 nmi_enter();
21860 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21861 index 6d9582e..f746287 100644
21862 --- a/arch/x86/kernel/nmi_selftest.c
21863 +++ b/arch/x86/kernel/nmi_selftest.c
21864 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21865 {
21866 /* trap all the unknown NMIs we may generate */
21867 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21868 - __initdata);
21869 + __initconst);
21870 }
21871
21872 static void __init cleanup_nmi_testsuite(void)
21873 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21874 unsigned long timeout;
21875
21876 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21877 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21878 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21879 nmi_fail = FAILURE;
21880 return;
21881 }
21882 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21883 index 676b8c7..870ba04 100644
21884 --- a/arch/x86/kernel/paravirt-spinlocks.c
21885 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21886 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21887 arch_spin_lock(lock);
21888 }
21889
21890 -struct pv_lock_ops pv_lock_ops = {
21891 +struct pv_lock_ops pv_lock_ops __read_only = {
21892 #ifdef CONFIG_SMP
21893 .spin_is_locked = __ticket_spin_is_locked,
21894 .spin_is_contended = __ticket_spin_is_contended,
21895 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21896 index cd6de64..27c6af0 100644
21897 --- a/arch/x86/kernel/paravirt.c
21898 +++ b/arch/x86/kernel/paravirt.c
21899 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21900 {
21901 return x;
21902 }
21903 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21904 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21905 +#endif
21906
21907 void __init default_banner(void)
21908 {
21909 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21910 if (opfunc == NULL)
21911 /* If there's no function, patch it with a ud2a (BUG) */
21912 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21913 - else if (opfunc == _paravirt_nop)
21914 + else if (opfunc == (void *)_paravirt_nop)
21915 /* If the operation is a nop, then nop the callsite */
21916 ret = paravirt_patch_nop();
21917
21918 /* identity functions just return their single argument */
21919 - else if (opfunc == _paravirt_ident_32)
21920 + else if (opfunc == (void *)_paravirt_ident_32)
21921 ret = paravirt_patch_ident_32(insnbuf, len);
21922 - else if (opfunc == _paravirt_ident_64)
21923 + else if (opfunc == (void *)_paravirt_ident_64)
21924 ret = paravirt_patch_ident_64(insnbuf, len);
21925 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21926 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21927 + ret = paravirt_patch_ident_64(insnbuf, len);
21928 +#endif
21929
21930 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21931 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21932 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21933 if (insn_len > len || start == NULL)
21934 insn_len = len;
21935 else
21936 - memcpy(insnbuf, start, insn_len);
21937 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21938
21939 return insn_len;
21940 }
21941 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21942 return this_cpu_read(paravirt_lazy_mode);
21943 }
21944
21945 -struct pv_info pv_info = {
21946 +struct pv_info pv_info __read_only = {
21947 .name = "bare hardware",
21948 .paravirt_enabled = 0,
21949 .kernel_rpl = 0,
21950 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21951 #endif
21952 };
21953
21954 -struct pv_init_ops pv_init_ops = {
21955 +struct pv_init_ops pv_init_ops __read_only = {
21956 .patch = native_patch,
21957 };
21958
21959 -struct pv_time_ops pv_time_ops = {
21960 +struct pv_time_ops pv_time_ops __read_only = {
21961 .sched_clock = native_sched_clock,
21962 .steal_clock = native_steal_clock,
21963 };
21964
21965 -struct pv_irq_ops pv_irq_ops = {
21966 +struct pv_irq_ops pv_irq_ops __read_only = {
21967 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21968 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21969 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21970 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21971 #endif
21972 };
21973
21974 -struct pv_cpu_ops pv_cpu_ops = {
21975 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21976 .cpuid = native_cpuid,
21977 .get_debugreg = native_get_debugreg,
21978 .set_debugreg = native_set_debugreg,
21979 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21980 .end_context_switch = paravirt_nop,
21981 };
21982
21983 -struct pv_apic_ops pv_apic_ops = {
21984 +struct pv_apic_ops pv_apic_ops __read_only= {
21985 #ifdef CONFIG_X86_LOCAL_APIC
21986 .startup_ipi_hook = paravirt_nop,
21987 #endif
21988 };
21989
21990 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21991 +#ifdef CONFIG_X86_32
21992 +#ifdef CONFIG_X86_PAE
21993 +/* 64-bit pagetable entries */
21994 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21995 +#else
21996 /* 32-bit pagetable entries */
21997 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21998 +#endif
21999 #else
22000 /* 64-bit pagetable entries */
22001 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22002 #endif
22003
22004 -struct pv_mmu_ops pv_mmu_ops = {
22005 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22006
22007 .read_cr2 = native_read_cr2,
22008 .write_cr2 = native_write_cr2,
22009 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22010 .make_pud = PTE_IDENT,
22011
22012 .set_pgd = native_set_pgd,
22013 + .set_pgd_batched = native_set_pgd_batched,
22014 #endif
22015 #endif /* PAGETABLE_LEVELS >= 3 */
22016
22017 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22018 },
22019
22020 .set_fixmap = native_set_fixmap,
22021 +
22022 +#ifdef CONFIG_PAX_KERNEXEC
22023 + .pax_open_kernel = native_pax_open_kernel,
22024 + .pax_close_kernel = native_pax_close_kernel,
22025 +#endif
22026 +
22027 };
22028
22029 EXPORT_SYMBOL_GPL(pv_time_ops);
22030 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
22031 index 299d493..2ccb0ee 100644
22032 --- a/arch/x86/kernel/pci-calgary_64.c
22033 +++ b/arch/x86/kernel/pci-calgary_64.c
22034 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
22035 tce_space = be64_to_cpu(readq(target));
22036 tce_space = tce_space & TAR_SW_BITS;
22037
22038 - tce_space = tce_space & (~specified_table_size);
22039 + tce_space = tce_space & (~(unsigned long)specified_table_size);
22040 info->tce_space = (u64 *)__va(tce_space);
22041 }
22042 }
22043 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22044 index 35ccf75..7a15747 100644
22045 --- a/arch/x86/kernel/pci-iommu_table.c
22046 +++ b/arch/x86/kernel/pci-iommu_table.c
22047 @@ -2,7 +2,7 @@
22048 #include <asm/iommu_table.h>
22049 #include <linux/string.h>
22050 #include <linux/kallsyms.h>
22051 -
22052 +#include <linux/sched.h>
22053
22054 #define DEBUG 1
22055
22056 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22057 index 6c483ba..d10ce2f 100644
22058 --- a/arch/x86/kernel/pci-swiotlb.c
22059 +++ b/arch/x86/kernel/pci-swiotlb.c
22060 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22061 void *vaddr, dma_addr_t dma_addr,
22062 struct dma_attrs *attrs)
22063 {
22064 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22065 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22066 }
22067
22068 static struct dma_map_ops swiotlb_dma_ops = {
22069 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22070 index 81a5f5e..20f8b58 100644
22071 --- a/arch/x86/kernel/process.c
22072 +++ b/arch/x86/kernel/process.c
22073 @@ -36,7 +36,8 @@
22074 * section. Since TSS's are completely CPU-local, we want them
22075 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22076 */
22077 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22078 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22079 +EXPORT_SYMBOL(init_tss);
22080
22081 #ifdef CONFIG_X86_64
22082 static DEFINE_PER_CPU(unsigned char, is_idle);
22083 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22084 task_xstate_cachep =
22085 kmem_cache_create("task_xstate", xstate_size,
22086 __alignof__(union thread_xstate),
22087 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22088 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22089 }
22090
22091 /*
22092 @@ -105,7 +106,7 @@ void exit_thread(void)
22093 unsigned long *bp = t->io_bitmap_ptr;
22094
22095 if (bp) {
22096 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22097 + struct tss_struct *tss = init_tss + get_cpu();
22098
22099 t->io_bitmap_ptr = NULL;
22100 clear_thread_flag(TIF_IO_BITMAP);
22101 @@ -125,6 +126,9 @@ void flush_thread(void)
22102 {
22103 struct task_struct *tsk = current;
22104
22105 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22106 + loadsegment(gs, 0);
22107 +#endif
22108 flush_ptrace_hw_breakpoint(tsk);
22109 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22110 drop_init_fpu(tsk);
22111 @@ -271,7 +275,7 @@ static void __exit_idle(void)
22112 void exit_idle(void)
22113 {
22114 /* idle loop has pid 0 */
22115 - if (current->pid)
22116 + if (task_pid_nr(current))
22117 return;
22118 __exit_idle();
22119 }
22120 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
22121 return ret;
22122 }
22123 #endif
22124 -void stop_this_cpu(void *dummy)
22125 +__noreturn void stop_this_cpu(void *dummy)
22126 {
22127 local_irq_disable();
22128 /*
22129 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
22130 }
22131 early_param("idle", idle_setup);
22132
22133 -unsigned long arch_align_stack(unsigned long sp)
22134 +#ifdef CONFIG_PAX_RANDKSTACK
22135 +void pax_randomize_kstack(struct pt_regs *regs)
22136 {
22137 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22138 - sp -= get_random_int() % 8192;
22139 - return sp & ~0xf;
22140 -}
22141 + struct thread_struct *thread = &current->thread;
22142 + unsigned long time;
22143
22144 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22145 -{
22146 - unsigned long range_end = mm->brk + 0x02000000;
22147 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22148 -}
22149 + if (!randomize_va_space)
22150 + return;
22151 +
22152 + if (v8086_mode(regs))
22153 + return;
22154
22155 + rdtscl(time);
22156 +
22157 + /* P4 seems to return a 0 LSB, ignore it */
22158 +#ifdef CONFIG_MPENTIUM4
22159 + time &= 0x3EUL;
22160 + time <<= 2;
22161 +#elif defined(CONFIG_X86_64)
22162 + time &= 0xFUL;
22163 + time <<= 4;
22164 +#else
22165 + time &= 0x1FUL;
22166 + time <<= 3;
22167 +#endif
22168 +
22169 + thread->sp0 ^= time;
22170 + load_sp0(init_tss + smp_processor_id(), thread);
22171 +
22172 +#ifdef CONFIG_X86_64
22173 + this_cpu_write(kernel_stack, thread->sp0);
22174 +#endif
22175 +}
22176 +#endif
22177 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22178 index 7305f7d..22f73d6 100644
22179 --- a/arch/x86/kernel/process_32.c
22180 +++ b/arch/x86/kernel/process_32.c
22181 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22182 unsigned long thread_saved_pc(struct task_struct *tsk)
22183 {
22184 return ((unsigned long *)tsk->thread.sp)[3];
22185 +//XXX return tsk->thread.eip;
22186 }
22187
22188 void __show_regs(struct pt_regs *regs, int all)
22189 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
22190 unsigned long sp;
22191 unsigned short ss, gs;
22192
22193 - if (user_mode_vm(regs)) {
22194 + if (user_mode(regs)) {
22195 sp = regs->sp;
22196 ss = regs->ss & 0xffff;
22197 - gs = get_user_gs(regs);
22198 } else {
22199 sp = kernel_stack_pointer(regs);
22200 savesegment(ss, ss);
22201 - savesegment(gs, gs);
22202 }
22203 + gs = get_user_gs(regs);
22204
22205 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22206 (u16)regs->cs, regs->ip, regs->flags,
22207 - smp_processor_id());
22208 + raw_smp_processor_id());
22209 print_symbol("EIP is at %s\n", regs->ip);
22210
22211 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22212 @@ -128,20 +128,21 @@ void release_thread(struct task_struct *dead_task)
22213 int copy_thread(unsigned long clone_flags, unsigned long sp,
22214 unsigned long arg, struct task_struct *p)
22215 {
22216 - struct pt_regs *childregs = task_pt_regs(p);
22217 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22218 struct task_struct *tsk;
22219 int err;
22220
22221 p->thread.sp = (unsigned long) childregs;
22222 p->thread.sp0 = (unsigned long) (childregs+1);
22223 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22224
22225 if (unlikely(p->flags & PF_KTHREAD)) {
22226 /* kernel thread */
22227 memset(childregs, 0, sizeof(struct pt_regs));
22228 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22229 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22230 - childregs->ds = __USER_DS;
22231 - childregs->es = __USER_DS;
22232 + savesegment(gs, childregs->gs);
22233 + childregs->ds = __KERNEL_DS;
22234 + childregs->es = __KERNEL_DS;
22235 childregs->fs = __KERNEL_PERCPU;
22236 childregs->bx = sp; /* function */
22237 childregs->bp = arg;
22238 @@ -248,7 +249,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22239 struct thread_struct *prev = &prev_p->thread,
22240 *next = &next_p->thread;
22241 int cpu = smp_processor_id();
22242 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22243 + struct tss_struct *tss = init_tss + cpu;
22244 fpu_switch_t fpu;
22245
22246 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22247 @@ -272,6 +273,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22248 */
22249 lazy_save_gs(prev->gs);
22250
22251 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22252 + __set_fs(task_thread_info(next_p)->addr_limit);
22253 +#endif
22254 +
22255 /*
22256 * Load the per-thread Thread-Local Storage descriptor.
22257 */
22258 @@ -302,6 +307,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22259 */
22260 arch_end_context_switch(next_p);
22261
22262 + this_cpu_write(current_task, next_p);
22263 + this_cpu_write(current_tinfo, &next_p->tinfo);
22264 +
22265 /*
22266 * Restore %gs if needed (which is common)
22267 */
22268 @@ -310,8 +318,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22269
22270 switch_fpu_finish(next_p, fpu);
22271
22272 - this_cpu_write(current_task, next_p);
22273 -
22274 return prev_p;
22275 }
22276
22277 @@ -341,4 +347,3 @@ unsigned long get_wchan(struct task_struct *p)
22278 } while (count++ < 16);
22279 return 0;
22280 }
22281 -
22282 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22283 index 355ae06..4530766 100644
22284 --- a/arch/x86/kernel/process_64.c
22285 +++ b/arch/x86/kernel/process_64.c
22286 @@ -151,10 +151,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22287 struct pt_regs *childregs;
22288 struct task_struct *me = current;
22289
22290 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22291 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22292 childregs = task_pt_regs(p);
22293 p->thread.sp = (unsigned long) childregs;
22294 p->thread.usersp = me->thread.usersp;
22295 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22296 set_tsk_thread_flag(p, TIF_FORK);
22297 p->fpu_counter = 0;
22298 p->thread.io_bitmap_ptr = NULL;
22299 @@ -273,7 +274,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22300 struct thread_struct *prev = &prev_p->thread;
22301 struct thread_struct *next = &next_p->thread;
22302 int cpu = smp_processor_id();
22303 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22304 + struct tss_struct *tss = init_tss + cpu;
22305 unsigned fsindex, gsindex;
22306 fpu_switch_t fpu;
22307
22308 @@ -355,10 +356,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22309 prev->usersp = this_cpu_read(old_rsp);
22310 this_cpu_write(old_rsp, next->usersp);
22311 this_cpu_write(current_task, next_p);
22312 + this_cpu_write(current_tinfo, &next_p->tinfo);
22313
22314 - this_cpu_write(kernel_stack,
22315 - (unsigned long)task_stack_page(next_p) +
22316 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22317 + this_cpu_write(kernel_stack, next->sp0);
22318
22319 /*
22320 * Now maybe reload the debug registers and handle I/O bitmaps
22321 @@ -427,12 +427,11 @@ unsigned long get_wchan(struct task_struct *p)
22322 if (!p || p == current || p->state == TASK_RUNNING)
22323 return 0;
22324 stack = (unsigned long)task_stack_page(p);
22325 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22326 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22327 return 0;
22328 fp = *(u64 *)(p->thread.sp);
22329 do {
22330 - if (fp < (unsigned long)stack ||
22331 - fp >= (unsigned long)stack+THREAD_SIZE)
22332 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22333 return 0;
22334 ip = *(u64 *)(fp+8);
22335 if (!in_sched_functions(ip))
22336 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22337 index 29a8120..a50b5ee 100644
22338 --- a/arch/x86/kernel/ptrace.c
22339 +++ b/arch/x86/kernel/ptrace.c
22340 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22341 {
22342 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22343 unsigned long sp = (unsigned long)&regs->sp;
22344 - struct thread_info *tinfo;
22345
22346 - if (context == (sp & ~(THREAD_SIZE - 1)))
22347 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22348 return sp;
22349
22350 - tinfo = (struct thread_info *)context;
22351 - if (tinfo->previous_esp)
22352 - return tinfo->previous_esp;
22353 + sp = *(unsigned long *)context;
22354 + if (sp)
22355 + return sp;
22356
22357 return (unsigned long)regs;
22358 }
22359 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22360 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22361 {
22362 int i;
22363 - int dr7 = 0;
22364 + unsigned long dr7 = 0;
22365 struct arch_hw_breakpoint *info;
22366
22367 for (i = 0; i < HBP_NUM; i++) {
22368 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22369 unsigned long addr, unsigned long data)
22370 {
22371 int ret;
22372 - unsigned long __user *datap = (unsigned long __user *)data;
22373 + unsigned long __user *datap = (__force unsigned long __user *)data;
22374
22375 switch (request) {
22376 /* read the word at location addr in the USER area. */
22377 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22378 if ((int) addr < 0)
22379 return -EIO;
22380 ret = do_get_thread_area(child, addr,
22381 - (struct user_desc __user *)data);
22382 + (__force struct user_desc __user *) data);
22383 break;
22384
22385 case PTRACE_SET_THREAD_AREA:
22386 if ((int) addr < 0)
22387 return -EIO;
22388 ret = do_set_thread_area(child, addr,
22389 - (struct user_desc __user *)data, 0);
22390 + (__force struct user_desc __user *) data, 0);
22391 break;
22392 #endif
22393
22394 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22395
22396 #ifdef CONFIG_X86_64
22397
22398 -static struct user_regset x86_64_regsets[] __read_mostly = {
22399 +static user_regset_no_const x86_64_regsets[] __read_only = {
22400 [REGSET_GENERAL] = {
22401 .core_note_type = NT_PRSTATUS,
22402 .n = sizeof(struct user_regs_struct) / sizeof(long),
22403 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22404 #endif /* CONFIG_X86_64 */
22405
22406 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22407 -static struct user_regset x86_32_regsets[] __read_mostly = {
22408 +static user_regset_no_const x86_32_regsets[] __read_only = {
22409 [REGSET_GENERAL] = {
22410 .core_note_type = NT_PRSTATUS,
22411 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22412 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22413 */
22414 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22415
22416 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22417 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22418 {
22419 #ifdef CONFIG_X86_64
22420 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22421 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22422 memset(info, 0, sizeof(*info));
22423 info->si_signo = SIGTRAP;
22424 info->si_code = si_code;
22425 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22426 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22427 }
22428
22429 void user_single_step_siginfo(struct task_struct *tsk,
22430 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22431 # define IS_IA32 0
22432 #endif
22433
22434 +#ifdef CONFIG_GRKERNSEC_SETXID
22435 +extern void gr_delayed_cred_worker(void);
22436 +#endif
22437 +
22438 /*
22439 * We must return the syscall number to actually look up in the table.
22440 * This can be -1L to skip running any syscall at all.
22441 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22442
22443 user_exit();
22444
22445 +#ifdef CONFIG_GRKERNSEC_SETXID
22446 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22447 + gr_delayed_cred_worker();
22448 +#endif
22449 +
22450 /*
22451 * If we stepped into a sysenter/syscall insn, it trapped in
22452 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22453 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22454 */
22455 user_exit();
22456
22457 +#ifdef CONFIG_GRKERNSEC_SETXID
22458 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22459 + gr_delayed_cred_worker();
22460 +#endif
22461 +
22462 audit_syscall_exit(regs);
22463
22464 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22465 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22466 index 2cb9470..ff1fd80 100644
22467 --- a/arch/x86/kernel/pvclock.c
22468 +++ b/arch/x86/kernel/pvclock.c
22469 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22470 return pv_tsc_khz;
22471 }
22472
22473 -static atomic64_t last_value = ATOMIC64_INIT(0);
22474 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22475
22476 void pvclock_resume(void)
22477 {
22478 - atomic64_set(&last_value, 0);
22479 + atomic64_set_unchecked(&last_value, 0);
22480 }
22481
22482 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22483 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22484 * updating at the same time, and one of them could be slightly behind,
22485 * making the assumption that last_value always go forward fail to hold.
22486 */
22487 - last = atomic64_read(&last_value);
22488 + last = atomic64_read_unchecked(&last_value);
22489 do {
22490 if (ret < last)
22491 return last;
22492 - last = atomic64_cmpxchg(&last_value, last, ret);
22493 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22494 } while (unlikely(last != ret));
22495
22496 return ret;
22497 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22498 index 76fa1e9..abf09ea 100644
22499 --- a/arch/x86/kernel/reboot.c
22500 +++ b/arch/x86/kernel/reboot.c
22501 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22502 EXPORT_SYMBOL(pm_power_off);
22503
22504 static const struct desc_ptr no_idt = {};
22505 -static int reboot_mode;
22506 +static unsigned short reboot_mode;
22507 enum reboot_type reboot_type = BOOT_ACPI;
22508 int reboot_force;
22509
22510 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22511
22512 void __noreturn machine_real_restart(unsigned int type)
22513 {
22514 +
22515 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22516 + struct desc_struct *gdt;
22517 +#endif
22518 +
22519 local_irq_disable();
22520
22521 /*
22522 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22523
22524 /* Jump to the identity-mapped low memory code */
22525 #ifdef CONFIG_X86_32
22526 - asm volatile("jmpl *%0" : :
22527 +
22528 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22529 + gdt = get_cpu_gdt_table(smp_processor_id());
22530 + pax_open_kernel();
22531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22532 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22533 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22534 + loadsegment(ds, __KERNEL_DS);
22535 + loadsegment(es, __KERNEL_DS);
22536 + loadsegment(ss, __KERNEL_DS);
22537 +#endif
22538 +#ifdef CONFIG_PAX_KERNEXEC
22539 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22540 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22541 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22542 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22543 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22544 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22545 +#endif
22546 + pax_close_kernel();
22547 +#endif
22548 +
22549 + asm volatile("ljmpl *%0" : :
22550 "rm" (real_mode_header->machine_real_restart_asm),
22551 "a" (type));
22552 #else
22553 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22554 * try to force a triple fault and then cycle between hitting the keyboard
22555 * controller and doing that
22556 */
22557 -static void native_machine_emergency_restart(void)
22558 +static void __noreturn native_machine_emergency_restart(void)
22559 {
22560 int i;
22561 int attempt = 0;
22562 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22563 #endif
22564 }
22565
22566 -static void __machine_emergency_restart(int emergency)
22567 +static void __noreturn __machine_emergency_restart(int emergency)
22568 {
22569 reboot_emergency = emergency;
22570 machine_ops.emergency_restart();
22571 }
22572
22573 -static void native_machine_restart(char *__unused)
22574 +static void __noreturn native_machine_restart(char *__unused)
22575 {
22576 pr_notice("machine restart\n");
22577
22578 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22579 __machine_emergency_restart(0);
22580 }
22581
22582 -static void native_machine_halt(void)
22583 +static void __noreturn native_machine_halt(void)
22584 {
22585 /* Stop other cpus and apics */
22586 machine_shutdown();
22587 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22588 stop_this_cpu(NULL);
22589 }
22590
22591 -static void native_machine_power_off(void)
22592 +static void __noreturn native_machine_power_off(void)
22593 {
22594 if (pm_power_off) {
22595 if (!reboot_force)
22596 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22597 }
22598 /* A fallback in case there is no PM info available */
22599 tboot_shutdown(TB_SHUTDOWN_HALT);
22600 + unreachable();
22601 }
22602
22603 -struct machine_ops machine_ops = {
22604 +struct machine_ops machine_ops __read_only = {
22605 .power_off = native_machine_power_off,
22606 .shutdown = native_machine_shutdown,
22607 .emergency_restart = native_machine_emergency_restart,
22608 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
22609 index c8e41e9..64049ef 100644
22610 --- a/arch/x86/kernel/reboot_fixups_32.c
22611 +++ b/arch/x86/kernel/reboot_fixups_32.c
22612 @@ -57,7 +57,7 @@ struct device_fixup {
22613 unsigned int vendor;
22614 unsigned int device;
22615 void (*reboot_fixup)(struct pci_dev *);
22616 -};
22617 +} __do_const;
22618
22619 /*
22620 * PCI ids solely used for fixups_table go here
22621 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22622 index f2bb9c9..bed145d7 100644
22623 --- a/arch/x86/kernel/relocate_kernel_64.S
22624 +++ b/arch/x86/kernel/relocate_kernel_64.S
22625 @@ -11,6 +11,7 @@
22626 #include <asm/kexec.h>
22627 #include <asm/processor-flags.h>
22628 #include <asm/pgtable_types.h>
22629 +#include <asm/alternative-asm.h>
22630
22631 /*
22632 * Must be relocatable PIC code callable as a C function
22633 @@ -167,6 +168,7 @@ identity_mapped:
22634 xorq %r14, %r14
22635 xorq %r15, %r15
22636
22637 + pax_force_retaddr 0, 1
22638 ret
22639
22640 1:
22641 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22642 index 56f7fcf..fa229f4 100644
22643 --- a/arch/x86/kernel/setup.c
22644 +++ b/arch/x86/kernel/setup.c
22645 @@ -110,6 +110,7 @@
22646 #include <asm/mce.h>
22647 #include <asm/alternative.h>
22648 #include <asm/prom.h>
22649 +#include <asm/boot.h>
22650
22651 /*
22652 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22653 @@ -444,7 +445,7 @@ static void __init parse_setup_data(void)
22654
22655 switch (data->type) {
22656 case SETUP_E820_EXT:
22657 - parse_e820_ext(data);
22658 + parse_e820_ext((struct setup_data __force_kernel *)data);
22659 break;
22660 case SETUP_DTB:
22661 add_dtb(pa_data);
22662 @@ -771,7 +772,7 @@ static void __init trim_bios_range(void)
22663 * area (640->1Mb) as ram even though it is not.
22664 * take them out.
22665 */
22666 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22667 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22668
22669 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22670 }
22671 @@ -779,7 +780,7 @@ static void __init trim_bios_range(void)
22672 /* called before trim_bios_range() to spare extra sanitize */
22673 static void __init e820_add_kernel_range(void)
22674 {
22675 - u64 start = __pa_symbol(_text);
22676 + u64 start = __pa_symbol(ktla_ktva(_text));
22677 u64 size = __pa_symbol(_end) - start;
22678
22679 /*
22680 @@ -841,8 +842,12 @@ static void __init trim_low_memory_range(void)
22681
22682 void __init setup_arch(char **cmdline_p)
22683 {
22684 +#ifdef CONFIG_X86_32
22685 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
22686 +#else
22687 memblock_reserve(__pa_symbol(_text),
22688 (unsigned long)__bss_stop - (unsigned long)_text);
22689 +#endif
22690
22691 early_reserve_initrd();
22692
22693 @@ -934,14 +939,14 @@ void __init setup_arch(char **cmdline_p)
22694
22695 if (!boot_params.hdr.root_flags)
22696 root_mountflags &= ~MS_RDONLY;
22697 - init_mm.start_code = (unsigned long) _text;
22698 - init_mm.end_code = (unsigned long) _etext;
22699 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22700 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22701 init_mm.end_data = (unsigned long) _edata;
22702 init_mm.brk = _brk_end;
22703
22704 - code_resource.start = __pa_symbol(_text);
22705 - code_resource.end = __pa_symbol(_etext)-1;
22706 - data_resource.start = __pa_symbol(_etext);
22707 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22708 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22709 + data_resource.start = __pa_symbol(_sdata);
22710 data_resource.end = __pa_symbol(_edata)-1;
22711 bss_resource.start = __pa_symbol(__bss_start);
22712 bss_resource.end = __pa_symbol(__bss_stop)-1;
22713 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22714 index 5cdff03..80fa283 100644
22715 --- a/arch/x86/kernel/setup_percpu.c
22716 +++ b/arch/x86/kernel/setup_percpu.c
22717 @@ -21,19 +21,17 @@
22718 #include <asm/cpu.h>
22719 #include <asm/stackprotector.h>
22720
22721 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22722 +#ifdef CONFIG_SMP
22723 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22724 EXPORT_PER_CPU_SYMBOL(cpu_number);
22725 +#endif
22726
22727 -#ifdef CONFIG_X86_64
22728 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22729 -#else
22730 -#define BOOT_PERCPU_OFFSET 0
22731 -#endif
22732
22733 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22734 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22735
22736 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22737 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22738 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22739 };
22740 EXPORT_SYMBOL(__per_cpu_offset);
22741 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22742 {
22743 #ifdef CONFIG_NEED_MULTIPLE_NODES
22744 pg_data_t *last = NULL;
22745 - unsigned int cpu;
22746 + int cpu;
22747
22748 for_each_possible_cpu(cpu) {
22749 int node = early_cpu_to_node(cpu);
22750 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22751 {
22752 #ifdef CONFIG_X86_32
22753 struct desc_struct gdt;
22754 + unsigned long base = per_cpu_offset(cpu);
22755
22756 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22757 - 0x2 | DESCTYPE_S, 0x8);
22758 - gdt.s = 1;
22759 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22760 + 0x83 | DESCTYPE_S, 0xC);
22761 write_gdt_entry(get_cpu_gdt_table(cpu),
22762 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22763 #endif
22764 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22765 /* alrighty, percpu areas up and running */
22766 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22767 for_each_possible_cpu(cpu) {
22768 +#ifdef CONFIG_CC_STACKPROTECTOR
22769 +#ifdef CONFIG_X86_32
22770 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22771 +#endif
22772 +#endif
22773 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22774 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22775 per_cpu(cpu_number, cpu) = cpu;
22776 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22777 */
22778 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22779 #endif
22780 +#ifdef CONFIG_CC_STACKPROTECTOR
22781 +#ifdef CONFIG_X86_32
22782 + if (!cpu)
22783 + per_cpu(stack_canary.canary, cpu) = canary;
22784 +#endif
22785 +#endif
22786 /*
22787 * Up to this point, the boot CPU has been using .init.data
22788 * area. Reload any changed state for the boot CPU.
22789 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22790 index 6956299..f20beae 100644
22791 --- a/arch/x86/kernel/signal.c
22792 +++ b/arch/x86/kernel/signal.c
22793 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22794 * Align the stack pointer according to the i386 ABI,
22795 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22796 */
22797 - sp = ((sp + 4) & -16ul) - 4;
22798 + sp = ((sp - 12) & -16ul) - 4;
22799 #else /* !CONFIG_X86_32 */
22800 sp = round_down(sp, 16) - 8;
22801 #endif
22802 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22803 }
22804
22805 if (current->mm->context.vdso)
22806 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22807 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22808 else
22809 - restorer = &frame->retcode;
22810 + restorer = (void __user *)&frame->retcode;
22811 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22812 restorer = ksig->ka.sa.sa_restorer;
22813
22814 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22815 * reasons and because gdb uses it as a signature to notice
22816 * signal handler stack frames.
22817 */
22818 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22819 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22820
22821 if (err)
22822 return -EFAULT;
22823 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22824 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22825
22826 /* Set up to return from userspace. */
22827 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22828 + if (current->mm->context.vdso)
22829 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22830 + else
22831 + restorer = (void __user *)&frame->retcode;
22832 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22833 restorer = ksig->ka.sa.sa_restorer;
22834 put_user_ex(restorer, &frame->pretcode);
22835 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22836 * reasons and because gdb uses it as a signature to notice
22837 * signal handler stack frames.
22838 */
22839 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22840 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22841 } put_user_catch(err);
22842
22843 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22844 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22845 {
22846 int usig = signr_convert(ksig->sig);
22847 sigset_t *set = sigmask_to_save();
22848 - compat_sigset_t *cset = (compat_sigset_t *) set;
22849 + sigset_t sigcopy;
22850 + compat_sigset_t *cset;
22851 +
22852 + sigcopy = *set;
22853 +
22854 + cset = (compat_sigset_t *) &sigcopy;
22855
22856 /* Set up the stack frame */
22857 if (is_ia32_frame()) {
22858 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22859 } else if (is_x32_frame()) {
22860 return x32_setup_rt_frame(ksig, cset, regs);
22861 } else {
22862 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22863 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22864 }
22865 }
22866
22867 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22868 index 48d2b7d..90d328a 100644
22869 --- a/arch/x86/kernel/smp.c
22870 +++ b/arch/x86/kernel/smp.c
22871 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22872
22873 __setup("nonmi_ipi", nonmi_ipi_setup);
22874
22875 -struct smp_ops smp_ops = {
22876 +struct smp_ops smp_ops __read_only = {
22877 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22878 .smp_prepare_cpus = native_smp_prepare_cpus,
22879 .smp_cpus_done = native_smp_cpus_done,
22880 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22881 index bfd348e..4816ad8 100644
22882 --- a/arch/x86/kernel/smpboot.c
22883 +++ b/arch/x86/kernel/smpboot.c
22884 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22885 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22886 (THREAD_SIZE + task_stack_page(idle))) - 1);
22887 per_cpu(current_task, cpu) = idle;
22888 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22889
22890 #ifdef CONFIG_X86_32
22891 /* Stack for startup_32 can be just as for start_secondary onwards */
22892 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22893 #else
22894 clear_tsk_thread_flag(idle, TIF_FORK);
22895 initial_gs = per_cpu_offset(cpu);
22896 - per_cpu(kernel_stack, cpu) =
22897 - (unsigned long)task_stack_page(idle) -
22898 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22899 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22900 #endif
22901 +
22902 + pax_open_kernel();
22903 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22904 + pax_close_kernel();
22905 +
22906 initial_code = (unsigned long)start_secondary;
22907 stack_start = idle->thread.sp;
22908
22909 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22910 /* the FPU context is blank, nobody can own it */
22911 __cpu_disable_lazy_restore(cpu);
22912
22913 +#ifdef CONFIG_PAX_PER_CPU_PGD
22914 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22915 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22916 + KERNEL_PGD_PTRS);
22917 +#endif
22918 +
22919 + /* the FPU context is blank, nobody can own it */
22920 + __cpu_disable_lazy_restore(cpu);
22921 +
22922 err = do_boot_cpu(apicid, cpu, tidle);
22923 if (err) {
22924 pr_debug("do_boot_cpu failed %d\n", err);
22925 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22926 index 9b4d51d..5d28b58 100644
22927 --- a/arch/x86/kernel/step.c
22928 +++ b/arch/x86/kernel/step.c
22929 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22930 struct desc_struct *desc;
22931 unsigned long base;
22932
22933 - seg &= ~7UL;
22934 + seg >>= 3;
22935
22936 mutex_lock(&child->mm->context.lock);
22937 - if (unlikely((seg >> 3) >= child->mm->context.size))
22938 + if (unlikely(seg >= child->mm->context.size))
22939 addr = -1L; /* bogus selector, access would fault */
22940 else {
22941 desc = child->mm->context.ldt + seg;
22942 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22943 addr += base;
22944 }
22945 mutex_unlock(&child->mm->context.lock);
22946 - }
22947 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22948 + addr = ktla_ktva(addr);
22949
22950 return addr;
22951 }
22952 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22953 unsigned char opcode[15];
22954 unsigned long addr = convert_ip_to_linear(child, regs);
22955
22956 + if (addr == -EINVAL)
22957 + return 0;
22958 +
22959 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22960 for (i = 0; i < copied; i++) {
22961 switch (opcode[i]) {
22962 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22963 new file mode 100644
22964 index 0000000..5877189
22965 --- /dev/null
22966 +++ b/arch/x86/kernel/sys_i386_32.c
22967 @@ -0,0 +1,189 @@
22968 +/*
22969 + * This file contains various random system calls that
22970 + * have a non-standard calling sequence on the Linux/i386
22971 + * platform.
22972 + */
22973 +
22974 +#include <linux/errno.h>
22975 +#include <linux/sched.h>
22976 +#include <linux/mm.h>
22977 +#include <linux/fs.h>
22978 +#include <linux/smp.h>
22979 +#include <linux/sem.h>
22980 +#include <linux/msg.h>
22981 +#include <linux/shm.h>
22982 +#include <linux/stat.h>
22983 +#include <linux/syscalls.h>
22984 +#include <linux/mman.h>
22985 +#include <linux/file.h>
22986 +#include <linux/utsname.h>
22987 +#include <linux/ipc.h>
22988 +#include <linux/elf.h>
22989 +
22990 +#include <linux/uaccess.h>
22991 +#include <linux/unistd.h>
22992 +
22993 +#include <asm/syscalls.h>
22994 +
22995 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22996 +{
22997 + unsigned long pax_task_size = TASK_SIZE;
22998 +
22999 +#ifdef CONFIG_PAX_SEGMEXEC
23000 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23001 + pax_task_size = SEGMEXEC_TASK_SIZE;
23002 +#endif
23003 +
23004 + if (flags & MAP_FIXED)
23005 + if (len > pax_task_size || addr > pax_task_size - len)
23006 + return -EINVAL;
23007 +
23008 + return 0;
23009 +}
23010 +
23011 +/*
23012 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
23013 + */
23014 +static unsigned long get_align_mask(void)
23015 +{
23016 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
23017 + return 0;
23018 +
23019 + if (!(current->flags & PF_RANDOMIZE))
23020 + return 0;
23021 +
23022 + return va_align.mask;
23023 +}
23024 +
23025 +unsigned long
23026 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23027 + unsigned long len, unsigned long pgoff, unsigned long flags)
23028 +{
23029 + struct mm_struct *mm = current->mm;
23030 + struct vm_area_struct *vma;
23031 + unsigned long pax_task_size = TASK_SIZE;
23032 + struct vm_unmapped_area_info info;
23033 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23034 +
23035 +#ifdef CONFIG_PAX_SEGMEXEC
23036 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23037 + pax_task_size = SEGMEXEC_TASK_SIZE;
23038 +#endif
23039 +
23040 + pax_task_size -= PAGE_SIZE;
23041 +
23042 + if (len > pax_task_size)
23043 + return -ENOMEM;
23044 +
23045 + if (flags & MAP_FIXED)
23046 + return addr;
23047 +
23048 +#ifdef CONFIG_PAX_RANDMMAP
23049 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23050 +#endif
23051 +
23052 + if (addr) {
23053 + addr = PAGE_ALIGN(addr);
23054 + if (pax_task_size - len >= addr) {
23055 + vma = find_vma(mm, addr);
23056 + if (check_heap_stack_gap(vma, addr, len, offset))
23057 + return addr;
23058 + }
23059 + }
23060 +
23061 + info.flags = 0;
23062 + info.length = len;
23063 + info.align_mask = filp ? get_align_mask() : 0;
23064 + info.align_offset = pgoff << PAGE_SHIFT;
23065 + info.threadstack_offset = offset;
23066 +
23067 +#ifdef CONFIG_PAX_PAGEEXEC
23068 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
23069 + info.low_limit = 0x00110000UL;
23070 + info.high_limit = mm->start_code;
23071 +
23072 +#ifdef CONFIG_PAX_RANDMMAP
23073 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23074 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
23075 +#endif
23076 +
23077 + if (info.low_limit < info.high_limit) {
23078 + addr = vm_unmapped_area(&info);
23079 + if (!IS_ERR_VALUE(addr))
23080 + return addr;
23081 + }
23082 + } else
23083 +#endif
23084 +
23085 + info.low_limit = mm->mmap_base;
23086 + info.high_limit = pax_task_size;
23087 +
23088 + return vm_unmapped_area(&info);
23089 +}
23090 +
23091 +unsigned long
23092 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23093 + const unsigned long len, const unsigned long pgoff,
23094 + const unsigned long flags)
23095 +{
23096 + struct vm_area_struct *vma;
23097 + struct mm_struct *mm = current->mm;
23098 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
23099 + struct vm_unmapped_area_info info;
23100 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23101 +
23102 +#ifdef CONFIG_PAX_SEGMEXEC
23103 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23104 + pax_task_size = SEGMEXEC_TASK_SIZE;
23105 +#endif
23106 +
23107 + pax_task_size -= PAGE_SIZE;
23108 +
23109 + /* requested length too big for entire address space */
23110 + if (len > pax_task_size)
23111 + return -ENOMEM;
23112 +
23113 + if (flags & MAP_FIXED)
23114 + return addr;
23115 +
23116 +#ifdef CONFIG_PAX_PAGEEXEC
23117 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23118 + goto bottomup;
23119 +#endif
23120 +
23121 +#ifdef CONFIG_PAX_RANDMMAP
23122 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23123 +#endif
23124 +
23125 + /* requesting a specific address */
23126 + if (addr) {
23127 + addr = PAGE_ALIGN(addr);
23128 + if (pax_task_size - len >= addr) {
23129 + vma = find_vma(mm, addr);
23130 + if (check_heap_stack_gap(vma, addr, len, offset))
23131 + return addr;
23132 + }
23133 + }
23134 +
23135 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
23136 + info.length = len;
23137 + info.low_limit = PAGE_SIZE;
23138 + info.high_limit = mm->mmap_base;
23139 + info.align_mask = filp ? get_align_mask() : 0;
23140 + info.align_offset = pgoff << PAGE_SHIFT;
23141 + info.threadstack_offset = offset;
23142 +
23143 + addr = vm_unmapped_area(&info);
23144 + if (!(addr & ~PAGE_MASK))
23145 + return addr;
23146 + VM_BUG_ON(addr != -ENOMEM);
23147 +
23148 +bottomup:
23149 + /*
23150 + * A failed mmap() very likely causes application failure,
23151 + * so fall back to the bottom-up function here. This scenario
23152 + * can happen with large stack limits and large mmap()
23153 + * allocations.
23154 + */
23155 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23156 +}
23157 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23158 index dbded5a..ace2781 100644
23159 --- a/arch/x86/kernel/sys_x86_64.c
23160 +++ b/arch/x86/kernel/sys_x86_64.c
23161 @@ -81,8 +81,8 @@ out:
23162 return error;
23163 }
23164
23165 -static void find_start_end(unsigned long flags, unsigned long *begin,
23166 - unsigned long *end)
23167 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23168 + unsigned long *begin, unsigned long *end)
23169 {
23170 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23171 unsigned long new_begin;
23172 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23173 *begin = new_begin;
23174 }
23175 } else {
23176 - *begin = TASK_UNMAPPED_BASE;
23177 + *begin = mm->mmap_base;
23178 *end = TASK_SIZE;
23179 }
23180 }
23181 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23182 struct vm_area_struct *vma;
23183 struct vm_unmapped_area_info info;
23184 unsigned long begin, end;
23185 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23186
23187 if (flags & MAP_FIXED)
23188 return addr;
23189
23190 - find_start_end(flags, &begin, &end);
23191 + find_start_end(mm, flags, &begin, &end);
23192
23193 if (len > end)
23194 return -ENOMEM;
23195
23196 +#ifdef CONFIG_PAX_RANDMMAP
23197 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23198 +#endif
23199 +
23200 if (addr) {
23201 addr = PAGE_ALIGN(addr);
23202 vma = find_vma(mm, addr);
23203 - if (end - len >= addr &&
23204 - (!vma || addr + len <= vma->vm_start))
23205 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23206 return addr;
23207 }
23208
23209 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23210 info.high_limit = end;
23211 info.align_mask = filp ? get_align_mask() : 0;
23212 info.align_offset = pgoff << PAGE_SHIFT;
23213 + info.threadstack_offset = offset;
23214 return vm_unmapped_area(&info);
23215 }
23216
23217 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23218 struct mm_struct *mm = current->mm;
23219 unsigned long addr = addr0;
23220 struct vm_unmapped_area_info info;
23221 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23222
23223 /* requested length too big for entire address space */
23224 if (len > TASK_SIZE)
23225 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23226 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23227 goto bottomup;
23228
23229 +#ifdef CONFIG_PAX_RANDMMAP
23230 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23231 +#endif
23232 +
23233 /* requesting a specific address */
23234 if (addr) {
23235 addr = PAGE_ALIGN(addr);
23236 vma = find_vma(mm, addr);
23237 - if (TASK_SIZE - len >= addr &&
23238 - (!vma || addr + len <= vma->vm_start))
23239 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23240 return addr;
23241 }
23242
23243 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23244 info.high_limit = mm->mmap_base;
23245 info.align_mask = filp ? get_align_mask() : 0;
23246 info.align_offset = pgoff << PAGE_SHIFT;
23247 + info.threadstack_offset = offset;
23248 addr = vm_unmapped_area(&info);
23249 if (!(addr & ~PAGE_MASK))
23250 return addr;
23251 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23252 index f84fe00..f41d9f1 100644
23253 --- a/arch/x86/kernel/tboot.c
23254 +++ b/arch/x86/kernel/tboot.c
23255 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23256
23257 void tboot_shutdown(u32 shutdown_type)
23258 {
23259 - void (*shutdown)(void);
23260 + void (* __noreturn shutdown)(void);
23261
23262 if (!tboot_enabled())
23263 return;
23264 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23265
23266 switch_to_tboot_pt();
23267
23268 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23269 + shutdown = (void *)tboot->shutdown_entry;
23270 shutdown();
23271
23272 /* should not reach here */
23273 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23274 return 0;
23275 }
23276
23277 -static atomic_t ap_wfs_count;
23278 +static atomic_unchecked_t ap_wfs_count;
23279
23280 static int tboot_wait_for_aps(int num_aps)
23281 {
23282 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23283 {
23284 switch (action) {
23285 case CPU_DYING:
23286 - atomic_inc(&ap_wfs_count);
23287 + atomic_inc_unchecked(&ap_wfs_count);
23288 if (num_online_cpus() == 1)
23289 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23290 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23291 return NOTIFY_BAD;
23292 break;
23293 }
23294 return NOTIFY_OK;
23295 }
23296
23297 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23298 +static struct notifier_block tboot_cpu_notifier =
23299 {
23300 .notifier_call = tboot_cpu_callback,
23301 };
23302 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23303
23304 tboot_create_trampoline();
23305
23306 - atomic_set(&ap_wfs_count, 0);
23307 + atomic_set_unchecked(&ap_wfs_count, 0);
23308 register_hotcpu_notifier(&tboot_cpu_notifier);
23309
23310 acpi_os_set_prepare_sleep(&tboot_sleep);
23311 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23312 index 24d3c91..d06b473 100644
23313 --- a/arch/x86/kernel/time.c
23314 +++ b/arch/x86/kernel/time.c
23315 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23316 {
23317 unsigned long pc = instruction_pointer(regs);
23318
23319 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23320 + if (!user_mode(regs) && in_lock_functions(pc)) {
23321 #ifdef CONFIG_FRAME_POINTER
23322 - return *(unsigned long *)(regs->bp + sizeof(long));
23323 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23324 #else
23325 unsigned long *sp =
23326 (unsigned long *)kernel_stack_pointer(regs);
23327 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23328 * or above a saved flags. Eflags has bits 22-31 zero,
23329 * kernel addresses don't.
23330 */
23331 +
23332 +#ifdef CONFIG_PAX_KERNEXEC
23333 + return ktla_ktva(sp[0]);
23334 +#else
23335 if (sp[0] >> 22)
23336 return sp[0];
23337 if (sp[1] >> 22)
23338 return sp[1];
23339 #endif
23340 +
23341 +#endif
23342 }
23343 return pc;
23344 }
23345 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23346 index f7fec09..9991981 100644
23347 --- a/arch/x86/kernel/tls.c
23348 +++ b/arch/x86/kernel/tls.c
23349 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23350 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23351 return -EINVAL;
23352
23353 +#ifdef CONFIG_PAX_SEGMEXEC
23354 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23355 + return -EINVAL;
23356 +#endif
23357 +
23358 set_tls_desc(p, idx, &info, 1);
23359
23360 return 0;
23361 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23362
23363 if (kbuf)
23364 info = kbuf;
23365 - else if (__copy_from_user(infobuf, ubuf, count))
23366 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23367 return -EFAULT;
23368 else
23369 info = infobuf;
23370 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23371 index 772e2a8..bad5bf6 100644
23372 --- a/arch/x86/kernel/traps.c
23373 +++ b/arch/x86/kernel/traps.c
23374 @@ -68,12 +68,6 @@
23375 #include <asm/setup.h>
23376
23377 asmlinkage int system_call(void);
23378 -
23379 -/*
23380 - * The IDT has to be page-aligned to simplify the Pentium
23381 - * F0 0F bug workaround.
23382 - */
23383 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23384 #endif
23385
23386 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23387 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23388 }
23389
23390 static int __kprobes
23391 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23392 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23393 struct pt_regs *regs, long error_code)
23394 {
23395 #ifdef CONFIG_X86_32
23396 - if (regs->flags & X86_VM_MASK) {
23397 + if (v8086_mode(regs)) {
23398 /*
23399 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23400 * On nmi (interrupt 2), do_trap should not be called.
23401 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23402 return -1;
23403 }
23404 #endif
23405 - if (!user_mode(regs)) {
23406 + if (!user_mode_novm(regs)) {
23407 if (!fixup_exception(regs)) {
23408 tsk->thread.error_code = error_code;
23409 tsk->thread.trap_nr = trapnr;
23410 +
23411 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23412 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23413 + str = "PAX: suspicious stack segment fault";
23414 +#endif
23415 +
23416 die(str, regs, error_code);
23417 }
23418 +
23419 +#ifdef CONFIG_PAX_REFCOUNT
23420 + if (trapnr == 4)
23421 + pax_report_refcount_overflow(regs);
23422 +#endif
23423 +
23424 return 0;
23425 }
23426
23427 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23428 }
23429
23430 static void __kprobes
23431 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23432 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23433 long error_code, siginfo_t *info)
23434 {
23435 struct task_struct *tsk = current;
23436 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23437 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23438 printk_ratelimit()) {
23439 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23440 - tsk->comm, tsk->pid, str,
23441 + tsk->comm, task_pid_nr(tsk), str,
23442 regs->ip, regs->sp, error_code);
23443 print_vma_addr(" in ", regs->ip);
23444 pr_cont("\n");
23445 @@ -273,7 +279,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23446 conditional_sti(regs);
23447
23448 #ifdef CONFIG_X86_32
23449 - if (regs->flags & X86_VM_MASK) {
23450 + if (v8086_mode(regs)) {
23451 local_irq_enable();
23452 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23453 goto exit;
23454 @@ -281,18 +287,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23455 #endif
23456
23457 tsk = current;
23458 - if (!user_mode(regs)) {
23459 + if (!user_mode_novm(regs)) {
23460 if (fixup_exception(regs))
23461 goto exit;
23462
23463 tsk->thread.error_code = error_code;
23464 tsk->thread.trap_nr = X86_TRAP_GP;
23465 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23466 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23467 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23468 +
23469 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23470 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23471 + die("PAX: suspicious general protection fault", regs, error_code);
23472 + else
23473 +#endif
23474 +
23475 die("general protection fault", regs, error_code);
23476 + }
23477 goto exit;
23478 }
23479
23480 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23481 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23482 + struct mm_struct *mm = tsk->mm;
23483 + unsigned long limit;
23484 +
23485 + down_write(&mm->mmap_sem);
23486 + limit = mm->context.user_cs_limit;
23487 + if (limit < TASK_SIZE) {
23488 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23489 + up_write(&mm->mmap_sem);
23490 + return;
23491 + }
23492 + up_write(&mm->mmap_sem);
23493 + }
23494 +#endif
23495 +
23496 tsk->thread.error_code = error_code;
23497 tsk->thread.trap_nr = X86_TRAP_GP;
23498
23499 @@ -450,7 +480,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23500 /* It's safe to allow irq's after DR6 has been saved */
23501 preempt_conditional_sti(regs);
23502
23503 - if (regs->flags & X86_VM_MASK) {
23504 + if (v8086_mode(regs)) {
23505 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23506 X86_TRAP_DB);
23507 preempt_conditional_cli(regs);
23508 @@ -465,7 +495,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23509 * We already checked v86 mode above, so we can check for kernel mode
23510 * by just checking the CPL of CS.
23511 */
23512 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23513 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23514 tsk->thread.debugreg6 &= ~DR_STEP;
23515 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23516 regs->flags &= ~X86_EFLAGS_TF;
23517 @@ -497,7 +527,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23518 return;
23519 conditional_sti(regs);
23520
23521 - if (!user_mode_vm(regs))
23522 + if (!user_mode(regs))
23523 {
23524 if (!fixup_exception(regs)) {
23525 task->thread.error_code = error_code;
23526 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23527 index 2ed8459..7cf329f 100644
23528 --- a/arch/x86/kernel/uprobes.c
23529 +++ b/arch/x86/kernel/uprobes.c
23530 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23531 int ret = NOTIFY_DONE;
23532
23533 /* We are only interested in userspace traps */
23534 - if (regs && !user_mode_vm(regs))
23535 + if (regs && !user_mode(regs))
23536 return NOTIFY_DONE;
23537
23538 switch (val) {
23539 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
23540
23541 if (ncopied != rasize) {
23542 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
23543 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
23544 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
23545
23546 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
23547 }
23548 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23549 index b9242ba..50c5edd 100644
23550 --- a/arch/x86/kernel/verify_cpu.S
23551 +++ b/arch/x86/kernel/verify_cpu.S
23552 @@ -20,6 +20,7 @@
23553 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23554 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23555 * arch/x86/kernel/head_32.S: processor startup
23556 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23557 *
23558 * verify_cpu, returns the status of longmode and SSE in register %eax.
23559 * 0: Success 1: Failure
23560 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23561 index e8edcf5..27f9344 100644
23562 --- a/arch/x86/kernel/vm86_32.c
23563 +++ b/arch/x86/kernel/vm86_32.c
23564 @@ -44,6 +44,7 @@
23565 #include <linux/ptrace.h>
23566 #include <linux/audit.h>
23567 #include <linux/stddef.h>
23568 +#include <linux/grsecurity.h>
23569
23570 #include <asm/uaccess.h>
23571 #include <asm/io.h>
23572 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23573 do_exit(SIGSEGV);
23574 }
23575
23576 - tss = &per_cpu(init_tss, get_cpu());
23577 + tss = init_tss + get_cpu();
23578 current->thread.sp0 = current->thread.saved_sp0;
23579 current->thread.sysenter_cs = __KERNEL_CS;
23580 load_sp0(tss, &current->thread);
23581 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23582
23583 if (tsk->thread.saved_sp0)
23584 return -EPERM;
23585 +
23586 +#ifdef CONFIG_GRKERNSEC_VM86
23587 + if (!capable(CAP_SYS_RAWIO)) {
23588 + gr_handle_vm86();
23589 + return -EPERM;
23590 + }
23591 +#endif
23592 +
23593 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23594 offsetof(struct kernel_vm86_struct, vm86plus) -
23595 sizeof(info.regs));
23596 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23597 int tmp;
23598 struct vm86plus_struct __user *v86;
23599
23600 +#ifdef CONFIG_GRKERNSEC_VM86
23601 + if (!capable(CAP_SYS_RAWIO)) {
23602 + gr_handle_vm86();
23603 + return -EPERM;
23604 + }
23605 +#endif
23606 +
23607 tsk = current;
23608 switch (cmd) {
23609 case VM86_REQUEST_IRQ:
23610 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23611 tsk->thread.saved_fs = info->regs32->fs;
23612 tsk->thread.saved_gs = get_user_gs(info->regs32);
23613
23614 - tss = &per_cpu(init_tss, get_cpu());
23615 + tss = init_tss + get_cpu();
23616 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23617 if (cpu_has_sep)
23618 tsk->thread.sysenter_cs = 0;
23619 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23620 goto cannot_handle;
23621 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23622 goto cannot_handle;
23623 - intr_ptr = (unsigned long __user *) (i << 2);
23624 + intr_ptr = (__force unsigned long __user *) (i << 2);
23625 if (get_user(segoffs, intr_ptr))
23626 goto cannot_handle;
23627 if ((segoffs >> 16) == BIOSSEG)
23628 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23629 index 10c4f30..57377c2 100644
23630 --- a/arch/x86/kernel/vmlinux.lds.S
23631 +++ b/arch/x86/kernel/vmlinux.lds.S
23632 @@ -26,6 +26,13 @@
23633 #include <asm/page_types.h>
23634 #include <asm/cache.h>
23635 #include <asm/boot.h>
23636 +#include <asm/segment.h>
23637 +
23638 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23639 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23640 +#else
23641 +#define __KERNEL_TEXT_OFFSET 0
23642 +#endif
23643
23644 #undef i386 /* in case the preprocessor is a 32bit one */
23645
23646 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23647
23648 PHDRS {
23649 text PT_LOAD FLAGS(5); /* R_E */
23650 +#ifdef CONFIG_X86_32
23651 + module PT_LOAD FLAGS(5); /* R_E */
23652 +#endif
23653 +#ifdef CONFIG_XEN
23654 + rodata PT_LOAD FLAGS(5); /* R_E */
23655 +#else
23656 + rodata PT_LOAD FLAGS(4); /* R__ */
23657 +#endif
23658 data PT_LOAD FLAGS(6); /* RW_ */
23659 -#ifdef CONFIG_X86_64
23660 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23661 #ifdef CONFIG_SMP
23662 percpu PT_LOAD FLAGS(6); /* RW_ */
23663 #endif
23664 + text.init PT_LOAD FLAGS(5); /* R_E */
23665 + text.exit PT_LOAD FLAGS(5); /* R_E */
23666 init PT_LOAD FLAGS(7); /* RWE */
23667 -#endif
23668 note PT_NOTE FLAGS(0); /* ___ */
23669 }
23670
23671 SECTIONS
23672 {
23673 #ifdef CONFIG_X86_32
23674 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23675 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23676 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23677 #else
23678 - . = __START_KERNEL;
23679 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23680 + . = __START_KERNEL;
23681 #endif
23682
23683 /* Text and read-only data */
23684 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23685 - _text = .;
23686 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23687 /* bootstrapping code */
23688 +#ifdef CONFIG_X86_32
23689 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23690 +#else
23691 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23692 +#endif
23693 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23694 + _text = .;
23695 HEAD_TEXT
23696 . = ALIGN(8);
23697 _stext = .;
23698 @@ -104,13 +124,48 @@ SECTIONS
23699 IRQENTRY_TEXT
23700 *(.fixup)
23701 *(.gnu.warning)
23702 - /* End of text section */
23703 - _etext = .;
23704 } :text = 0x9090
23705
23706 - NOTES :text :note
23707 + . += __KERNEL_TEXT_OFFSET;
23708
23709 - EXCEPTION_TABLE(16) :text = 0x9090
23710 +#ifdef CONFIG_X86_32
23711 + . = ALIGN(PAGE_SIZE);
23712 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23713 +
23714 +#ifdef CONFIG_PAX_KERNEXEC
23715 + MODULES_EXEC_VADDR = .;
23716 + BYTE(0)
23717 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23718 + . = ALIGN(HPAGE_SIZE) - 1;
23719 + MODULES_EXEC_END = .;
23720 +#endif
23721 +
23722 + } :module
23723 +#endif
23724 +
23725 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23726 + /* End of text section */
23727 + BYTE(0)
23728 + _etext = . - __KERNEL_TEXT_OFFSET;
23729 + }
23730 +
23731 +#ifdef CONFIG_X86_32
23732 + . = ALIGN(PAGE_SIZE);
23733 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23734 + *(.idt)
23735 + . = ALIGN(PAGE_SIZE);
23736 + *(.empty_zero_page)
23737 + *(.initial_pg_fixmap)
23738 + *(.initial_pg_pmd)
23739 + *(.initial_page_table)
23740 + *(.swapper_pg_dir)
23741 + } :rodata
23742 +#endif
23743 +
23744 + . = ALIGN(PAGE_SIZE);
23745 + NOTES :rodata :note
23746 +
23747 + EXCEPTION_TABLE(16) :rodata
23748
23749 #if defined(CONFIG_DEBUG_RODATA)
23750 /* .text should occupy whole number of pages */
23751 @@ -122,16 +177,20 @@ SECTIONS
23752
23753 /* Data */
23754 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23755 +
23756 +#ifdef CONFIG_PAX_KERNEXEC
23757 + . = ALIGN(HPAGE_SIZE);
23758 +#else
23759 + . = ALIGN(PAGE_SIZE);
23760 +#endif
23761 +
23762 /* Start of data section */
23763 _sdata = .;
23764
23765 /* init_task */
23766 INIT_TASK_DATA(THREAD_SIZE)
23767
23768 -#ifdef CONFIG_X86_32
23769 - /* 32 bit has nosave before _edata */
23770 NOSAVE_DATA
23771 -#endif
23772
23773 PAGE_ALIGNED_DATA(PAGE_SIZE)
23774
23775 @@ -172,12 +231,19 @@ SECTIONS
23776 #endif /* CONFIG_X86_64 */
23777
23778 /* Init code and data - will be freed after init */
23779 - . = ALIGN(PAGE_SIZE);
23780 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23781 + BYTE(0)
23782 +
23783 +#ifdef CONFIG_PAX_KERNEXEC
23784 + . = ALIGN(HPAGE_SIZE);
23785 +#else
23786 + . = ALIGN(PAGE_SIZE);
23787 +#endif
23788 +
23789 __init_begin = .; /* paired with __init_end */
23790 - }
23791 + } :init.begin
23792
23793 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23794 +#ifdef CONFIG_SMP
23795 /*
23796 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23797 * output PHDR, so the next output section - .init.text - should
23798 @@ -186,12 +252,27 @@ SECTIONS
23799 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23800 #endif
23801
23802 - INIT_TEXT_SECTION(PAGE_SIZE)
23803 -#ifdef CONFIG_X86_64
23804 - :init
23805 -#endif
23806 + . = ALIGN(PAGE_SIZE);
23807 + init_begin = .;
23808 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23809 + VMLINUX_SYMBOL(_sinittext) = .;
23810 + INIT_TEXT
23811 + VMLINUX_SYMBOL(_einittext) = .;
23812 + . = ALIGN(PAGE_SIZE);
23813 + } :text.init
23814
23815 - INIT_DATA_SECTION(16)
23816 + /*
23817 + * .exit.text is discard at runtime, not link time, to deal with
23818 + * references from .altinstructions and .eh_frame
23819 + */
23820 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23821 + EXIT_TEXT
23822 + . = ALIGN(16);
23823 + } :text.exit
23824 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23825 +
23826 + . = ALIGN(PAGE_SIZE);
23827 + INIT_DATA_SECTION(16) :init
23828
23829 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23830 __x86_cpu_dev_start = .;
23831 @@ -253,19 +334,12 @@ SECTIONS
23832 }
23833
23834 . = ALIGN(8);
23835 - /*
23836 - * .exit.text is discard at runtime, not link time, to deal with
23837 - * references from .altinstructions and .eh_frame
23838 - */
23839 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23840 - EXIT_TEXT
23841 - }
23842
23843 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23844 EXIT_DATA
23845 }
23846
23847 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23848 +#ifndef CONFIG_SMP
23849 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23850 #endif
23851
23852 @@ -284,16 +358,10 @@ SECTIONS
23853 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23854 __smp_locks = .;
23855 *(.smp_locks)
23856 - . = ALIGN(PAGE_SIZE);
23857 __smp_locks_end = .;
23858 + . = ALIGN(PAGE_SIZE);
23859 }
23860
23861 -#ifdef CONFIG_X86_64
23862 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23863 - NOSAVE_DATA
23864 - }
23865 -#endif
23866 -
23867 /* BSS */
23868 . = ALIGN(PAGE_SIZE);
23869 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23870 @@ -309,6 +377,7 @@ SECTIONS
23871 __brk_base = .;
23872 . += 64 * 1024; /* 64k alignment slop space */
23873 *(.brk_reservation) /* areas brk users have reserved */
23874 + . = ALIGN(HPAGE_SIZE);
23875 __brk_limit = .;
23876 }
23877
23878 @@ -335,13 +404,12 @@ SECTIONS
23879 * for the boot processor.
23880 */
23881 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23882 -INIT_PER_CPU(gdt_page);
23883 INIT_PER_CPU(irq_stack_union);
23884
23885 /*
23886 * Build-time check on the image size:
23887 */
23888 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23889 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23890 "kernel image bigger than KERNEL_IMAGE_SIZE");
23891
23892 #ifdef CONFIG_SMP
23893 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23894 index 9a907a6..f83f921 100644
23895 --- a/arch/x86/kernel/vsyscall_64.c
23896 +++ b/arch/x86/kernel/vsyscall_64.c
23897 @@ -56,15 +56,13 @@
23898 DEFINE_VVAR(int, vgetcpu_mode);
23899 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23900
23901 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23902 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23903
23904 static int __init vsyscall_setup(char *str)
23905 {
23906 if (str) {
23907 if (!strcmp("emulate", str))
23908 vsyscall_mode = EMULATE;
23909 - else if (!strcmp("native", str))
23910 - vsyscall_mode = NATIVE;
23911 else if (!strcmp("none", str))
23912 vsyscall_mode = NONE;
23913 else
23914 @@ -323,8 +321,7 @@ do_ret:
23915 return true;
23916
23917 sigsegv:
23918 - force_sig(SIGSEGV, current);
23919 - return true;
23920 + do_group_exit(SIGKILL);
23921 }
23922
23923 /*
23924 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23925 extern char __vvar_page;
23926 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23927
23928 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23929 - vsyscall_mode == NATIVE
23930 - ? PAGE_KERNEL_VSYSCALL
23931 - : PAGE_KERNEL_VVAR);
23932 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23933 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23934 (unsigned long)VSYSCALL_START);
23935
23936 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23937 index b014d94..6d6ca7b 100644
23938 --- a/arch/x86/kernel/x8664_ksyms_64.c
23939 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23940 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23941 EXPORT_SYMBOL(copy_user_generic_unrolled);
23942 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23943 EXPORT_SYMBOL(__copy_user_nocache);
23944 -EXPORT_SYMBOL(_copy_from_user);
23945 -EXPORT_SYMBOL(_copy_to_user);
23946
23947 EXPORT_SYMBOL(copy_page);
23948 EXPORT_SYMBOL(clear_page);
23949 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23950 index 45a14db..075bb9b 100644
23951 --- a/arch/x86/kernel/x86_init.c
23952 +++ b/arch/x86/kernel/x86_init.c
23953 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23954 },
23955 };
23956
23957 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23958 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23959 .early_percpu_clock_init = x86_init_noop,
23960 .setup_percpu_clockev = setup_secondary_APIC_clock,
23961 };
23962 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23963 static void default_nmi_init(void) { };
23964 static int default_i8042_detect(void) { return 1; };
23965
23966 -struct x86_platform_ops x86_platform = {
23967 +struct x86_platform_ops x86_platform __read_only = {
23968 .calibrate_tsc = native_calibrate_tsc,
23969 .get_wallclock = mach_get_cmos_time,
23970 .set_wallclock = mach_set_rtc_mmss,
23971 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23972 };
23973
23974 EXPORT_SYMBOL_GPL(x86_platform);
23975 -struct x86_msi_ops x86_msi = {
23976 +struct x86_msi_ops x86_msi __read_only = {
23977 .setup_msi_irqs = native_setup_msi_irqs,
23978 .compose_msi_msg = native_compose_msi_msg,
23979 .teardown_msi_irq = native_teardown_msi_irq,
23980 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23981 .setup_hpet_msi = default_setup_hpet_msi,
23982 };
23983
23984 -struct x86_io_apic_ops x86_io_apic_ops = {
23985 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23986 .init = native_io_apic_init_mappings,
23987 .read = native_io_apic_read,
23988 .write = native_io_apic_write,
23989 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23990 index ada87a3..afea76d 100644
23991 --- a/arch/x86/kernel/xsave.c
23992 +++ b/arch/x86/kernel/xsave.c
23993 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23994 {
23995 int err;
23996
23997 + buf = (struct xsave_struct __user *)____m(buf);
23998 if (use_xsave())
23999 err = xsave_user(buf);
24000 else if (use_fxsr())
24001 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24002 */
24003 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24004 {
24005 + buf = (void __user *)____m(buf);
24006 if (use_xsave()) {
24007 if ((unsigned long)buf % 64 || fx_only) {
24008 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24009 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24010 index a20ecb5..d0e2194 100644
24011 --- a/arch/x86/kvm/cpuid.c
24012 +++ b/arch/x86/kvm/cpuid.c
24013 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24014 struct kvm_cpuid2 *cpuid,
24015 struct kvm_cpuid_entry2 __user *entries)
24016 {
24017 - int r;
24018 + int r, i;
24019
24020 r = -E2BIG;
24021 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24022 goto out;
24023 r = -EFAULT;
24024 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24025 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24026 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24027 goto out;
24028 + for (i = 0; i < cpuid->nent; ++i) {
24029 + struct kvm_cpuid_entry2 cpuid_entry;
24030 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24031 + goto out;
24032 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24033 + }
24034 vcpu->arch.cpuid_nent = cpuid->nent;
24035 kvm_apic_set_version(vcpu);
24036 kvm_x86_ops->cpuid_update(vcpu);
24037 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24038 struct kvm_cpuid2 *cpuid,
24039 struct kvm_cpuid_entry2 __user *entries)
24040 {
24041 - int r;
24042 + int r, i;
24043
24044 r = -E2BIG;
24045 if (cpuid->nent < vcpu->arch.cpuid_nent)
24046 goto out;
24047 r = -EFAULT;
24048 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24049 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24050 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24051 goto out;
24052 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24053 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24054 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24055 + goto out;
24056 + }
24057 return 0;
24058
24059 out:
24060 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24061 index 5953dce..f11a7d2 100644
24062 --- a/arch/x86/kvm/emulate.c
24063 +++ b/arch/x86/kvm/emulate.c
24064 @@ -329,6 +329,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24065
24066 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24067 do { \
24068 + unsigned long _tmp; \
24069 __asm__ __volatile__ ( \
24070 _PRE_EFLAGS("0", "4", "2") \
24071 _op _suffix " %"_x"3,%1; " \
24072 @@ -343,8 +344,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24073 /* Raw emulation: instruction has two explicit operands. */
24074 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24075 do { \
24076 - unsigned long _tmp; \
24077 - \
24078 switch ((ctxt)->dst.bytes) { \
24079 case 2: \
24080 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24081 @@ -360,7 +359,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24082
24083 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24084 do { \
24085 - unsigned long _tmp; \
24086 switch ((ctxt)->dst.bytes) { \
24087 case 1: \
24088 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24089 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24090 index 0eee2c8..94a32c3 100644
24091 --- a/arch/x86/kvm/lapic.c
24092 +++ b/arch/x86/kvm/lapic.c
24093 @@ -55,7 +55,7 @@
24094 #define APIC_BUS_CYCLE_NS 1
24095
24096 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24097 -#define apic_debug(fmt, arg...)
24098 +#define apic_debug(fmt, arg...) do {} while (0)
24099
24100 #define APIC_LVT_NUM 6
24101 /* 14 is the version for Xeon and Pentium 8.4.8*/
24102 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24103 index da20860..d19fdf5 100644
24104 --- a/arch/x86/kvm/paging_tmpl.h
24105 +++ b/arch/x86/kvm/paging_tmpl.h
24106 @@ -208,7 +208,7 @@ retry_walk:
24107 if (unlikely(kvm_is_error_hva(host_addr)))
24108 goto error;
24109
24110 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24111 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24112 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24113 goto error;
24114 walker->ptep_user[walker->level - 1] = ptep_user;
24115 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24116 index a14a6ea..dc86cf0 100644
24117 --- a/arch/x86/kvm/svm.c
24118 +++ b/arch/x86/kvm/svm.c
24119 @@ -3493,7 +3493,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24120 int cpu = raw_smp_processor_id();
24121
24122 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24123 +
24124 + pax_open_kernel();
24125 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24126 + pax_close_kernel();
24127 +
24128 load_TR_desc();
24129 }
24130
24131 @@ -3894,6 +3898,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24132 #endif
24133 #endif
24134
24135 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24136 + __set_fs(current_thread_info()->addr_limit);
24137 +#endif
24138 +
24139 reload_tss(vcpu);
24140
24141 local_irq_disable();
24142 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24143 index 5402c94..c3bdeee 100644
24144 --- a/arch/x86/kvm/vmx.c
24145 +++ b/arch/x86/kvm/vmx.c
24146 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24147 #endif
24148 }
24149
24150 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24151 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24152 {
24153 vmcs_writel(field, vmcs_readl(field) & ~mask);
24154 }
24155
24156 -static void vmcs_set_bits(unsigned long field, u32 mask)
24157 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24158 {
24159 vmcs_writel(field, vmcs_readl(field) | mask);
24160 }
24161 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
24162 struct desc_struct *descs;
24163
24164 descs = (void *)gdt->address;
24165 +
24166 + pax_open_kernel();
24167 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24168 + pax_close_kernel();
24169 +
24170 load_TR_desc();
24171 }
24172
24173 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24174 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24175 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24176
24177 +#ifdef CONFIG_PAX_PER_CPU_PGD
24178 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24179 +#endif
24180 +
24181 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24182 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24183 vmx->loaded_vmcs->cpu = cpu;
24184 @@ -2935,8 +2943,11 @@ static __init int hardware_setup(void)
24185 if (!cpu_has_vmx_flexpriority())
24186 flexpriority_enabled = 0;
24187
24188 - if (!cpu_has_vmx_tpr_shadow())
24189 - kvm_x86_ops->update_cr8_intercept = NULL;
24190 + if (!cpu_has_vmx_tpr_shadow()) {
24191 + pax_open_kernel();
24192 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24193 + pax_close_kernel();
24194 + }
24195
24196 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24197 kvm_disable_largepages();
24198 @@ -2947,13 +2958,15 @@ static __init int hardware_setup(void)
24199 if (!cpu_has_vmx_apicv())
24200 enable_apicv = 0;
24201
24202 + pax_open_kernel();
24203 if (enable_apicv)
24204 - kvm_x86_ops->update_cr8_intercept = NULL;
24205 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24206 else {
24207 - kvm_x86_ops->hwapic_irr_update = NULL;
24208 - kvm_x86_ops->deliver_posted_interrupt = NULL;
24209 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24210 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24211 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
24212 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24213 }
24214 + pax_close_kernel();
24215
24216 if (nested)
24217 nested_vmx_setup_ctls_msrs();
24218 @@ -4076,7 +4089,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24219
24220 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24221 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24222 +
24223 +#ifndef CONFIG_PAX_PER_CPU_PGD
24224 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24225 +#endif
24226
24227 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24228 #ifdef CONFIG_X86_64
24229 @@ -4098,7 +4114,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24230 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24231 vmx->host_idt_base = dt.address;
24232
24233 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24234 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24235
24236 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24237 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24238 @@ -7030,6 +7046,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24239 "jmp 2f \n\t"
24240 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24241 "2: "
24242 +
24243 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24244 + "ljmp %[cs],$3f\n\t"
24245 + "3: "
24246 +#endif
24247 +
24248 /* Save guest registers, load host registers, keep flags */
24249 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24250 "pop %0 \n\t"
24251 @@ -7082,6 +7104,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24252 #endif
24253 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24254 [wordsize]"i"(sizeof(ulong))
24255 +
24256 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24257 + ,[cs]"i"(__KERNEL_CS)
24258 +#endif
24259 +
24260 : "cc", "memory"
24261 #ifdef CONFIG_X86_64
24262 , "rax", "rbx", "rdi", "rsi"
24263 @@ -7095,7 +7122,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24264 if (debugctlmsr)
24265 update_debugctlmsr(debugctlmsr);
24266
24267 -#ifndef CONFIG_X86_64
24268 +#ifdef CONFIG_X86_32
24269 /*
24270 * The sysexit path does not restore ds/es, so we must set them to
24271 * a reasonable value ourselves.
24272 @@ -7104,8 +7131,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24273 * may be executed in interrupt context, which saves and restore segments
24274 * around it, nullifying its effect.
24275 */
24276 - loadsegment(ds, __USER_DS);
24277 - loadsegment(es, __USER_DS);
24278 + loadsegment(ds, __KERNEL_DS);
24279 + loadsegment(es, __KERNEL_DS);
24280 + loadsegment(ss, __KERNEL_DS);
24281 +
24282 +#ifdef CONFIG_PAX_KERNEXEC
24283 + loadsegment(fs, __KERNEL_PERCPU);
24284 +#endif
24285 +
24286 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24287 + __set_fs(current_thread_info()->addr_limit);
24288 +#endif
24289 +
24290 #endif
24291
24292 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24293 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24294 index e8ba99c..ee9d7d9 100644
24295 --- a/arch/x86/kvm/x86.c
24296 +++ b/arch/x86/kvm/x86.c
24297 @@ -1725,8 +1725,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24298 {
24299 struct kvm *kvm = vcpu->kvm;
24300 int lm = is_long_mode(vcpu);
24301 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24302 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24303 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24304 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24305 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24306 : kvm->arch.xen_hvm_config.blob_size_32;
24307 u32 page_num = data & ~PAGE_MASK;
24308 @@ -2609,6 +2609,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24309 if (n < msr_list.nmsrs)
24310 goto out;
24311 r = -EFAULT;
24312 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24313 + goto out;
24314 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24315 num_msrs_to_save * sizeof(u32)))
24316 goto out;
24317 @@ -5297,7 +5299,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24318 };
24319 #endif
24320
24321 -int kvm_arch_init(void *opaque)
24322 +int kvm_arch_init(const void *opaque)
24323 {
24324 int r;
24325 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24326 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24327 index 7114c63..a1018fc 100644
24328 --- a/arch/x86/lguest/boot.c
24329 +++ b/arch/x86/lguest/boot.c
24330 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24331 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24332 * Launcher to reboot us.
24333 */
24334 -static void lguest_restart(char *reason)
24335 +static __noreturn void lguest_restart(char *reason)
24336 {
24337 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24338 + BUG();
24339 }
24340
24341 /*G:050
24342 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24343 index 00933d5..3a64af9 100644
24344 --- a/arch/x86/lib/atomic64_386_32.S
24345 +++ b/arch/x86/lib/atomic64_386_32.S
24346 @@ -48,6 +48,10 @@ BEGIN(read)
24347 movl (v), %eax
24348 movl 4(v), %edx
24349 RET_ENDP
24350 +BEGIN(read_unchecked)
24351 + movl (v), %eax
24352 + movl 4(v), %edx
24353 +RET_ENDP
24354 #undef v
24355
24356 #define v %esi
24357 @@ -55,6 +59,10 @@ BEGIN(set)
24358 movl %ebx, (v)
24359 movl %ecx, 4(v)
24360 RET_ENDP
24361 +BEGIN(set_unchecked)
24362 + movl %ebx, (v)
24363 + movl %ecx, 4(v)
24364 +RET_ENDP
24365 #undef v
24366
24367 #define v %esi
24368 @@ -70,6 +78,20 @@ RET_ENDP
24369 BEGIN(add)
24370 addl %eax, (v)
24371 adcl %edx, 4(v)
24372 +
24373 +#ifdef CONFIG_PAX_REFCOUNT
24374 + jno 0f
24375 + subl %eax, (v)
24376 + sbbl %edx, 4(v)
24377 + int $4
24378 +0:
24379 + _ASM_EXTABLE(0b, 0b)
24380 +#endif
24381 +
24382 +RET_ENDP
24383 +BEGIN(add_unchecked)
24384 + addl %eax, (v)
24385 + adcl %edx, 4(v)
24386 RET_ENDP
24387 #undef v
24388
24389 @@ -77,6 +99,24 @@ RET_ENDP
24390 BEGIN(add_return)
24391 addl (v), %eax
24392 adcl 4(v), %edx
24393 +
24394 +#ifdef CONFIG_PAX_REFCOUNT
24395 + into
24396 +1234:
24397 + _ASM_EXTABLE(1234b, 2f)
24398 +#endif
24399 +
24400 + movl %eax, (v)
24401 + movl %edx, 4(v)
24402 +
24403 +#ifdef CONFIG_PAX_REFCOUNT
24404 +2:
24405 +#endif
24406 +
24407 +RET_ENDP
24408 +BEGIN(add_return_unchecked)
24409 + addl (v), %eax
24410 + adcl 4(v), %edx
24411 movl %eax, (v)
24412 movl %edx, 4(v)
24413 RET_ENDP
24414 @@ -86,6 +126,20 @@ RET_ENDP
24415 BEGIN(sub)
24416 subl %eax, (v)
24417 sbbl %edx, 4(v)
24418 +
24419 +#ifdef CONFIG_PAX_REFCOUNT
24420 + jno 0f
24421 + addl %eax, (v)
24422 + adcl %edx, 4(v)
24423 + int $4
24424 +0:
24425 + _ASM_EXTABLE(0b, 0b)
24426 +#endif
24427 +
24428 +RET_ENDP
24429 +BEGIN(sub_unchecked)
24430 + subl %eax, (v)
24431 + sbbl %edx, 4(v)
24432 RET_ENDP
24433 #undef v
24434
24435 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24436 sbbl $0, %edx
24437 addl (v), %eax
24438 adcl 4(v), %edx
24439 +
24440 +#ifdef CONFIG_PAX_REFCOUNT
24441 + into
24442 +1234:
24443 + _ASM_EXTABLE(1234b, 2f)
24444 +#endif
24445 +
24446 + movl %eax, (v)
24447 + movl %edx, 4(v)
24448 +
24449 +#ifdef CONFIG_PAX_REFCOUNT
24450 +2:
24451 +#endif
24452 +
24453 +RET_ENDP
24454 +BEGIN(sub_return_unchecked)
24455 + negl %edx
24456 + negl %eax
24457 + sbbl $0, %edx
24458 + addl (v), %eax
24459 + adcl 4(v), %edx
24460 movl %eax, (v)
24461 movl %edx, 4(v)
24462 RET_ENDP
24463 @@ -105,6 +180,20 @@ RET_ENDP
24464 BEGIN(inc)
24465 addl $1, (v)
24466 adcl $0, 4(v)
24467 +
24468 +#ifdef CONFIG_PAX_REFCOUNT
24469 + jno 0f
24470 + subl $1, (v)
24471 + sbbl $0, 4(v)
24472 + int $4
24473 +0:
24474 + _ASM_EXTABLE(0b, 0b)
24475 +#endif
24476 +
24477 +RET_ENDP
24478 +BEGIN(inc_unchecked)
24479 + addl $1, (v)
24480 + adcl $0, 4(v)
24481 RET_ENDP
24482 #undef v
24483
24484 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24485 movl 4(v), %edx
24486 addl $1, %eax
24487 adcl $0, %edx
24488 +
24489 +#ifdef CONFIG_PAX_REFCOUNT
24490 + into
24491 +1234:
24492 + _ASM_EXTABLE(1234b, 2f)
24493 +#endif
24494 +
24495 + movl %eax, (v)
24496 + movl %edx, 4(v)
24497 +
24498 +#ifdef CONFIG_PAX_REFCOUNT
24499 +2:
24500 +#endif
24501 +
24502 +RET_ENDP
24503 +BEGIN(inc_return_unchecked)
24504 + movl (v), %eax
24505 + movl 4(v), %edx
24506 + addl $1, %eax
24507 + adcl $0, %edx
24508 movl %eax, (v)
24509 movl %edx, 4(v)
24510 RET_ENDP
24511 @@ -123,6 +232,20 @@ RET_ENDP
24512 BEGIN(dec)
24513 subl $1, (v)
24514 sbbl $0, 4(v)
24515 +
24516 +#ifdef CONFIG_PAX_REFCOUNT
24517 + jno 0f
24518 + addl $1, (v)
24519 + adcl $0, 4(v)
24520 + int $4
24521 +0:
24522 + _ASM_EXTABLE(0b, 0b)
24523 +#endif
24524 +
24525 +RET_ENDP
24526 +BEGIN(dec_unchecked)
24527 + subl $1, (v)
24528 + sbbl $0, 4(v)
24529 RET_ENDP
24530 #undef v
24531
24532 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24533 movl 4(v), %edx
24534 subl $1, %eax
24535 sbbl $0, %edx
24536 +
24537 +#ifdef CONFIG_PAX_REFCOUNT
24538 + into
24539 +1234:
24540 + _ASM_EXTABLE(1234b, 2f)
24541 +#endif
24542 +
24543 + movl %eax, (v)
24544 + movl %edx, 4(v)
24545 +
24546 +#ifdef CONFIG_PAX_REFCOUNT
24547 +2:
24548 +#endif
24549 +
24550 +RET_ENDP
24551 +BEGIN(dec_return_unchecked)
24552 + movl (v), %eax
24553 + movl 4(v), %edx
24554 + subl $1, %eax
24555 + sbbl $0, %edx
24556 movl %eax, (v)
24557 movl %edx, 4(v)
24558 RET_ENDP
24559 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24560 adcl %edx, %edi
24561 addl (v), %eax
24562 adcl 4(v), %edx
24563 +
24564 +#ifdef CONFIG_PAX_REFCOUNT
24565 + into
24566 +1234:
24567 + _ASM_EXTABLE(1234b, 2f)
24568 +#endif
24569 +
24570 cmpl %eax, %ecx
24571 je 3f
24572 1:
24573 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24574 1:
24575 addl $1, %eax
24576 adcl $0, %edx
24577 +
24578 +#ifdef CONFIG_PAX_REFCOUNT
24579 + into
24580 +1234:
24581 + _ASM_EXTABLE(1234b, 2f)
24582 +#endif
24583 +
24584 movl %eax, (v)
24585 movl %edx, 4(v)
24586 movl $1, %eax
24587 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24588 movl 4(v), %edx
24589 subl $1, %eax
24590 sbbl $0, %edx
24591 +
24592 +#ifdef CONFIG_PAX_REFCOUNT
24593 + into
24594 +1234:
24595 + _ASM_EXTABLE(1234b, 1f)
24596 +#endif
24597 +
24598 js 1f
24599 movl %eax, (v)
24600 movl %edx, 4(v)
24601 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24602 index f5cc9eb..51fa319 100644
24603 --- a/arch/x86/lib/atomic64_cx8_32.S
24604 +++ b/arch/x86/lib/atomic64_cx8_32.S
24605 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24606 CFI_STARTPROC
24607
24608 read64 %ecx
24609 + pax_force_retaddr
24610 ret
24611 CFI_ENDPROC
24612 ENDPROC(atomic64_read_cx8)
24613
24614 +ENTRY(atomic64_read_unchecked_cx8)
24615 + CFI_STARTPROC
24616 +
24617 + read64 %ecx
24618 + pax_force_retaddr
24619 + ret
24620 + CFI_ENDPROC
24621 +ENDPROC(atomic64_read_unchecked_cx8)
24622 +
24623 ENTRY(atomic64_set_cx8)
24624 CFI_STARTPROC
24625
24626 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24627 cmpxchg8b (%esi)
24628 jne 1b
24629
24630 + pax_force_retaddr
24631 ret
24632 CFI_ENDPROC
24633 ENDPROC(atomic64_set_cx8)
24634
24635 +ENTRY(atomic64_set_unchecked_cx8)
24636 + CFI_STARTPROC
24637 +
24638 +1:
24639 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24640 + * are atomic on 586 and newer */
24641 + cmpxchg8b (%esi)
24642 + jne 1b
24643 +
24644 + pax_force_retaddr
24645 + ret
24646 + CFI_ENDPROC
24647 +ENDPROC(atomic64_set_unchecked_cx8)
24648 +
24649 ENTRY(atomic64_xchg_cx8)
24650 CFI_STARTPROC
24651
24652 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24653 cmpxchg8b (%esi)
24654 jne 1b
24655
24656 + pax_force_retaddr
24657 ret
24658 CFI_ENDPROC
24659 ENDPROC(atomic64_xchg_cx8)
24660
24661 -.macro addsub_return func ins insc
24662 -ENTRY(atomic64_\func\()_return_cx8)
24663 +.macro addsub_return func ins insc unchecked=""
24664 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24665 CFI_STARTPROC
24666 SAVE ebp
24667 SAVE ebx
24668 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24669 movl %edx, %ecx
24670 \ins\()l %esi, %ebx
24671 \insc\()l %edi, %ecx
24672 +
24673 +.ifb \unchecked
24674 +#ifdef CONFIG_PAX_REFCOUNT
24675 + into
24676 +2:
24677 + _ASM_EXTABLE(2b, 3f)
24678 +#endif
24679 +.endif
24680 +
24681 LOCK_PREFIX
24682 cmpxchg8b (%ebp)
24683 jne 1b
24684 -
24685 -10:
24686 movl %ebx, %eax
24687 movl %ecx, %edx
24688 +
24689 +.ifb \unchecked
24690 +#ifdef CONFIG_PAX_REFCOUNT
24691 +3:
24692 +#endif
24693 +.endif
24694 +
24695 RESTORE edi
24696 RESTORE esi
24697 RESTORE ebx
24698 RESTORE ebp
24699 + pax_force_retaddr
24700 ret
24701 CFI_ENDPROC
24702 -ENDPROC(atomic64_\func\()_return_cx8)
24703 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24704 .endm
24705
24706 addsub_return add add adc
24707 addsub_return sub sub sbb
24708 +addsub_return add add adc _unchecked
24709 +addsub_return sub sub sbb _unchecked
24710
24711 -.macro incdec_return func ins insc
24712 -ENTRY(atomic64_\func\()_return_cx8)
24713 +.macro incdec_return func ins insc unchecked=""
24714 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24715 CFI_STARTPROC
24716 SAVE ebx
24717
24718 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24719 movl %edx, %ecx
24720 \ins\()l $1, %ebx
24721 \insc\()l $0, %ecx
24722 +
24723 +.ifb \unchecked
24724 +#ifdef CONFIG_PAX_REFCOUNT
24725 + into
24726 +2:
24727 + _ASM_EXTABLE(2b, 3f)
24728 +#endif
24729 +.endif
24730 +
24731 LOCK_PREFIX
24732 cmpxchg8b (%esi)
24733 jne 1b
24734
24735 -10:
24736 movl %ebx, %eax
24737 movl %ecx, %edx
24738 +
24739 +.ifb \unchecked
24740 +#ifdef CONFIG_PAX_REFCOUNT
24741 +3:
24742 +#endif
24743 +.endif
24744 +
24745 RESTORE ebx
24746 + pax_force_retaddr
24747 ret
24748 CFI_ENDPROC
24749 -ENDPROC(atomic64_\func\()_return_cx8)
24750 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24751 .endm
24752
24753 incdec_return inc add adc
24754 incdec_return dec sub sbb
24755 +incdec_return inc add adc _unchecked
24756 +incdec_return dec sub sbb _unchecked
24757
24758 ENTRY(atomic64_dec_if_positive_cx8)
24759 CFI_STARTPROC
24760 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24761 movl %edx, %ecx
24762 subl $1, %ebx
24763 sbb $0, %ecx
24764 +
24765 +#ifdef CONFIG_PAX_REFCOUNT
24766 + into
24767 +1234:
24768 + _ASM_EXTABLE(1234b, 2f)
24769 +#endif
24770 +
24771 js 2f
24772 LOCK_PREFIX
24773 cmpxchg8b (%esi)
24774 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24775 movl %ebx, %eax
24776 movl %ecx, %edx
24777 RESTORE ebx
24778 + pax_force_retaddr
24779 ret
24780 CFI_ENDPROC
24781 ENDPROC(atomic64_dec_if_positive_cx8)
24782 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24783 movl %edx, %ecx
24784 addl %ebp, %ebx
24785 adcl %edi, %ecx
24786 +
24787 +#ifdef CONFIG_PAX_REFCOUNT
24788 + into
24789 +1234:
24790 + _ASM_EXTABLE(1234b, 3f)
24791 +#endif
24792 +
24793 LOCK_PREFIX
24794 cmpxchg8b (%esi)
24795 jne 1b
24796 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24797 CFI_ADJUST_CFA_OFFSET -8
24798 RESTORE ebx
24799 RESTORE ebp
24800 + pax_force_retaddr
24801 ret
24802 4:
24803 cmpl %edx, 4(%esp)
24804 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24805 xorl %ecx, %ecx
24806 addl $1, %ebx
24807 adcl %edx, %ecx
24808 +
24809 +#ifdef CONFIG_PAX_REFCOUNT
24810 + into
24811 +1234:
24812 + _ASM_EXTABLE(1234b, 3f)
24813 +#endif
24814 +
24815 LOCK_PREFIX
24816 cmpxchg8b (%esi)
24817 jne 1b
24818 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24819 movl $1, %eax
24820 3:
24821 RESTORE ebx
24822 + pax_force_retaddr
24823 ret
24824 CFI_ENDPROC
24825 ENDPROC(atomic64_inc_not_zero_cx8)
24826 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24827 index e78b8ee..7e173a8 100644
24828 --- a/arch/x86/lib/checksum_32.S
24829 +++ b/arch/x86/lib/checksum_32.S
24830 @@ -29,7 +29,8 @@
24831 #include <asm/dwarf2.h>
24832 #include <asm/errno.h>
24833 #include <asm/asm.h>
24834 -
24835 +#include <asm/segment.h>
24836 +
24837 /*
24838 * computes a partial checksum, e.g. for TCP/UDP fragments
24839 */
24840 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24841
24842 #define ARGBASE 16
24843 #define FP 12
24844 -
24845 -ENTRY(csum_partial_copy_generic)
24846 +
24847 +ENTRY(csum_partial_copy_generic_to_user)
24848 CFI_STARTPROC
24849 +
24850 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24851 + pushl_cfi %gs
24852 + popl_cfi %es
24853 + jmp csum_partial_copy_generic
24854 +#endif
24855 +
24856 +ENTRY(csum_partial_copy_generic_from_user)
24857 +
24858 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24859 + pushl_cfi %gs
24860 + popl_cfi %ds
24861 +#endif
24862 +
24863 +ENTRY(csum_partial_copy_generic)
24864 subl $4,%esp
24865 CFI_ADJUST_CFA_OFFSET 4
24866 pushl_cfi %edi
24867 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24868 jmp 4f
24869 SRC(1: movw (%esi), %bx )
24870 addl $2, %esi
24871 -DST( movw %bx, (%edi) )
24872 +DST( movw %bx, %es:(%edi) )
24873 addl $2, %edi
24874 addw %bx, %ax
24875 adcl $0, %eax
24876 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24877 SRC(1: movl (%esi), %ebx )
24878 SRC( movl 4(%esi), %edx )
24879 adcl %ebx, %eax
24880 -DST( movl %ebx, (%edi) )
24881 +DST( movl %ebx, %es:(%edi) )
24882 adcl %edx, %eax
24883 -DST( movl %edx, 4(%edi) )
24884 +DST( movl %edx, %es:4(%edi) )
24885
24886 SRC( movl 8(%esi), %ebx )
24887 SRC( movl 12(%esi), %edx )
24888 adcl %ebx, %eax
24889 -DST( movl %ebx, 8(%edi) )
24890 +DST( movl %ebx, %es:8(%edi) )
24891 adcl %edx, %eax
24892 -DST( movl %edx, 12(%edi) )
24893 +DST( movl %edx, %es:12(%edi) )
24894
24895 SRC( movl 16(%esi), %ebx )
24896 SRC( movl 20(%esi), %edx )
24897 adcl %ebx, %eax
24898 -DST( movl %ebx, 16(%edi) )
24899 +DST( movl %ebx, %es:16(%edi) )
24900 adcl %edx, %eax
24901 -DST( movl %edx, 20(%edi) )
24902 +DST( movl %edx, %es:20(%edi) )
24903
24904 SRC( movl 24(%esi), %ebx )
24905 SRC( movl 28(%esi), %edx )
24906 adcl %ebx, %eax
24907 -DST( movl %ebx, 24(%edi) )
24908 +DST( movl %ebx, %es:24(%edi) )
24909 adcl %edx, %eax
24910 -DST( movl %edx, 28(%edi) )
24911 +DST( movl %edx, %es:28(%edi) )
24912
24913 lea 32(%esi), %esi
24914 lea 32(%edi), %edi
24915 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24916 shrl $2, %edx # This clears CF
24917 SRC(3: movl (%esi), %ebx )
24918 adcl %ebx, %eax
24919 -DST( movl %ebx, (%edi) )
24920 +DST( movl %ebx, %es:(%edi) )
24921 lea 4(%esi), %esi
24922 lea 4(%edi), %edi
24923 dec %edx
24924 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24925 jb 5f
24926 SRC( movw (%esi), %cx )
24927 leal 2(%esi), %esi
24928 -DST( movw %cx, (%edi) )
24929 +DST( movw %cx, %es:(%edi) )
24930 leal 2(%edi), %edi
24931 je 6f
24932 shll $16,%ecx
24933 SRC(5: movb (%esi), %cl )
24934 -DST( movb %cl, (%edi) )
24935 +DST( movb %cl, %es:(%edi) )
24936 6: addl %ecx, %eax
24937 adcl $0, %eax
24938 7:
24939 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24940
24941 6001:
24942 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24943 - movl $-EFAULT, (%ebx)
24944 + movl $-EFAULT, %ss:(%ebx)
24945
24946 # zero the complete destination - computing the rest
24947 # is too much work
24948 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24949
24950 6002:
24951 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24952 - movl $-EFAULT,(%ebx)
24953 + movl $-EFAULT,%ss:(%ebx)
24954 jmp 5000b
24955
24956 .previous
24957
24958 + pushl_cfi %ss
24959 + popl_cfi %ds
24960 + pushl_cfi %ss
24961 + popl_cfi %es
24962 popl_cfi %ebx
24963 CFI_RESTORE ebx
24964 popl_cfi %esi
24965 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24966 popl_cfi %ecx # equivalent to addl $4,%esp
24967 ret
24968 CFI_ENDPROC
24969 -ENDPROC(csum_partial_copy_generic)
24970 +ENDPROC(csum_partial_copy_generic_to_user)
24971
24972 #else
24973
24974 /* Version for PentiumII/PPro */
24975
24976 #define ROUND1(x) \
24977 + nop; nop; nop; \
24978 SRC(movl x(%esi), %ebx ) ; \
24979 addl %ebx, %eax ; \
24980 - DST(movl %ebx, x(%edi) ) ;
24981 + DST(movl %ebx, %es:x(%edi)) ;
24982
24983 #define ROUND(x) \
24984 + nop; nop; nop; \
24985 SRC(movl x(%esi), %ebx ) ; \
24986 adcl %ebx, %eax ; \
24987 - DST(movl %ebx, x(%edi) ) ;
24988 + DST(movl %ebx, %es:x(%edi)) ;
24989
24990 #define ARGBASE 12
24991 -
24992 -ENTRY(csum_partial_copy_generic)
24993 +
24994 +ENTRY(csum_partial_copy_generic_to_user)
24995 CFI_STARTPROC
24996 +
24997 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24998 + pushl_cfi %gs
24999 + popl_cfi %es
25000 + jmp csum_partial_copy_generic
25001 +#endif
25002 +
25003 +ENTRY(csum_partial_copy_generic_from_user)
25004 +
25005 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25006 + pushl_cfi %gs
25007 + popl_cfi %ds
25008 +#endif
25009 +
25010 +ENTRY(csum_partial_copy_generic)
25011 pushl_cfi %ebx
25012 CFI_REL_OFFSET ebx, 0
25013 pushl_cfi %edi
25014 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25015 subl %ebx, %edi
25016 lea -1(%esi),%edx
25017 andl $-32,%edx
25018 - lea 3f(%ebx,%ebx), %ebx
25019 + lea 3f(%ebx,%ebx,2), %ebx
25020 testl %esi, %esi
25021 jmp *%ebx
25022 1: addl $64,%esi
25023 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25024 jb 5f
25025 SRC( movw (%esi), %dx )
25026 leal 2(%esi), %esi
25027 -DST( movw %dx, (%edi) )
25028 +DST( movw %dx, %es:(%edi) )
25029 leal 2(%edi), %edi
25030 je 6f
25031 shll $16,%edx
25032 5:
25033 SRC( movb (%esi), %dl )
25034 -DST( movb %dl, (%edi) )
25035 +DST( movb %dl, %es:(%edi) )
25036 6: addl %edx, %eax
25037 adcl $0, %eax
25038 7:
25039 .section .fixup, "ax"
25040 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25041 - movl $-EFAULT, (%ebx)
25042 + movl $-EFAULT, %ss:(%ebx)
25043 # zero the complete destination (computing the rest is too much work)
25044 movl ARGBASE+8(%esp),%edi # dst
25045 movl ARGBASE+12(%esp),%ecx # len
25046 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25047 rep; stosb
25048 jmp 7b
25049 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25050 - movl $-EFAULT, (%ebx)
25051 + movl $-EFAULT, %ss:(%ebx)
25052 jmp 7b
25053 .previous
25054
25055 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25056 + pushl_cfi %ss
25057 + popl_cfi %ds
25058 + pushl_cfi %ss
25059 + popl_cfi %es
25060 +#endif
25061 +
25062 popl_cfi %esi
25063 CFI_RESTORE esi
25064 popl_cfi %edi
25065 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25066 CFI_RESTORE ebx
25067 ret
25068 CFI_ENDPROC
25069 -ENDPROC(csum_partial_copy_generic)
25070 +ENDPROC(csum_partial_copy_generic_to_user)
25071
25072 #undef ROUND
25073 #undef ROUND1
25074 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25075 index f2145cf..cea889d 100644
25076 --- a/arch/x86/lib/clear_page_64.S
25077 +++ b/arch/x86/lib/clear_page_64.S
25078 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25079 movl $4096/8,%ecx
25080 xorl %eax,%eax
25081 rep stosq
25082 + pax_force_retaddr
25083 ret
25084 CFI_ENDPROC
25085 ENDPROC(clear_page_c)
25086 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25087 movl $4096,%ecx
25088 xorl %eax,%eax
25089 rep stosb
25090 + pax_force_retaddr
25091 ret
25092 CFI_ENDPROC
25093 ENDPROC(clear_page_c_e)
25094 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25095 leaq 64(%rdi),%rdi
25096 jnz .Lloop
25097 nop
25098 + pax_force_retaddr
25099 ret
25100 CFI_ENDPROC
25101 .Lclear_page_end:
25102 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25103
25104 #include <asm/cpufeature.h>
25105
25106 - .section .altinstr_replacement,"ax"
25107 + .section .altinstr_replacement,"a"
25108 1: .byte 0xeb /* jmp <disp8> */
25109 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25110 2: .byte 0xeb /* jmp <disp8> */
25111 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25112 index 1e572c5..2a162cd 100644
25113 --- a/arch/x86/lib/cmpxchg16b_emu.S
25114 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25115 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25116
25117 popf
25118 mov $1, %al
25119 + pax_force_retaddr
25120 ret
25121
25122 not_same:
25123 popf
25124 xor %al,%al
25125 + pax_force_retaddr
25126 ret
25127
25128 CFI_ENDPROC
25129 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25130 index 176cca6..1166c50 100644
25131 --- a/arch/x86/lib/copy_page_64.S
25132 +++ b/arch/x86/lib/copy_page_64.S
25133 @@ -9,6 +9,7 @@ copy_page_rep:
25134 CFI_STARTPROC
25135 movl $4096/8, %ecx
25136 rep movsq
25137 + pax_force_retaddr
25138 ret
25139 CFI_ENDPROC
25140 ENDPROC(copy_page_rep)
25141 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25142
25143 ENTRY(copy_page)
25144 CFI_STARTPROC
25145 - subq $2*8, %rsp
25146 - CFI_ADJUST_CFA_OFFSET 2*8
25147 + subq $3*8, %rsp
25148 + CFI_ADJUST_CFA_OFFSET 3*8
25149 movq %rbx, (%rsp)
25150 CFI_REL_OFFSET rbx, 0
25151 movq %r12, 1*8(%rsp)
25152 CFI_REL_OFFSET r12, 1*8
25153 + movq %r13, 2*8(%rsp)
25154 + CFI_REL_OFFSET r13, 2*8
25155
25156 movl $(4096/64)-5, %ecx
25157 .p2align 4
25158 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25159 movq 0x8*2(%rsi), %rdx
25160 movq 0x8*3(%rsi), %r8
25161 movq 0x8*4(%rsi), %r9
25162 - movq 0x8*5(%rsi), %r10
25163 + movq 0x8*5(%rsi), %r13
25164 movq 0x8*6(%rsi), %r11
25165 movq 0x8*7(%rsi), %r12
25166
25167 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25168 movq %rdx, 0x8*2(%rdi)
25169 movq %r8, 0x8*3(%rdi)
25170 movq %r9, 0x8*4(%rdi)
25171 - movq %r10, 0x8*5(%rdi)
25172 + movq %r13, 0x8*5(%rdi)
25173 movq %r11, 0x8*6(%rdi)
25174 movq %r12, 0x8*7(%rdi)
25175
25176 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25177 movq 0x8*2(%rsi), %rdx
25178 movq 0x8*3(%rsi), %r8
25179 movq 0x8*4(%rsi), %r9
25180 - movq 0x8*5(%rsi), %r10
25181 + movq 0x8*5(%rsi), %r13
25182 movq 0x8*6(%rsi), %r11
25183 movq 0x8*7(%rsi), %r12
25184
25185 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25186 movq %rdx, 0x8*2(%rdi)
25187 movq %r8, 0x8*3(%rdi)
25188 movq %r9, 0x8*4(%rdi)
25189 - movq %r10, 0x8*5(%rdi)
25190 + movq %r13, 0x8*5(%rdi)
25191 movq %r11, 0x8*6(%rdi)
25192 movq %r12, 0x8*7(%rdi)
25193
25194 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25195 CFI_RESTORE rbx
25196 movq 1*8(%rsp), %r12
25197 CFI_RESTORE r12
25198 - addq $2*8, %rsp
25199 - CFI_ADJUST_CFA_OFFSET -2*8
25200 + movq 2*8(%rsp), %r13
25201 + CFI_RESTORE r13
25202 + addq $3*8, %rsp
25203 + CFI_ADJUST_CFA_OFFSET -3*8
25204 + pax_force_retaddr
25205 ret
25206 .Lcopy_page_end:
25207 CFI_ENDPROC
25208 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25209
25210 #include <asm/cpufeature.h>
25211
25212 - .section .altinstr_replacement,"ax"
25213 + .section .altinstr_replacement,"a"
25214 1: .byte 0xeb /* jmp <disp8> */
25215 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25216 2:
25217 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25218 index a30ca15..d25fab6 100644
25219 --- a/arch/x86/lib/copy_user_64.S
25220 +++ b/arch/x86/lib/copy_user_64.S
25221 @@ -18,6 +18,7 @@
25222 #include <asm/alternative-asm.h>
25223 #include <asm/asm.h>
25224 #include <asm/smap.h>
25225 +#include <asm/pgtable.h>
25226
25227 /*
25228 * By placing feature2 after feature1 in altinstructions section, we logically
25229 @@ -31,7 +32,7 @@
25230 .byte 0xe9 /* 32bit jump */
25231 .long \orig-1f /* by default jump to orig */
25232 1:
25233 - .section .altinstr_replacement,"ax"
25234 + .section .altinstr_replacement,"a"
25235 2: .byte 0xe9 /* near jump with 32bit immediate */
25236 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25237 3: .byte 0xe9 /* near jump with 32bit immediate */
25238 @@ -70,47 +71,20 @@
25239 #endif
25240 .endm
25241
25242 -/* Standard copy_to_user with segment limit checking */
25243 -ENTRY(_copy_to_user)
25244 - CFI_STARTPROC
25245 - GET_THREAD_INFO(%rax)
25246 - movq %rdi,%rcx
25247 - addq %rdx,%rcx
25248 - jc bad_to_user
25249 - cmpq TI_addr_limit(%rax),%rcx
25250 - ja bad_to_user
25251 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25252 - copy_user_generic_unrolled,copy_user_generic_string, \
25253 - copy_user_enhanced_fast_string
25254 - CFI_ENDPROC
25255 -ENDPROC(_copy_to_user)
25256 -
25257 -/* Standard copy_from_user with segment limit checking */
25258 -ENTRY(_copy_from_user)
25259 - CFI_STARTPROC
25260 - GET_THREAD_INFO(%rax)
25261 - movq %rsi,%rcx
25262 - addq %rdx,%rcx
25263 - jc bad_from_user
25264 - cmpq TI_addr_limit(%rax),%rcx
25265 - ja bad_from_user
25266 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25267 - copy_user_generic_unrolled,copy_user_generic_string, \
25268 - copy_user_enhanced_fast_string
25269 - CFI_ENDPROC
25270 -ENDPROC(_copy_from_user)
25271 -
25272 .section .fixup,"ax"
25273 /* must zero dest */
25274 ENTRY(bad_from_user)
25275 bad_from_user:
25276 CFI_STARTPROC
25277 + testl %edx,%edx
25278 + js bad_to_user
25279 movl %edx,%ecx
25280 xorl %eax,%eax
25281 rep
25282 stosb
25283 bad_to_user:
25284 movl %edx,%eax
25285 + pax_force_retaddr
25286 ret
25287 CFI_ENDPROC
25288 ENDPROC(bad_from_user)
25289 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25290 jz 17f
25291 1: movq (%rsi),%r8
25292 2: movq 1*8(%rsi),%r9
25293 -3: movq 2*8(%rsi),%r10
25294 +3: movq 2*8(%rsi),%rax
25295 4: movq 3*8(%rsi),%r11
25296 5: movq %r8,(%rdi)
25297 6: movq %r9,1*8(%rdi)
25298 -7: movq %r10,2*8(%rdi)
25299 +7: movq %rax,2*8(%rdi)
25300 8: movq %r11,3*8(%rdi)
25301 9: movq 4*8(%rsi),%r8
25302 10: movq 5*8(%rsi),%r9
25303 -11: movq 6*8(%rsi),%r10
25304 +11: movq 6*8(%rsi),%rax
25305 12: movq 7*8(%rsi),%r11
25306 13: movq %r8,4*8(%rdi)
25307 14: movq %r9,5*8(%rdi)
25308 -15: movq %r10,6*8(%rdi)
25309 +15: movq %rax,6*8(%rdi)
25310 16: movq %r11,7*8(%rdi)
25311 leaq 64(%rsi),%rsi
25312 leaq 64(%rdi),%rdi
25313 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25314 jnz 21b
25315 23: xor %eax,%eax
25316 ASM_CLAC
25317 + pax_force_retaddr
25318 ret
25319
25320 .section .fixup,"ax"
25321 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25322 movsb
25323 4: xorl %eax,%eax
25324 ASM_CLAC
25325 + pax_force_retaddr
25326 ret
25327
25328 .section .fixup,"ax"
25329 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25330 movsb
25331 2: xorl %eax,%eax
25332 ASM_CLAC
25333 + pax_force_retaddr
25334 ret
25335
25336 .section .fixup,"ax"
25337 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25338 index 6a4f43c..f08b4a2 100644
25339 --- a/arch/x86/lib/copy_user_nocache_64.S
25340 +++ b/arch/x86/lib/copy_user_nocache_64.S
25341 @@ -8,6 +8,7 @@
25342
25343 #include <linux/linkage.h>
25344 #include <asm/dwarf2.h>
25345 +#include <asm/alternative-asm.h>
25346
25347 #define FIX_ALIGNMENT 1
25348
25349 @@ -16,6 +17,7 @@
25350 #include <asm/thread_info.h>
25351 #include <asm/asm.h>
25352 #include <asm/smap.h>
25353 +#include <asm/pgtable.h>
25354
25355 .macro ALIGN_DESTINATION
25356 #ifdef FIX_ALIGNMENT
25357 @@ -49,6 +51,15 @@
25358 */
25359 ENTRY(__copy_user_nocache)
25360 CFI_STARTPROC
25361 +
25362 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25363 + mov pax_user_shadow_base,%rcx
25364 + cmp %rcx,%rsi
25365 + jae 1f
25366 + add %rcx,%rsi
25367 +1:
25368 +#endif
25369 +
25370 ASM_STAC
25371 cmpl $8,%edx
25372 jb 20f /* less then 8 bytes, go to byte copy loop */
25373 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25374 jz 17f
25375 1: movq (%rsi),%r8
25376 2: movq 1*8(%rsi),%r9
25377 -3: movq 2*8(%rsi),%r10
25378 +3: movq 2*8(%rsi),%rax
25379 4: movq 3*8(%rsi),%r11
25380 5: movnti %r8,(%rdi)
25381 6: movnti %r9,1*8(%rdi)
25382 -7: movnti %r10,2*8(%rdi)
25383 +7: movnti %rax,2*8(%rdi)
25384 8: movnti %r11,3*8(%rdi)
25385 9: movq 4*8(%rsi),%r8
25386 10: movq 5*8(%rsi),%r9
25387 -11: movq 6*8(%rsi),%r10
25388 +11: movq 6*8(%rsi),%rax
25389 12: movq 7*8(%rsi),%r11
25390 13: movnti %r8,4*8(%rdi)
25391 14: movnti %r9,5*8(%rdi)
25392 -15: movnti %r10,6*8(%rdi)
25393 +15: movnti %rax,6*8(%rdi)
25394 16: movnti %r11,7*8(%rdi)
25395 leaq 64(%rsi),%rsi
25396 leaq 64(%rdi),%rdi
25397 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25398 23: xorl %eax,%eax
25399 ASM_CLAC
25400 sfence
25401 + pax_force_retaddr
25402 ret
25403
25404 .section .fixup,"ax"
25405 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25406 index 2419d5f..953ee51 100644
25407 --- a/arch/x86/lib/csum-copy_64.S
25408 +++ b/arch/x86/lib/csum-copy_64.S
25409 @@ -9,6 +9,7 @@
25410 #include <asm/dwarf2.h>
25411 #include <asm/errno.h>
25412 #include <asm/asm.h>
25413 +#include <asm/alternative-asm.h>
25414
25415 /*
25416 * Checksum copy with exception handling.
25417 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25418 CFI_RESTORE rbp
25419 addq $7*8, %rsp
25420 CFI_ADJUST_CFA_OFFSET -7*8
25421 + pax_force_retaddr 0, 1
25422 ret
25423 CFI_RESTORE_STATE
25424
25425 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25426 index 25b7ae8..169fafc 100644
25427 --- a/arch/x86/lib/csum-wrappers_64.c
25428 +++ b/arch/x86/lib/csum-wrappers_64.c
25429 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25430 len -= 2;
25431 }
25432 }
25433 - isum = csum_partial_copy_generic((__force const void *)src,
25434 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25435 dst, len, isum, errp, NULL);
25436 if (unlikely(*errp))
25437 goto out_err;
25438 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25439 }
25440
25441 *errp = 0;
25442 - return csum_partial_copy_generic(src, (void __force *)dst,
25443 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25444 len, isum, NULL, errp);
25445 }
25446 EXPORT_SYMBOL(csum_partial_copy_to_user);
25447 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25448 index a451235..1daa956 100644
25449 --- a/arch/x86/lib/getuser.S
25450 +++ b/arch/x86/lib/getuser.S
25451 @@ -33,17 +33,40 @@
25452 #include <asm/thread_info.h>
25453 #include <asm/asm.h>
25454 #include <asm/smap.h>
25455 +#include <asm/segment.h>
25456 +#include <asm/pgtable.h>
25457 +#include <asm/alternative-asm.h>
25458 +
25459 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25460 +#define __copyuser_seg gs;
25461 +#else
25462 +#define __copyuser_seg
25463 +#endif
25464
25465 .text
25466 ENTRY(__get_user_1)
25467 CFI_STARTPROC
25468 +
25469 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25470 GET_THREAD_INFO(%_ASM_DX)
25471 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25472 jae bad_get_user
25473 ASM_STAC
25474 -1: movzbl (%_ASM_AX),%edx
25475 +
25476 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25477 + mov pax_user_shadow_base,%_ASM_DX
25478 + cmp %_ASM_DX,%_ASM_AX
25479 + jae 1234f
25480 + add %_ASM_DX,%_ASM_AX
25481 +1234:
25482 +#endif
25483 +
25484 +#endif
25485 +
25486 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25487 xor %eax,%eax
25488 ASM_CLAC
25489 + pax_force_retaddr
25490 ret
25491 CFI_ENDPROC
25492 ENDPROC(__get_user_1)
25493 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25494 ENTRY(__get_user_2)
25495 CFI_STARTPROC
25496 add $1,%_ASM_AX
25497 +
25498 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25499 jc bad_get_user
25500 GET_THREAD_INFO(%_ASM_DX)
25501 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25502 jae bad_get_user
25503 ASM_STAC
25504 -2: movzwl -1(%_ASM_AX),%edx
25505 +
25506 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25507 + mov pax_user_shadow_base,%_ASM_DX
25508 + cmp %_ASM_DX,%_ASM_AX
25509 + jae 1234f
25510 + add %_ASM_DX,%_ASM_AX
25511 +1234:
25512 +#endif
25513 +
25514 +#endif
25515 +
25516 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25517 xor %eax,%eax
25518 ASM_CLAC
25519 + pax_force_retaddr
25520 ret
25521 CFI_ENDPROC
25522 ENDPROC(__get_user_2)
25523 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25524 ENTRY(__get_user_4)
25525 CFI_STARTPROC
25526 add $3,%_ASM_AX
25527 +
25528 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25529 jc bad_get_user
25530 GET_THREAD_INFO(%_ASM_DX)
25531 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25532 jae bad_get_user
25533 ASM_STAC
25534 -3: movl -3(%_ASM_AX),%edx
25535 +
25536 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25537 + mov pax_user_shadow_base,%_ASM_DX
25538 + cmp %_ASM_DX,%_ASM_AX
25539 + jae 1234f
25540 + add %_ASM_DX,%_ASM_AX
25541 +1234:
25542 +#endif
25543 +
25544 +#endif
25545 +
25546 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25547 xor %eax,%eax
25548 ASM_CLAC
25549 + pax_force_retaddr
25550 ret
25551 CFI_ENDPROC
25552 ENDPROC(__get_user_4)
25553 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25554 GET_THREAD_INFO(%_ASM_DX)
25555 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25556 jae bad_get_user
25557 +
25558 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25559 + mov pax_user_shadow_base,%_ASM_DX
25560 + cmp %_ASM_DX,%_ASM_AX
25561 + jae 1234f
25562 + add %_ASM_DX,%_ASM_AX
25563 +1234:
25564 +#endif
25565 +
25566 ASM_STAC
25567 4: movq -7(%_ASM_AX),%rdx
25568 xor %eax,%eax
25569 ASM_CLAC
25570 + pax_force_retaddr
25571 ret
25572 #else
25573 add $7,%_ASM_AX
25574 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
25575 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25576 jae bad_get_user_8
25577 ASM_STAC
25578 -4: movl -7(%_ASM_AX),%edx
25579 -5: movl -3(%_ASM_AX),%ecx
25580 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
25581 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
25582 xor %eax,%eax
25583 ASM_CLAC
25584 + pax_force_retaddr
25585 ret
25586 #endif
25587 CFI_ENDPROC
25588 @@ -113,6 +175,7 @@ bad_get_user:
25589 xor %edx,%edx
25590 mov $(-EFAULT),%_ASM_AX
25591 ASM_CLAC
25592 + pax_force_retaddr
25593 ret
25594 CFI_ENDPROC
25595 END(bad_get_user)
25596 @@ -124,6 +187,7 @@ bad_get_user_8:
25597 xor %ecx,%ecx
25598 mov $(-EFAULT),%_ASM_AX
25599 ASM_CLAC
25600 + pax_force_retaddr
25601 ret
25602 CFI_ENDPROC
25603 END(bad_get_user_8)
25604 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25605 index 54fcffe..7be149e 100644
25606 --- a/arch/x86/lib/insn.c
25607 +++ b/arch/x86/lib/insn.c
25608 @@ -20,8 +20,10 @@
25609
25610 #ifdef __KERNEL__
25611 #include <linux/string.h>
25612 +#include <asm/pgtable_types.h>
25613 #else
25614 #include <string.h>
25615 +#define ktla_ktva(addr) addr
25616 #endif
25617 #include <asm/inat.h>
25618 #include <asm/insn.h>
25619 @@ -53,8 +55,8 @@
25620 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25621 {
25622 memset(insn, 0, sizeof(*insn));
25623 - insn->kaddr = kaddr;
25624 - insn->next_byte = kaddr;
25625 + insn->kaddr = ktla_ktva(kaddr);
25626 + insn->next_byte = ktla_ktva(kaddr);
25627 insn->x86_64 = x86_64 ? 1 : 0;
25628 insn->opnd_bytes = 4;
25629 if (x86_64)
25630 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25631 index 05a95e7..326f2fa 100644
25632 --- a/arch/x86/lib/iomap_copy_64.S
25633 +++ b/arch/x86/lib/iomap_copy_64.S
25634 @@ -17,6 +17,7 @@
25635
25636 #include <linux/linkage.h>
25637 #include <asm/dwarf2.h>
25638 +#include <asm/alternative-asm.h>
25639
25640 /*
25641 * override generic version in lib/iomap_copy.c
25642 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25643 CFI_STARTPROC
25644 movl %edx,%ecx
25645 rep movsd
25646 + pax_force_retaddr
25647 ret
25648 CFI_ENDPROC
25649 ENDPROC(__iowrite32_copy)
25650 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25651 index 56313a3..aa84a79 100644
25652 --- a/arch/x86/lib/memcpy_64.S
25653 +++ b/arch/x86/lib/memcpy_64.S
25654 @@ -33,6 +33,7 @@
25655 rep movsq
25656 movl %edx, %ecx
25657 rep movsb
25658 + pax_force_retaddr
25659 ret
25660 .Lmemcpy_e:
25661 .previous
25662 @@ -49,6 +50,7 @@
25663 movq %rdi, %rax
25664 movq %rdx, %rcx
25665 rep movsb
25666 + pax_force_retaddr
25667 ret
25668 .Lmemcpy_e_e:
25669 .previous
25670 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25671 */
25672 movq 0*8(%rsi), %r8
25673 movq 1*8(%rsi), %r9
25674 - movq 2*8(%rsi), %r10
25675 + movq 2*8(%rsi), %rcx
25676 movq 3*8(%rsi), %r11
25677 leaq 4*8(%rsi), %rsi
25678
25679 movq %r8, 0*8(%rdi)
25680 movq %r9, 1*8(%rdi)
25681 - movq %r10, 2*8(%rdi)
25682 + movq %rcx, 2*8(%rdi)
25683 movq %r11, 3*8(%rdi)
25684 leaq 4*8(%rdi), %rdi
25685 jae .Lcopy_forward_loop
25686 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25687 subq $0x20, %rdx
25688 movq -1*8(%rsi), %r8
25689 movq -2*8(%rsi), %r9
25690 - movq -3*8(%rsi), %r10
25691 + movq -3*8(%rsi), %rcx
25692 movq -4*8(%rsi), %r11
25693 leaq -4*8(%rsi), %rsi
25694 movq %r8, -1*8(%rdi)
25695 movq %r9, -2*8(%rdi)
25696 - movq %r10, -3*8(%rdi)
25697 + movq %rcx, -3*8(%rdi)
25698 movq %r11, -4*8(%rdi)
25699 leaq -4*8(%rdi), %rdi
25700 jae .Lcopy_backward_loop
25701 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25702 */
25703 movq 0*8(%rsi), %r8
25704 movq 1*8(%rsi), %r9
25705 - movq -2*8(%rsi, %rdx), %r10
25706 + movq -2*8(%rsi, %rdx), %rcx
25707 movq -1*8(%rsi, %rdx), %r11
25708 movq %r8, 0*8(%rdi)
25709 movq %r9, 1*8(%rdi)
25710 - movq %r10, -2*8(%rdi, %rdx)
25711 + movq %rcx, -2*8(%rdi, %rdx)
25712 movq %r11, -1*8(%rdi, %rdx)
25713 + pax_force_retaddr
25714 retq
25715 .p2align 4
25716 .Lless_16bytes:
25717 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25718 movq -1*8(%rsi, %rdx), %r9
25719 movq %r8, 0*8(%rdi)
25720 movq %r9, -1*8(%rdi, %rdx)
25721 + pax_force_retaddr
25722 retq
25723 .p2align 4
25724 .Lless_8bytes:
25725 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25726 movl -4(%rsi, %rdx), %r8d
25727 movl %ecx, (%rdi)
25728 movl %r8d, -4(%rdi, %rdx)
25729 + pax_force_retaddr
25730 retq
25731 .p2align 4
25732 .Lless_3bytes:
25733 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25734 movb %cl, (%rdi)
25735
25736 .Lend:
25737 + pax_force_retaddr
25738 retq
25739 CFI_ENDPROC
25740 ENDPROC(memcpy)
25741 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25742 index 65268a6..c9518d1 100644
25743 --- a/arch/x86/lib/memmove_64.S
25744 +++ b/arch/x86/lib/memmove_64.S
25745 @@ -61,13 +61,13 @@ ENTRY(memmove)
25746 5:
25747 sub $0x20, %rdx
25748 movq 0*8(%rsi), %r11
25749 - movq 1*8(%rsi), %r10
25750 + movq 1*8(%rsi), %rcx
25751 movq 2*8(%rsi), %r9
25752 movq 3*8(%rsi), %r8
25753 leaq 4*8(%rsi), %rsi
25754
25755 movq %r11, 0*8(%rdi)
25756 - movq %r10, 1*8(%rdi)
25757 + movq %rcx, 1*8(%rdi)
25758 movq %r9, 2*8(%rdi)
25759 movq %r8, 3*8(%rdi)
25760 leaq 4*8(%rdi), %rdi
25761 @@ -81,10 +81,10 @@ ENTRY(memmove)
25762 4:
25763 movq %rdx, %rcx
25764 movq -8(%rsi, %rdx), %r11
25765 - lea -8(%rdi, %rdx), %r10
25766 + lea -8(%rdi, %rdx), %r9
25767 shrq $3, %rcx
25768 rep movsq
25769 - movq %r11, (%r10)
25770 + movq %r11, (%r9)
25771 jmp 13f
25772 .Lmemmove_end_forward:
25773
25774 @@ -95,14 +95,14 @@ ENTRY(memmove)
25775 7:
25776 movq %rdx, %rcx
25777 movq (%rsi), %r11
25778 - movq %rdi, %r10
25779 + movq %rdi, %r9
25780 leaq -8(%rsi, %rdx), %rsi
25781 leaq -8(%rdi, %rdx), %rdi
25782 shrq $3, %rcx
25783 std
25784 rep movsq
25785 cld
25786 - movq %r11, (%r10)
25787 + movq %r11, (%r9)
25788 jmp 13f
25789
25790 /*
25791 @@ -127,13 +127,13 @@ ENTRY(memmove)
25792 8:
25793 subq $0x20, %rdx
25794 movq -1*8(%rsi), %r11
25795 - movq -2*8(%rsi), %r10
25796 + movq -2*8(%rsi), %rcx
25797 movq -3*8(%rsi), %r9
25798 movq -4*8(%rsi), %r8
25799 leaq -4*8(%rsi), %rsi
25800
25801 movq %r11, -1*8(%rdi)
25802 - movq %r10, -2*8(%rdi)
25803 + movq %rcx, -2*8(%rdi)
25804 movq %r9, -3*8(%rdi)
25805 movq %r8, -4*8(%rdi)
25806 leaq -4*8(%rdi), %rdi
25807 @@ -151,11 +151,11 @@ ENTRY(memmove)
25808 * Move data from 16 bytes to 31 bytes.
25809 */
25810 movq 0*8(%rsi), %r11
25811 - movq 1*8(%rsi), %r10
25812 + movq 1*8(%rsi), %rcx
25813 movq -2*8(%rsi, %rdx), %r9
25814 movq -1*8(%rsi, %rdx), %r8
25815 movq %r11, 0*8(%rdi)
25816 - movq %r10, 1*8(%rdi)
25817 + movq %rcx, 1*8(%rdi)
25818 movq %r9, -2*8(%rdi, %rdx)
25819 movq %r8, -1*8(%rdi, %rdx)
25820 jmp 13f
25821 @@ -167,9 +167,9 @@ ENTRY(memmove)
25822 * Move data from 8 bytes to 15 bytes.
25823 */
25824 movq 0*8(%rsi), %r11
25825 - movq -1*8(%rsi, %rdx), %r10
25826 + movq -1*8(%rsi, %rdx), %r9
25827 movq %r11, 0*8(%rdi)
25828 - movq %r10, -1*8(%rdi, %rdx)
25829 + movq %r9, -1*8(%rdi, %rdx)
25830 jmp 13f
25831 10:
25832 cmpq $4, %rdx
25833 @@ -178,9 +178,9 @@ ENTRY(memmove)
25834 * Move data from 4 bytes to 7 bytes.
25835 */
25836 movl (%rsi), %r11d
25837 - movl -4(%rsi, %rdx), %r10d
25838 + movl -4(%rsi, %rdx), %r9d
25839 movl %r11d, (%rdi)
25840 - movl %r10d, -4(%rdi, %rdx)
25841 + movl %r9d, -4(%rdi, %rdx)
25842 jmp 13f
25843 11:
25844 cmp $2, %rdx
25845 @@ -189,9 +189,9 @@ ENTRY(memmove)
25846 * Move data from 2 bytes to 3 bytes.
25847 */
25848 movw (%rsi), %r11w
25849 - movw -2(%rsi, %rdx), %r10w
25850 + movw -2(%rsi, %rdx), %r9w
25851 movw %r11w, (%rdi)
25852 - movw %r10w, -2(%rdi, %rdx)
25853 + movw %r9w, -2(%rdi, %rdx)
25854 jmp 13f
25855 12:
25856 cmp $1, %rdx
25857 @@ -202,6 +202,7 @@ ENTRY(memmove)
25858 movb (%rsi), %r11b
25859 movb %r11b, (%rdi)
25860 13:
25861 + pax_force_retaddr
25862 retq
25863 CFI_ENDPROC
25864
25865 @@ -210,6 +211,7 @@ ENTRY(memmove)
25866 /* Forward moving data. */
25867 movq %rdx, %rcx
25868 rep movsb
25869 + pax_force_retaddr
25870 retq
25871 .Lmemmove_end_forward_efs:
25872 .previous
25873 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25874 index 2dcb380..963660a 100644
25875 --- a/arch/x86/lib/memset_64.S
25876 +++ b/arch/x86/lib/memset_64.S
25877 @@ -30,6 +30,7 @@
25878 movl %edx,%ecx
25879 rep stosb
25880 movq %r9,%rax
25881 + pax_force_retaddr
25882 ret
25883 .Lmemset_e:
25884 .previous
25885 @@ -52,6 +53,7 @@
25886 movq %rdx,%rcx
25887 rep stosb
25888 movq %r9,%rax
25889 + pax_force_retaddr
25890 ret
25891 .Lmemset_e_e:
25892 .previous
25893 @@ -59,7 +61,7 @@
25894 ENTRY(memset)
25895 ENTRY(__memset)
25896 CFI_STARTPROC
25897 - movq %rdi,%r10
25898 + movq %rdi,%r11
25899
25900 /* expand byte value */
25901 movzbl %sil,%ecx
25902 @@ -117,7 +119,8 @@ ENTRY(__memset)
25903 jnz .Lloop_1
25904
25905 .Lende:
25906 - movq %r10,%rax
25907 + movq %r11,%rax
25908 + pax_force_retaddr
25909 ret
25910
25911 CFI_RESTORE_STATE
25912 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25913 index c9f2d9b..e7fd2c0 100644
25914 --- a/arch/x86/lib/mmx_32.c
25915 +++ b/arch/x86/lib/mmx_32.c
25916 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25917 {
25918 void *p;
25919 int i;
25920 + unsigned long cr0;
25921
25922 if (unlikely(in_interrupt()))
25923 return __memcpy(to, from, len);
25924 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25925 kernel_fpu_begin();
25926
25927 __asm__ __volatile__ (
25928 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25929 - " prefetch 64(%0)\n"
25930 - " prefetch 128(%0)\n"
25931 - " prefetch 192(%0)\n"
25932 - " prefetch 256(%0)\n"
25933 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25934 + " prefetch 64(%1)\n"
25935 + " prefetch 128(%1)\n"
25936 + " prefetch 192(%1)\n"
25937 + " prefetch 256(%1)\n"
25938 "2: \n"
25939 ".section .fixup, \"ax\"\n"
25940 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25941 + "3: \n"
25942 +
25943 +#ifdef CONFIG_PAX_KERNEXEC
25944 + " movl %%cr0, %0\n"
25945 + " movl %0, %%eax\n"
25946 + " andl $0xFFFEFFFF, %%eax\n"
25947 + " movl %%eax, %%cr0\n"
25948 +#endif
25949 +
25950 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25951 +
25952 +#ifdef CONFIG_PAX_KERNEXEC
25953 + " movl %0, %%cr0\n"
25954 +#endif
25955 +
25956 " jmp 2b\n"
25957 ".previous\n"
25958 _ASM_EXTABLE(1b, 3b)
25959 - : : "r" (from));
25960 + : "=&r" (cr0) : "r" (from) : "ax");
25961
25962 for ( ; i > 5; i--) {
25963 __asm__ __volatile__ (
25964 - "1: prefetch 320(%0)\n"
25965 - "2: movq (%0), %%mm0\n"
25966 - " movq 8(%0), %%mm1\n"
25967 - " movq 16(%0), %%mm2\n"
25968 - " movq 24(%0), %%mm3\n"
25969 - " movq %%mm0, (%1)\n"
25970 - " movq %%mm1, 8(%1)\n"
25971 - " movq %%mm2, 16(%1)\n"
25972 - " movq %%mm3, 24(%1)\n"
25973 - " movq 32(%0), %%mm0\n"
25974 - " movq 40(%0), %%mm1\n"
25975 - " movq 48(%0), %%mm2\n"
25976 - " movq 56(%0), %%mm3\n"
25977 - " movq %%mm0, 32(%1)\n"
25978 - " movq %%mm1, 40(%1)\n"
25979 - " movq %%mm2, 48(%1)\n"
25980 - " movq %%mm3, 56(%1)\n"
25981 + "1: prefetch 320(%1)\n"
25982 + "2: movq (%1), %%mm0\n"
25983 + " movq 8(%1), %%mm1\n"
25984 + " movq 16(%1), %%mm2\n"
25985 + " movq 24(%1), %%mm3\n"
25986 + " movq %%mm0, (%2)\n"
25987 + " movq %%mm1, 8(%2)\n"
25988 + " movq %%mm2, 16(%2)\n"
25989 + " movq %%mm3, 24(%2)\n"
25990 + " movq 32(%1), %%mm0\n"
25991 + " movq 40(%1), %%mm1\n"
25992 + " movq 48(%1), %%mm2\n"
25993 + " movq 56(%1), %%mm3\n"
25994 + " movq %%mm0, 32(%2)\n"
25995 + " movq %%mm1, 40(%2)\n"
25996 + " movq %%mm2, 48(%2)\n"
25997 + " movq %%mm3, 56(%2)\n"
25998 ".section .fixup, \"ax\"\n"
25999 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26000 + "3:\n"
26001 +
26002 +#ifdef CONFIG_PAX_KERNEXEC
26003 + " movl %%cr0, %0\n"
26004 + " movl %0, %%eax\n"
26005 + " andl $0xFFFEFFFF, %%eax\n"
26006 + " movl %%eax, %%cr0\n"
26007 +#endif
26008 +
26009 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26010 +
26011 +#ifdef CONFIG_PAX_KERNEXEC
26012 + " movl %0, %%cr0\n"
26013 +#endif
26014 +
26015 " jmp 2b\n"
26016 ".previous\n"
26017 _ASM_EXTABLE(1b, 3b)
26018 - : : "r" (from), "r" (to) : "memory");
26019 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26020
26021 from += 64;
26022 to += 64;
26023 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26024 static void fast_copy_page(void *to, void *from)
26025 {
26026 int i;
26027 + unsigned long cr0;
26028
26029 kernel_fpu_begin();
26030
26031 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26032 * but that is for later. -AV
26033 */
26034 __asm__ __volatile__(
26035 - "1: prefetch (%0)\n"
26036 - " prefetch 64(%0)\n"
26037 - " prefetch 128(%0)\n"
26038 - " prefetch 192(%0)\n"
26039 - " prefetch 256(%0)\n"
26040 + "1: prefetch (%1)\n"
26041 + " prefetch 64(%1)\n"
26042 + " prefetch 128(%1)\n"
26043 + " prefetch 192(%1)\n"
26044 + " prefetch 256(%1)\n"
26045 "2: \n"
26046 ".section .fixup, \"ax\"\n"
26047 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26048 + "3: \n"
26049 +
26050 +#ifdef CONFIG_PAX_KERNEXEC
26051 + " movl %%cr0, %0\n"
26052 + " movl %0, %%eax\n"
26053 + " andl $0xFFFEFFFF, %%eax\n"
26054 + " movl %%eax, %%cr0\n"
26055 +#endif
26056 +
26057 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26058 +
26059 +#ifdef CONFIG_PAX_KERNEXEC
26060 + " movl %0, %%cr0\n"
26061 +#endif
26062 +
26063 " jmp 2b\n"
26064 ".previous\n"
26065 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26066 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26067
26068 for (i = 0; i < (4096-320)/64; i++) {
26069 __asm__ __volatile__ (
26070 - "1: prefetch 320(%0)\n"
26071 - "2: movq (%0), %%mm0\n"
26072 - " movntq %%mm0, (%1)\n"
26073 - " movq 8(%0), %%mm1\n"
26074 - " movntq %%mm1, 8(%1)\n"
26075 - " movq 16(%0), %%mm2\n"
26076 - " movntq %%mm2, 16(%1)\n"
26077 - " movq 24(%0), %%mm3\n"
26078 - " movntq %%mm3, 24(%1)\n"
26079 - " movq 32(%0), %%mm4\n"
26080 - " movntq %%mm4, 32(%1)\n"
26081 - " movq 40(%0), %%mm5\n"
26082 - " movntq %%mm5, 40(%1)\n"
26083 - " movq 48(%0), %%mm6\n"
26084 - " movntq %%mm6, 48(%1)\n"
26085 - " movq 56(%0), %%mm7\n"
26086 - " movntq %%mm7, 56(%1)\n"
26087 + "1: prefetch 320(%1)\n"
26088 + "2: movq (%1), %%mm0\n"
26089 + " movntq %%mm0, (%2)\n"
26090 + " movq 8(%1), %%mm1\n"
26091 + " movntq %%mm1, 8(%2)\n"
26092 + " movq 16(%1), %%mm2\n"
26093 + " movntq %%mm2, 16(%2)\n"
26094 + " movq 24(%1), %%mm3\n"
26095 + " movntq %%mm3, 24(%2)\n"
26096 + " movq 32(%1), %%mm4\n"
26097 + " movntq %%mm4, 32(%2)\n"
26098 + " movq 40(%1), %%mm5\n"
26099 + " movntq %%mm5, 40(%2)\n"
26100 + " movq 48(%1), %%mm6\n"
26101 + " movntq %%mm6, 48(%2)\n"
26102 + " movq 56(%1), %%mm7\n"
26103 + " movntq %%mm7, 56(%2)\n"
26104 ".section .fixup, \"ax\"\n"
26105 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26106 + "3:\n"
26107 +
26108 +#ifdef CONFIG_PAX_KERNEXEC
26109 + " movl %%cr0, %0\n"
26110 + " movl %0, %%eax\n"
26111 + " andl $0xFFFEFFFF, %%eax\n"
26112 + " movl %%eax, %%cr0\n"
26113 +#endif
26114 +
26115 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26116 +
26117 +#ifdef CONFIG_PAX_KERNEXEC
26118 + " movl %0, %%cr0\n"
26119 +#endif
26120 +
26121 " jmp 2b\n"
26122 ".previous\n"
26123 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26124 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26125
26126 from += 64;
26127 to += 64;
26128 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26129 static void fast_copy_page(void *to, void *from)
26130 {
26131 int i;
26132 + unsigned long cr0;
26133
26134 kernel_fpu_begin();
26135
26136 __asm__ __volatile__ (
26137 - "1: prefetch (%0)\n"
26138 - " prefetch 64(%0)\n"
26139 - " prefetch 128(%0)\n"
26140 - " prefetch 192(%0)\n"
26141 - " prefetch 256(%0)\n"
26142 + "1: prefetch (%1)\n"
26143 + " prefetch 64(%1)\n"
26144 + " prefetch 128(%1)\n"
26145 + " prefetch 192(%1)\n"
26146 + " prefetch 256(%1)\n"
26147 "2: \n"
26148 ".section .fixup, \"ax\"\n"
26149 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26150 + "3: \n"
26151 +
26152 +#ifdef CONFIG_PAX_KERNEXEC
26153 + " movl %%cr0, %0\n"
26154 + " movl %0, %%eax\n"
26155 + " andl $0xFFFEFFFF, %%eax\n"
26156 + " movl %%eax, %%cr0\n"
26157 +#endif
26158 +
26159 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26160 +
26161 +#ifdef CONFIG_PAX_KERNEXEC
26162 + " movl %0, %%cr0\n"
26163 +#endif
26164 +
26165 " jmp 2b\n"
26166 ".previous\n"
26167 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26168 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26169
26170 for (i = 0; i < 4096/64; i++) {
26171 __asm__ __volatile__ (
26172 - "1: prefetch 320(%0)\n"
26173 - "2: movq (%0), %%mm0\n"
26174 - " movq 8(%0), %%mm1\n"
26175 - " movq 16(%0), %%mm2\n"
26176 - " movq 24(%0), %%mm3\n"
26177 - " movq %%mm0, (%1)\n"
26178 - " movq %%mm1, 8(%1)\n"
26179 - " movq %%mm2, 16(%1)\n"
26180 - " movq %%mm3, 24(%1)\n"
26181 - " movq 32(%0), %%mm0\n"
26182 - " movq 40(%0), %%mm1\n"
26183 - " movq 48(%0), %%mm2\n"
26184 - " movq 56(%0), %%mm3\n"
26185 - " movq %%mm0, 32(%1)\n"
26186 - " movq %%mm1, 40(%1)\n"
26187 - " movq %%mm2, 48(%1)\n"
26188 - " movq %%mm3, 56(%1)\n"
26189 + "1: prefetch 320(%1)\n"
26190 + "2: movq (%1), %%mm0\n"
26191 + " movq 8(%1), %%mm1\n"
26192 + " movq 16(%1), %%mm2\n"
26193 + " movq 24(%1), %%mm3\n"
26194 + " movq %%mm0, (%2)\n"
26195 + " movq %%mm1, 8(%2)\n"
26196 + " movq %%mm2, 16(%2)\n"
26197 + " movq %%mm3, 24(%2)\n"
26198 + " movq 32(%1), %%mm0\n"
26199 + " movq 40(%1), %%mm1\n"
26200 + " movq 48(%1), %%mm2\n"
26201 + " movq 56(%1), %%mm3\n"
26202 + " movq %%mm0, 32(%2)\n"
26203 + " movq %%mm1, 40(%2)\n"
26204 + " movq %%mm2, 48(%2)\n"
26205 + " movq %%mm3, 56(%2)\n"
26206 ".section .fixup, \"ax\"\n"
26207 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26208 + "3:\n"
26209 +
26210 +#ifdef CONFIG_PAX_KERNEXEC
26211 + " movl %%cr0, %0\n"
26212 + " movl %0, %%eax\n"
26213 + " andl $0xFFFEFFFF, %%eax\n"
26214 + " movl %%eax, %%cr0\n"
26215 +#endif
26216 +
26217 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26218 +
26219 +#ifdef CONFIG_PAX_KERNEXEC
26220 + " movl %0, %%cr0\n"
26221 +#endif
26222 +
26223 " jmp 2b\n"
26224 ".previous\n"
26225 _ASM_EXTABLE(1b, 3b)
26226 - : : "r" (from), "r" (to) : "memory");
26227 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26228
26229 from += 64;
26230 to += 64;
26231 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26232 index f6d13ee..aca5f0b 100644
26233 --- a/arch/x86/lib/msr-reg.S
26234 +++ b/arch/x86/lib/msr-reg.S
26235 @@ -3,6 +3,7 @@
26236 #include <asm/dwarf2.h>
26237 #include <asm/asm.h>
26238 #include <asm/msr.h>
26239 +#include <asm/alternative-asm.h>
26240
26241 #ifdef CONFIG_X86_64
26242 /*
26243 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26244 CFI_STARTPROC
26245 pushq_cfi %rbx
26246 pushq_cfi %rbp
26247 - movq %rdi, %r10 /* Save pointer */
26248 + movq %rdi, %r9 /* Save pointer */
26249 xorl %r11d, %r11d /* Return value */
26250 movl (%rdi), %eax
26251 movl 4(%rdi), %ecx
26252 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26253 movl 28(%rdi), %edi
26254 CFI_REMEMBER_STATE
26255 1: \op
26256 -2: movl %eax, (%r10)
26257 +2: movl %eax, (%r9)
26258 movl %r11d, %eax /* Return value */
26259 - movl %ecx, 4(%r10)
26260 - movl %edx, 8(%r10)
26261 - movl %ebx, 12(%r10)
26262 - movl %ebp, 20(%r10)
26263 - movl %esi, 24(%r10)
26264 - movl %edi, 28(%r10)
26265 + movl %ecx, 4(%r9)
26266 + movl %edx, 8(%r9)
26267 + movl %ebx, 12(%r9)
26268 + movl %ebp, 20(%r9)
26269 + movl %esi, 24(%r9)
26270 + movl %edi, 28(%r9)
26271 popq_cfi %rbp
26272 popq_cfi %rbx
26273 + pax_force_retaddr
26274 ret
26275 3:
26276 CFI_RESTORE_STATE
26277 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26278 index fc6ba17..d4d989d 100644
26279 --- a/arch/x86/lib/putuser.S
26280 +++ b/arch/x86/lib/putuser.S
26281 @@ -16,7 +16,9 @@
26282 #include <asm/errno.h>
26283 #include <asm/asm.h>
26284 #include <asm/smap.h>
26285 -
26286 +#include <asm/segment.h>
26287 +#include <asm/pgtable.h>
26288 +#include <asm/alternative-asm.h>
26289
26290 /*
26291 * __put_user_X
26292 @@ -30,57 +32,125 @@
26293 * as they get called from within inline assembly.
26294 */
26295
26296 -#define ENTER CFI_STARTPROC ; \
26297 - GET_THREAD_INFO(%_ASM_BX)
26298 -#define EXIT ASM_CLAC ; \
26299 - ret ; \
26300 +#define ENTER CFI_STARTPROC
26301 +#define EXIT ASM_CLAC ; \
26302 + pax_force_retaddr ; \
26303 + ret ; \
26304 CFI_ENDPROC
26305
26306 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26307 +#define _DEST %_ASM_CX,%_ASM_BX
26308 +#else
26309 +#define _DEST %_ASM_CX
26310 +#endif
26311 +
26312 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26313 +#define __copyuser_seg gs;
26314 +#else
26315 +#define __copyuser_seg
26316 +#endif
26317 +
26318 .text
26319 ENTRY(__put_user_1)
26320 ENTER
26321 +
26322 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26323 + GET_THREAD_INFO(%_ASM_BX)
26324 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26325 jae bad_put_user
26326 ASM_STAC
26327 -1: movb %al,(%_ASM_CX)
26328 +
26329 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26330 + mov pax_user_shadow_base,%_ASM_BX
26331 + cmp %_ASM_BX,%_ASM_CX
26332 + jb 1234f
26333 + xor %ebx,%ebx
26334 +1234:
26335 +#endif
26336 +
26337 +#endif
26338 +
26339 +1: __copyuser_seg movb %al,(_DEST)
26340 xor %eax,%eax
26341 EXIT
26342 ENDPROC(__put_user_1)
26343
26344 ENTRY(__put_user_2)
26345 ENTER
26346 +
26347 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26348 + GET_THREAD_INFO(%_ASM_BX)
26349 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26350 sub $1,%_ASM_BX
26351 cmp %_ASM_BX,%_ASM_CX
26352 jae bad_put_user
26353 ASM_STAC
26354 -2: movw %ax,(%_ASM_CX)
26355 +
26356 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26357 + mov pax_user_shadow_base,%_ASM_BX
26358 + cmp %_ASM_BX,%_ASM_CX
26359 + jb 1234f
26360 + xor %ebx,%ebx
26361 +1234:
26362 +#endif
26363 +
26364 +#endif
26365 +
26366 +2: __copyuser_seg movw %ax,(_DEST)
26367 xor %eax,%eax
26368 EXIT
26369 ENDPROC(__put_user_2)
26370
26371 ENTRY(__put_user_4)
26372 ENTER
26373 +
26374 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26375 + GET_THREAD_INFO(%_ASM_BX)
26376 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26377 sub $3,%_ASM_BX
26378 cmp %_ASM_BX,%_ASM_CX
26379 jae bad_put_user
26380 ASM_STAC
26381 -3: movl %eax,(%_ASM_CX)
26382 +
26383 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26384 + mov pax_user_shadow_base,%_ASM_BX
26385 + cmp %_ASM_BX,%_ASM_CX
26386 + jb 1234f
26387 + xor %ebx,%ebx
26388 +1234:
26389 +#endif
26390 +
26391 +#endif
26392 +
26393 +3: __copyuser_seg movl %eax,(_DEST)
26394 xor %eax,%eax
26395 EXIT
26396 ENDPROC(__put_user_4)
26397
26398 ENTRY(__put_user_8)
26399 ENTER
26400 +
26401 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26402 + GET_THREAD_INFO(%_ASM_BX)
26403 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26404 sub $7,%_ASM_BX
26405 cmp %_ASM_BX,%_ASM_CX
26406 jae bad_put_user
26407 ASM_STAC
26408 -4: mov %_ASM_AX,(%_ASM_CX)
26409 +
26410 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26411 + mov pax_user_shadow_base,%_ASM_BX
26412 + cmp %_ASM_BX,%_ASM_CX
26413 + jb 1234f
26414 + xor %ebx,%ebx
26415 +1234:
26416 +#endif
26417 +
26418 +#endif
26419 +
26420 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26421 #ifdef CONFIG_X86_32
26422 -5: movl %edx,4(%_ASM_CX)
26423 +5: __copyuser_seg movl %edx,4(_DEST)
26424 #endif
26425 xor %eax,%eax
26426 EXIT
26427 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26428 index 1cad221..de671ee 100644
26429 --- a/arch/x86/lib/rwlock.S
26430 +++ b/arch/x86/lib/rwlock.S
26431 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26432 FRAME
26433 0: LOCK_PREFIX
26434 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26435 +
26436 +#ifdef CONFIG_PAX_REFCOUNT
26437 + jno 1234f
26438 + LOCK_PREFIX
26439 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26440 + int $4
26441 +1234:
26442 + _ASM_EXTABLE(1234b, 1234b)
26443 +#endif
26444 +
26445 1: rep; nop
26446 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26447 jne 1b
26448 LOCK_PREFIX
26449 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26450 +
26451 +#ifdef CONFIG_PAX_REFCOUNT
26452 + jno 1234f
26453 + LOCK_PREFIX
26454 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26455 + int $4
26456 +1234:
26457 + _ASM_EXTABLE(1234b, 1234b)
26458 +#endif
26459 +
26460 jnz 0b
26461 ENDFRAME
26462 + pax_force_retaddr
26463 ret
26464 CFI_ENDPROC
26465 END(__write_lock_failed)
26466 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26467 FRAME
26468 0: LOCK_PREFIX
26469 READ_LOCK_SIZE(inc) (%__lock_ptr)
26470 +
26471 +#ifdef CONFIG_PAX_REFCOUNT
26472 + jno 1234f
26473 + LOCK_PREFIX
26474 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26475 + int $4
26476 +1234:
26477 + _ASM_EXTABLE(1234b, 1234b)
26478 +#endif
26479 +
26480 1: rep; nop
26481 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26482 js 1b
26483 LOCK_PREFIX
26484 READ_LOCK_SIZE(dec) (%__lock_ptr)
26485 +
26486 +#ifdef CONFIG_PAX_REFCOUNT
26487 + jno 1234f
26488 + LOCK_PREFIX
26489 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26490 + int $4
26491 +1234:
26492 + _ASM_EXTABLE(1234b, 1234b)
26493 +#endif
26494 +
26495 js 0b
26496 ENDFRAME
26497 + pax_force_retaddr
26498 ret
26499 CFI_ENDPROC
26500 END(__read_lock_failed)
26501 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26502 index 5dff5f0..cadebf4 100644
26503 --- a/arch/x86/lib/rwsem.S
26504 +++ b/arch/x86/lib/rwsem.S
26505 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26506 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26507 CFI_RESTORE __ASM_REG(dx)
26508 restore_common_regs
26509 + pax_force_retaddr
26510 ret
26511 CFI_ENDPROC
26512 ENDPROC(call_rwsem_down_read_failed)
26513 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26514 movq %rax,%rdi
26515 call rwsem_down_write_failed
26516 restore_common_regs
26517 + pax_force_retaddr
26518 ret
26519 CFI_ENDPROC
26520 ENDPROC(call_rwsem_down_write_failed)
26521 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26522 movq %rax,%rdi
26523 call rwsem_wake
26524 restore_common_regs
26525 -1: ret
26526 +1: pax_force_retaddr
26527 + ret
26528 CFI_ENDPROC
26529 ENDPROC(call_rwsem_wake)
26530
26531 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26532 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26533 CFI_RESTORE __ASM_REG(dx)
26534 restore_common_regs
26535 + pax_force_retaddr
26536 ret
26537 CFI_ENDPROC
26538 ENDPROC(call_rwsem_downgrade_wake)
26539 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26540 index a63efd6..ccecad8 100644
26541 --- a/arch/x86/lib/thunk_64.S
26542 +++ b/arch/x86/lib/thunk_64.S
26543 @@ -8,6 +8,7 @@
26544 #include <linux/linkage.h>
26545 #include <asm/dwarf2.h>
26546 #include <asm/calling.h>
26547 +#include <asm/alternative-asm.h>
26548
26549 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26550 .macro THUNK name, func, put_ret_addr_in_rdi=0
26551 @@ -41,5 +42,6 @@
26552 SAVE_ARGS
26553 restore:
26554 RESTORE_ARGS
26555 + pax_force_retaddr
26556 ret
26557 CFI_ENDPROC
26558 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26559 index 3eb18ac..6890bc3 100644
26560 --- a/arch/x86/lib/usercopy_32.c
26561 +++ b/arch/x86/lib/usercopy_32.c
26562 @@ -42,11 +42,13 @@ do { \
26563 int __d0; \
26564 might_fault(); \
26565 __asm__ __volatile__( \
26566 + __COPYUSER_SET_ES \
26567 ASM_STAC "\n" \
26568 "0: rep; stosl\n" \
26569 " movl %2,%0\n" \
26570 "1: rep; stosb\n" \
26571 "2: " ASM_CLAC "\n" \
26572 + __COPYUSER_RESTORE_ES \
26573 ".section .fixup,\"ax\"\n" \
26574 "3: lea 0(%2,%0,4),%0\n" \
26575 " jmp 2b\n" \
26576 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26577
26578 #ifdef CONFIG_X86_INTEL_USERCOPY
26579 static unsigned long
26580 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26581 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26582 {
26583 int d0, d1;
26584 __asm__ __volatile__(
26585 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26586 " .align 2,0x90\n"
26587 "3: movl 0(%4), %%eax\n"
26588 "4: movl 4(%4), %%edx\n"
26589 - "5: movl %%eax, 0(%3)\n"
26590 - "6: movl %%edx, 4(%3)\n"
26591 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26592 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26593 "7: movl 8(%4), %%eax\n"
26594 "8: movl 12(%4),%%edx\n"
26595 - "9: movl %%eax, 8(%3)\n"
26596 - "10: movl %%edx, 12(%3)\n"
26597 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26598 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26599 "11: movl 16(%4), %%eax\n"
26600 "12: movl 20(%4), %%edx\n"
26601 - "13: movl %%eax, 16(%3)\n"
26602 - "14: movl %%edx, 20(%3)\n"
26603 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26604 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26605 "15: movl 24(%4), %%eax\n"
26606 "16: movl 28(%4), %%edx\n"
26607 - "17: movl %%eax, 24(%3)\n"
26608 - "18: movl %%edx, 28(%3)\n"
26609 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26610 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26611 "19: movl 32(%4), %%eax\n"
26612 "20: movl 36(%4), %%edx\n"
26613 - "21: movl %%eax, 32(%3)\n"
26614 - "22: movl %%edx, 36(%3)\n"
26615 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26616 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26617 "23: movl 40(%4), %%eax\n"
26618 "24: movl 44(%4), %%edx\n"
26619 - "25: movl %%eax, 40(%3)\n"
26620 - "26: movl %%edx, 44(%3)\n"
26621 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26622 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26623 "27: movl 48(%4), %%eax\n"
26624 "28: movl 52(%4), %%edx\n"
26625 - "29: movl %%eax, 48(%3)\n"
26626 - "30: movl %%edx, 52(%3)\n"
26627 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26628 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26629 "31: movl 56(%4), %%eax\n"
26630 "32: movl 60(%4), %%edx\n"
26631 - "33: movl %%eax, 56(%3)\n"
26632 - "34: movl %%edx, 60(%3)\n"
26633 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26634 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26635 " addl $-64, %0\n"
26636 " addl $64, %4\n"
26637 " addl $64, %3\n"
26638 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26639 " shrl $2, %0\n"
26640 " andl $3, %%eax\n"
26641 " cld\n"
26642 + __COPYUSER_SET_ES
26643 "99: rep; movsl\n"
26644 "36: movl %%eax, %0\n"
26645 "37: rep; movsb\n"
26646 "100:\n"
26647 + __COPYUSER_RESTORE_ES
26648 ".section .fixup,\"ax\"\n"
26649 "101: lea 0(%%eax,%0,4),%0\n"
26650 " jmp 100b\n"
26651 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26652 }
26653
26654 static unsigned long
26655 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26656 +{
26657 + int d0, d1;
26658 + __asm__ __volatile__(
26659 + " .align 2,0x90\n"
26660 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26661 + " cmpl $67, %0\n"
26662 + " jbe 3f\n"
26663 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26664 + " .align 2,0x90\n"
26665 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26666 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26667 + "5: movl %%eax, 0(%3)\n"
26668 + "6: movl %%edx, 4(%3)\n"
26669 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26670 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26671 + "9: movl %%eax, 8(%3)\n"
26672 + "10: movl %%edx, 12(%3)\n"
26673 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26674 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26675 + "13: movl %%eax, 16(%3)\n"
26676 + "14: movl %%edx, 20(%3)\n"
26677 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26678 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26679 + "17: movl %%eax, 24(%3)\n"
26680 + "18: movl %%edx, 28(%3)\n"
26681 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26682 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26683 + "21: movl %%eax, 32(%3)\n"
26684 + "22: movl %%edx, 36(%3)\n"
26685 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26686 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26687 + "25: movl %%eax, 40(%3)\n"
26688 + "26: movl %%edx, 44(%3)\n"
26689 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26690 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26691 + "29: movl %%eax, 48(%3)\n"
26692 + "30: movl %%edx, 52(%3)\n"
26693 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26694 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26695 + "33: movl %%eax, 56(%3)\n"
26696 + "34: movl %%edx, 60(%3)\n"
26697 + " addl $-64, %0\n"
26698 + " addl $64, %4\n"
26699 + " addl $64, %3\n"
26700 + " cmpl $63, %0\n"
26701 + " ja 1b\n"
26702 + "35: movl %0, %%eax\n"
26703 + " shrl $2, %0\n"
26704 + " andl $3, %%eax\n"
26705 + " cld\n"
26706 + "99: rep; "__copyuser_seg" movsl\n"
26707 + "36: movl %%eax, %0\n"
26708 + "37: rep; "__copyuser_seg" movsb\n"
26709 + "100:\n"
26710 + ".section .fixup,\"ax\"\n"
26711 + "101: lea 0(%%eax,%0,4),%0\n"
26712 + " jmp 100b\n"
26713 + ".previous\n"
26714 + _ASM_EXTABLE(1b,100b)
26715 + _ASM_EXTABLE(2b,100b)
26716 + _ASM_EXTABLE(3b,100b)
26717 + _ASM_EXTABLE(4b,100b)
26718 + _ASM_EXTABLE(5b,100b)
26719 + _ASM_EXTABLE(6b,100b)
26720 + _ASM_EXTABLE(7b,100b)
26721 + _ASM_EXTABLE(8b,100b)
26722 + _ASM_EXTABLE(9b,100b)
26723 + _ASM_EXTABLE(10b,100b)
26724 + _ASM_EXTABLE(11b,100b)
26725 + _ASM_EXTABLE(12b,100b)
26726 + _ASM_EXTABLE(13b,100b)
26727 + _ASM_EXTABLE(14b,100b)
26728 + _ASM_EXTABLE(15b,100b)
26729 + _ASM_EXTABLE(16b,100b)
26730 + _ASM_EXTABLE(17b,100b)
26731 + _ASM_EXTABLE(18b,100b)
26732 + _ASM_EXTABLE(19b,100b)
26733 + _ASM_EXTABLE(20b,100b)
26734 + _ASM_EXTABLE(21b,100b)
26735 + _ASM_EXTABLE(22b,100b)
26736 + _ASM_EXTABLE(23b,100b)
26737 + _ASM_EXTABLE(24b,100b)
26738 + _ASM_EXTABLE(25b,100b)
26739 + _ASM_EXTABLE(26b,100b)
26740 + _ASM_EXTABLE(27b,100b)
26741 + _ASM_EXTABLE(28b,100b)
26742 + _ASM_EXTABLE(29b,100b)
26743 + _ASM_EXTABLE(30b,100b)
26744 + _ASM_EXTABLE(31b,100b)
26745 + _ASM_EXTABLE(32b,100b)
26746 + _ASM_EXTABLE(33b,100b)
26747 + _ASM_EXTABLE(34b,100b)
26748 + _ASM_EXTABLE(35b,100b)
26749 + _ASM_EXTABLE(36b,100b)
26750 + _ASM_EXTABLE(37b,100b)
26751 + _ASM_EXTABLE(99b,101b)
26752 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26753 + : "1"(to), "2"(from), "0"(size)
26754 + : "eax", "edx", "memory");
26755 + return size;
26756 +}
26757 +
26758 +static unsigned long __size_overflow(3)
26759 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26760 {
26761 int d0, d1;
26762 __asm__ __volatile__(
26763 " .align 2,0x90\n"
26764 - "0: movl 32(%4), %%eax\n"
26765 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26766 " cmpl $67, %0\n"
26767 " jbe 2f\n"
26768 - "1: movl 64(%4), %%eax\n"
26769 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26770 " .align 2,0x90\n"
26771 - "2: movl 0(%4), %%eax\n"
26772 - "21: movl 4(%4), %%edx\n"
26773 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26774 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26775 " movl %%eax, 0(%3)\n"
26776 " movl %%edx, 4(%3)\n"
26777 - "3: movl 8(%4), %%eax\n"
26778 - "31: movl 12(%4),%%edx\n"
26779 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26780 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26781 " movl %%eax, 8(%3)\n"
26782 " movl %%edx, 12(%3)\n"
26783 - "4: movl 16(%4), %%eax\n"
26784 - "41: movl 20(%4), %%edx\n"
26785 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26786 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26787 " movl %%eax, 16(%3)\n"
26788 " movl %%edx, 20(%3)\n"
26789 - "10: movl 24(%4), %%eax\n"
26790 - "51: movl 28(%4), %%edx\n"
26791 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26792 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26793 " movl %%eax, 24(%3)\n"
26794 " movl %%edx, 28(%3)\n"
26795 - "11: movl 32(%4), %%eax\n"
26796 - "61: movl 36(%4), %%edx\n"
26797 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26798 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26799 " movl %%eax, 32(%3)\n"
26800 " movl %%edx, 36(%3)\n"
26801 - "12: movl 40(%4), %%eax\n"
26802 - "71: movl 44(%4), %%edx\n"
26803 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26804 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26805 " movl %%eax, 40(%3)\n"
26806 " movl %%edx, 44(%3)\n"
26807 - "13: movl 48(%4), %%eax\n"
26808 - "81: movl 52(%4), %%edx\n"
26809 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26810 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26811 " movl %%eax, 48(%3)\n"
26812 " movl %%edx, 52(%3)\n"
26813 - "14: movl 56(%4), %%eax\n"
26814 - "91: movl 60(%4), %%edx\n"
26815 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26816 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26817 " movl %%eax, 56(%3)\n"
26818 " movl %%edx, 60(%3)\n"
26819 " addl $-64, %0\n"
26820 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26821 " shrl $2, %0\n"
26822 " andl $3, %%eax\n"
26823 " cld\n"
26824 - "6: rep; movsl\n"
26825 + "6: rep; "__copyuser_seg" movsl\n"
26826 " movl %%eax,%0\n"
26827 - "7: rep; movsb\n"
26828 + "7: rep; "__copyuser_seg" movsb\n"
26829 "8:\n"
26830 ".section .fixup,\"ax\"\n"
26831 "9: lea 0(%%eax,%0,4),%0\n"
26832 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26833 * hyoshiok@miraclelinux.com
26834 */
26835
26836 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26837 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26838 const void __user *from, unsigned long size)
26839 {
26840 int d0, d1;
26841
26842 __asm__ __volatile__(
26843 " .align 2,0x90\n"
26844 - "0: movl 32(%4), %%eax\n"
26845 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26846 " cmpl $67, %0\n"
26847 " jbe 2f\n"
26848 - "1: movl 64(%4), %%eax\n"
26849 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26850 " .align 2,0x90\n"
26851 - "2: movl 0(%4), %%eax\n"
26852 - "21: movl 4(%4), %%edx\n"
26853 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26854 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26855 " movnti %%eax, 0(%3)\n"
26856 " movnti %%edx, 4(%3)\n"
26857 - "3: movl 8(%4), %%eax\n"
26858 - "31: movl 12(%4),%%edx\n"
26859 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26860 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26861 " movnti %%eax, 8(%3)\n"
26862 " movnti %%edx, 12(%3)\n"
26863 - "4: movl 16(%4), %%eax\n"
26864 - "41: movl 20(%4), %%edx\n"
26865 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26866 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26867 " movnti %%eax, 16(%3)\n"
26868 " movnti %%edx, 20(%3)\n"
26869 - "10: movl 24(%4), %%eax\n"
26870 - "51: movl 28(%4), %%edx\n"
26871 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26872 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26873 " movnti %%eax, 24(%3)\n"
26874 " movnti %%edx, 28(%3)\n"
26875 - "11: movl 32(%4), %%eax\n"
26876 - "61: movl 36(%4), %%edx\n"
26877 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26878 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26879 " movnti %%eax, 32(%3)\n"
26880 " movnti %%edx, 36(%3)\n"
26881 - "12: movl 40(%4), %%eax\n"
26882 - "71: movl 44(%4), %%edx\n"
26883 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26884 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26885 " movnti %%eax, 40(%3)\n"
26886 " movnti %%edx, 44(%3)\n"
26887 - "13: movl 48(%4), %%eax\n"
26888 - "81: movl 52(%4), %%edx\n"
26889 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26890 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26891 " movnti %%eax, 48(%3)\n"
26892 " movnti %%edx, 52(%3)\n"
26893 - "14: movl 56(%4), %%eax\n"
26894 - "91: movl 60(%4), %%edx\n"
26895 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26896 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26897 " movnti %%eax, 56(%3)\n"
26898 " movnti %%edx, 60(%3)\n"
26899 " addl $-64, %0\n"
26900 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26901 " shrl $2, %0\n"
26902 " andl $3, %%eax\n"
26903 " cld\n"
26904 - "6: rep; movsl\n"
26905 + "6: rep; "__copyuser_seg" movsl\n"
26906 " movl %%eax,%0\n"
26907 - "7: rep; movsb\n"
26908 + "7: rep; "__copyuser_seg" movsb\n"
26909 "8:\n"
26910 ".section .fixup,\"ax\"\n"
26911 "9: lea 0(%%eax,%0,4),%0\n"
26912 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26913 return size;
26914 }
26915
26916 -static unsigned long __copy_user_intel_nocache(void *to,
26917 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26918 const void __user *from, unsigned long size)
26919 {
26920 int d0, d1;
26921
26922 __asm__ __volatile__(
26923 " .align 2,0x90\n"
26924 - "0: movl 32(%4), %%eax\n"
26925 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26926 " cmpl $67, %0\n"
26927 " jbe 2f\n"
26928 - "1: movl 64(%4), %%eax\n"
26929 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26930 " .align 2,0x90\n"
26931 - "2: movl 0(%4), %%eax\n"
26932 - "21: movl 4(%4), %%edx\n"
26933 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26934 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26935 " movnti %%eax, 0(%3)\n"
26936 " movnti %%edx, 4(%3)\n"
26937 - "3: movl 8(%4), %%eax\n"
26938 - "31: movl 12(%4),%%edx\n"
26939 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26940 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26941 " movnti %%eax, 8(%3)\n"
26942 " movnti %%edx, 12(%3)\n"
26943 - "4: movl 16(%4), %%eax\n"
26944 - "41: movl 20(%4), %%edx\n"
26945 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26946 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26947 " movnti %%eax, 16(%3)\n"
26948 " movnti %%edx, 20(%3)\n"
26949 - "10: movl 24(%4), %%eax\n"
26950 - "51: movl 28(%4), %%edx\n"
26951 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26952 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26953 " movnti %%eax, 24(%3)\n"
26954 " movnti %%edx, 28(%3)\n"
26955 - "11: movl 32(%4), %%eax\n"
26956 - "61: movl 36(%4), %%edx\n"
26957 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26958 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26959 " movnti %%eax, 32(%3)\n"
26960 " movnti %%edx, 36(%3)\n"
26961 - "12: movl 40(%4), %%eax\n"
26962 - "71: movl 44(%4), %%edx\n"
26963 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26964 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26965 " movnti %%eax, 40(%3)\n"
26966 " movnti %%edx, 44(%3)\n"
26967 - "13: movl 48(%4), %%eax\n"
26968 - "81: movl 52(%4), %%edx\n"
26969 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26970 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26971 " movnti %%eax, 48(%3)\n"
26972 " movnti %%edx, 52(%3)\n"
26973 - "14: movl 56(%4), %%eax\n"
26974 - "91: movl 60(%4), %%edx\n"
26975 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26976 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26977 " movnti %%eax, 56(%3)\n"
26978 " movnti %%edx, 60(%3)\n"
26979 " addl $-64, %0\n"
26980 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26981 " shrl $2, %0\n"
26982 " andl $3, %%eax\n"
26983 " cld\n"
26984 - "6: rep; movsl\n"
26985 + "6: rep; "__copyuser_seg" movsl\n"
26986 " movl %%eax,%0\n"
26987 - "7: rep; movsb\n"
26988 + "7: rep; "__copyuser_seg" movsb\n"
26989 "8:\n"
26990 ".section .fixup,\"ax\"\n"
26991 "9: lea 0(%%eax,%0,4),%0\n"
26992 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26993 */
26994 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26995 unsigned long size);
26996 -unsigned long __copy_user_intel(void __user *to, const void *from,
26997 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26998 + unsigned long size);
26999 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27000 unsigned long size);
27001 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27002 const void __user *from, unsigned long size);
27003 #endif /* CONFIG_X86_INTEL_USERCOPY */
27004
27005 /* Generic arbitrary sized copy. */
27006 -#define __copy_user(to, from, size) \
27007 +#define __copy_user(to, from, size, prefix, set, restore) \
27008 do { \
27009 int __d0, __d1, __d2; \
27010 __asm__ __volatile__( \
27011 + set \
27012 " cmp $7,%0\n" \
27013 " jbe 1f\n" \
27014 " movl %1,%0\n" \
27015 " negl %0\n" \
27016 " andl $7,%0\n" \
27017 " subl %0,%3\n" \
27018 - "4: rep; movsb\n" \
27019 + "4: rep; "prefix"movsb\n" \
27020 " movl %3,%0\n" \
27021 " shrl $2,%0\n" \
27022 " andl $3,%3\n" \
27023 " .align 2,0x90\n" \
27024 - "0: rep; movsl\n" \
27025 + "0: rep; "prefix"movsl\n" \
27026 " movl %3,%0\n" \
27027 - "1: rep; movsb\n" \
27028 + "1: rep; "prefix"movsb\n" \
27029 "2:\n" \
27030 + restore \
27031 ".section .fixup,\"ax\"\n" \
27032 "5: addl %3,%0\n" \
27033 " jmp 2b\n" \
27034 @@ -538,14 +650,14 @@ do { \
27035 " negl %0\n" \
27036 " andl $7,%0\n" \
27037 " subl %0,%3\n" \
27038 - "4: rep; movsb\n" \
27039 + "4: rep; "__copyuser_seg"movsb\n" \
27040 " movl %3,%0\n" \
27041 " shrl $2,%0\n" \
27042 " andl $3,%3\n" \
27043 " .align 2,0x90\n" \
27044 - "0: rep; movsl\n" \
27045 + "0: rep; "__copyuser_seg"movsl\n" \
27046 " movl %3,%0\n" \
27047 - "1: rep; movsb\n" \
27048 + "1: rep; "__copyuser_seg"movsb\n" \
27049 "2:\n" \
27050 ".section .fixup,\"ax\"\n" \
27051 "5: addl %3,%0\n" \
27052 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27053 {
27054 stac();
27055 if (movsl_is_ok(to, from, n))
27056 - __copy_user(to, from, n);
27057 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27058 else
27059 - n = __copy_user_intel(to, from, n);
27060 + n = __generic_copy_to_user_intel(to, from, n);
27061 clac();
27062 return n;
27063 }
27064 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27065 {
27066 stac();
27067 if (movsl_is_ok(to, from, n))
27068 - __copy_user(to, from, n);
27069 + __copy_user(to, from, n, __copyuser_seg, "", "");
27070 else
27071 - n = __copy_user_intel((void __user *)to,
27072 - (const void *)from, n);
27073 + n = __generic_copy_from_user_intel(to, from, n);
27074 clac();
27075 return n;
27076 }
27077 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27078 if (n > 64 && cpu_has_xmm2)
27079 n = __copy_user_intel_nocache(to, from, n);
27080 else
27081 - __copy_user(to, from, n);
27082 + __copy_user(to, from, n, __copyuser_seg, "", "");
27083 #else
27084 - __copy_user(to, from, n);
27085 + __copy_user(to, from, n, __copyuser_seg, "", "");
27086 #endif
27087 clac();
27088 return n;
27089 }
27090 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27091
27092 -/**
27093 - * copy_to_user: - Copy a block of data into user space.
27094 - * @to: Destination address, in user space.
27095 - * @from: Source address, in kernel space.
27096 - * @n: Number of bytes to copy.
27097 - *
27098 - * Context: User context only. This function may sleep.
27099 - *
27100 - * Copy data from kernel space to user space.
27101 - *
27102 - * Returns number of bytes that could not be copied.
27103 - * On success, this will be zero.
27104 - */
27105 -unsigned long
27106 -copy_to_user(void __user *to, const void *from, unsigned long n)
27107 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27108 +void __set_fs(mm_segment_t x)
27109 {
27110 - if (access_ok(VERIFY_WRITE, to, n))
27111 - n = __copy_to_user(to, from, n);
27112 - return n;
27113 + switch (x.seg) {
27114 + case 0:
27115 + loadsegment(gs, 0);
27116 + break;
27117 + case TASK_SIZE_MAX:
27118 + loadsegment(gs, __USER_DS);
27119 + break;
27120 + case -1UL:
27121 + loadsegment(gs, __KERNEL_DS);
27122 + break;
27123 + default:
27124 + BUG();
27125 + }
27126 }
27127 -EXPORT_SYMBOL(copy_to_user);
27128 +EXPORT_SYMBOL(__set_fs);
27129
27130 -/**
27131 - * copy_from_user: - Copy a block of data from user space.
27132 - * @to: Destination address, in kernel space.
27133 - * @from: Source address, in user space.
27134 - * @n: Number of bytes to copy.
27135 - *
27136 - * Context: User context only. This function may sleep.
27137 - *
27138 - * Copy data from user space to kernel space.
27139 - *
27140 - * Returns number of bytes that could not be copied.
27141 - * On success, this will be zero.
27142 - *
27143 - * If some data could not be copied, this function will pad the copied
27144 - * data to the requested size using zero bytes.
27145 - */
27146 -unsigned long
27147 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27148 +void set_fs(mm_segment_t x)
27149 {
27150 - if (access_ok(VERIFY_READ, from, n))
27151 - n = __copy_from_user(to, from, n);
27152 - else
27153 - memset(to, 0, n);
27154 - return n;
27155 + current_thread_info()->addr_limit = x;
27156 + __set_fs(x);
27157 }
27158 -EXPORT_SYMBOL(_copy_from_user);
27159 +EXPORT_SYMBOL(set_fs);
27160 +#endif
27161 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27162 index 906fea3..5646695 100644
27163 --- a/arch/x86/lib/usercopy_64.c
27164 +++ b/arch/x86/lib/usercopy_64.c
27165 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27166 _ASM_EXTABLE(0b,3b)
27167 _ASM_EXTABLE(1b,2b)
27168 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27169 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27170 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27171 [zero] "r" (0UL), [eight] "r" (8UL));
27172 clac();
27173 return size;
27174 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27175 }
27176 EXPORT_SYMBOL(clear_user);
27177
27178 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27179 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27180 {
27181 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27182 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27183 - }
27184 - return len;
27185 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27186 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27187 + return len;
27188 }
27189 EXPORT_SYMBOL(copy_in_user);
27190
27191 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27192 * it is not necessary to optimize tail handling.
27193 */
27194 unsigned long
27195 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27196 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27197 {
27198 char c;
27199 unsigned zero_len;
27200 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27201 index 903ec1e..c4166b2 100644
27202 --- a/arch/x86/mm/extable.c
27203 +++ b/arch/x86/mm/extable.c
27204 @@ -6,12 +6,24 @@
27205 static inline unsigned long
27206 ex_insn_addr(const struct exception_table_entry *x)
27207 {
27208 - return (unsigned long)&x->insn + x->insn;
27209 + unsigned long reloc = 0;
27210 +
27211 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27212 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27213 +#endif
27214 +
27215 + return (unsigned long)&x->insn + x->insn + reloc;
27216 }
27217 static inline unsigned long
27218 ex_fixup_addr(const struct exception_table_entry *x)
27219 {
27220 - return (unsigned long)&x->fixup + x->fixup;
27221 + unsigned long reloc = 0;
27222 +
27223 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27224 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27225 +#endif
27226 +
27227 + return (unsigned long)&x->fixup + x->fixup + reloc;
27228 }
27229
27230 int fixup_exception(struct pt_regs *regs)
27231 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27232 unsigned long new_ip;
27233
27234 #ifdef CONFIG_PNPBIOS
27235 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27236 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27237 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27238 extern u32 pnp_bios_is_utter_crap;
27239 pnp_bios_is_utter_crap = 1;
27240 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27241 i += 4;
27242 p->fixup -= i;
27243 i += 4;
27244 +
27245 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27246 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27247 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27248 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27249 +#endif
27250 +
27251 }
27252 }
27253
27254 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27255 index 654be4a..d36985f 100644
27256 --- a/arch/x86/mm/fault.c
27257 +++ b/arch/x86/mm/fault.c
27258 @@ -14,11 +14,18 @@
27259 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27260 #include <linux/prefetch.h> /* prefetchw */
27261 #include <linux/context_tracking.h> /* exception_enter(), ... */
27262 +#include <linux/unistd.h>
27263 +#include <linux/compiler.h>
27264
27265 #include <asm/traps.h> /* dotraplinkage, ... */
27266 #include <asm/pgalloc.h> /* pgd_*(), ... */
27267 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27268 #include <asm/fixmap.h> /* VSYSCALL_START */
27269 +#include <asm/tlbflush.h>
27270 +
27271 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27272 +#include <asm/stacktrace.h>
27273 +#endif
27274
27275 /*
27276 * Page fault error code bits:
27277 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27278 int ret = 0;
27279
27280 /* kprobe_running() needs smp_processor_id() */
27281 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27282 + if (kprobes_built_in() && !user_mode(regs)) {
27283 preempt_disable();
27284 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27285 ret = 1;
27286 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27287 return !instr_lo || (instr_lo>>1) == 1;
27288 case 0x00:
27289 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27290 - if (probe_kernel_address(instr, opcode))
27291 + if (user_mode(regs)) {
27292 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27293 + return 0;
27294 + } else if (probe_kernel_address(instr, opcode))
27295 return 0;
27296
27297 *prefetch = (instr_lo == 0xF) &&
27298 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27299 while (instr < max_instr) {
27300 unsigned char opcode;
27301
27302 - if (probe_kernel_address(instr, opcode))
27303 + if (user_mode(regs)) {
27304 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27305 + break;
27306 + } else if (probe_kernel_address(instr, opcode))
27307 break;
27308
27309 instr++;
27310 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27311 force_sig_info(si_signo, &info, tsk);
27312 }
27313
27314 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27315 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27316 +#endif
27317 +
27318 +#ifdef CONFIG_PAX_EMUTRAMP
27319 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27320 +#endif
27321 +
27322 +#ifdef CONFIG_PAX_PAGEEXEC
27323 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27324 +{
27325 + pgd_t *pgd;
27326 + pud_t *pud;
27327 + pmd_t *pmd;
27328 +
27329 + pgd = pgd_offset(mm, address);
27330 + if (!pgd_present(*pgd))
27331 + return NULL;
27332 + pud = pud_offset(pgd, address);
27333 + if (!pud_present(*pud))
27334 + return NULL;
27335 + pmd = pmd_offset(pud, address);
27336 + if (!pmd_present(*pmd))
27337 + return NULL;
27338 + return pmd;
27339 +}
27340 +#endif
27341 +
27342 DEFINE_SPINLOCK(pgd_lock);
27343 LIST_HEAD(pgd_list);
27344
27345 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27346 for (address = VMALLOC_START & PMD_MASK;
27347 address >= TASK_SIZE && address < FIXADDR_TOP;
27348 address += PMD_SIZE) {
27349 +
27350 +#ifdef CONFIG_PAX_PER_CPU_PGD
27351 + unsigned long cpu;
27352 +#else
27353 struct page *page;
27354 +#endif
27355
27356 spin_lock(&pgd_lock);
27357 +
27358 +#ifdef CONFIG_PAX_PER_CPU_PGD
27359 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27360 + pgd_t *pgd = get_cpu_pgd(cpu);
27361 + pmd_t *ret;
27362 +#else
27363 list_for_each_entry(page, &pgd_list, lru) {
27364 + pgd_t *pgd;
27365 spinlock_t *pgt_lock;
27366 pmd_t *ret;
27367
27368 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27369 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27370
27371 spin_lock(pgt_lock);
27372 - ret = vmalloc_sync_one(page_address(page), address);
27373 + pgd = page_address(page);
27374 +#endif
27375 +
27376 + ret = vmalloc_sync_one(pgd, address);
27377 +
27378 +#ifndef CONFIG_PAX_PER_CPU_PGD
27379 spin_unlock(pgt_lock);
27380 +#endif
27381
27382 if (!ret)
27383 break;
27384 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27385 * an interrupt in the middle of a task switch..
27386 */
27387 pgd_paddr = read_cr3();
27388 +
27389 +#ifdef CONFIG_PAX_PER_CPU_PGD
27390 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27391 +#endif
27392 +
27393 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27394 if (!pmd_k)
27395 return -1;
27396 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27397 * happen within a race in page table update. In the later
27398 * case just flush:
27399 */
27400 +
27401 +#ifdef CONFIG_PAX_PER_CPU_PGD
27402 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27403 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27404 +#else
27405 pgd = pgd_offset(current->active_mm, address);
27406 +#endif
27407 +
27408 pgd_ref = pgd_offset_k(address);
27409 if (pgd_none(*pgd_ref))
27410 return -1;
27411 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27412 static int is_errata100(struct pt_regs *regs, unsigned long address)
27413 {
27414 #ifdef CONFIG_X86_64
27415 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27416 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27417 return 1;
27418 #endif
27419 return 0;
27420 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27421 }
27422
27423 static const char nx_warning[] = KERN_CRIT
27424 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27425 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27426
27427 static void
27428 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27429 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27430 if (!oops_may_print())
27431 return;
27432
27433 - if (error_code & PF_INSTR) {
27434 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27435 unsigned int level;
27436
27437 pte_t *pte = lookup_address(address, &level);
27438
27439 if (pte && pte_present(*pte) && !pte_exec(*pte))
27440 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27441 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27442 }
27443
27444 +#ifdef CONFIG_PAX_KERNEXEC
27445 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27446 + if (current->signal->curr_ip)
27447 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27448 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27449 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27450 + else
27451 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27452 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27453 + }
27454 +#endif
27455 +
27456 printk(KERN_ALERT "BUG: unable to handle kernel ");
27457 if (address < PAGE_SIZE)
27458 printk(KERN_CONT "NULL pointer dereference");
27459 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27460 return;
27461 }
27462 #endif
27463 +
27464 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27465 + if (pax_is_fetch_fault(regs, error_code, address)) {
27466 +
27467 +#ifdef CONFIG_PAX_EMUTRAMP
27468 + switch (pax_handle_fetch_fault(regs)) {
27469 + case 2:
27470 + return;
27471 + }
27472 +#endif
27473 +
27474 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27475 + do_group_exit(SIGKILL);
27476 + }
27477 +#endif
27478 +
27479 /* Kernel addresses are always protection faults: */
27480 if (address >= TASK_SIZE)
27481 error_code |= PF_PROT;
27482 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27483 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27484 printk(KERN_ERR
27485 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27486 - tsk->comm, tsk->pid, address);
27487 + tsk->comm, task_pid_nr(tsk), address);
27488 code = BUS_MCEERR_AR;
27489 }
27490 #endif
27491 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27492 return 1;
27493 }
27494
27495 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27496 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27497 +{
27498 + pte_t *pte;
27499 + pmd_t *pmd;
27500 + spinlock_t *ptl;
27501 + unsigned char pte_mask;
27502 +
27503 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27504 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27505 + return 0;
27506 +
27507 + /* PaX: it's our fault, let's handle it if we can */
27508 +
27509 + /* PaX: take a look at read faults before acquiring any locks */
27510 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27511 + /* instruction fetch attempt from a protected page in user mode */
27512 + up_read(&mm->mmap_sem);
27513 +
27514 +#ifdef CONFIG_PAX_EMUTRAMP
27515 + switch (pax_handle_fetch_fault(regs)) {
27516 + case 2:
27517 + return 1;
27518 + }
27519 +#endif
27520 +
27521 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27522 + do_group_exit(SIGKILL);
27523 + }
27524 +
27525 + pmd = pax_get_pmd(mm, address);
27526 + if (unlikely(!pmd))
27527 + return 0;
27528 +
27529 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27530 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27531 + pte_unmap_unlock(pte, ptl);
27532 + return 0;
27533 + }
27534 +
27535 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27536 + /* write attempt to a protected page in user mode */
27537 + pte_unmap_unlock(pte, ptl);
27538 + return 0;
27539 + }
27540 +
27541 +#ifdef CONFIG_SMP
27542 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27543 +#else
27544 + if (likely(address > get_limit(regs->cs)))
27545 +#endif
27546 + {
27547 + set_pte(pte, pte_mkread(*pte));
27548 + __flush_tlb_one(address);
27549 + pte_unmap_unlock(pte, ptl);
27550 + up_read(&mm->mmap_sem);
27551 + return 1;
27552 + }
27553 +
27554 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27555 +
27556 + /*
27557 + * PaX: fill DTLB with user rights and retry
27558 + */
27559 + __asm__ __volatile__ (
27560 + "orb %2,(%1)\n"
27561 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27562 +/*
27563 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27564 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27565 + * page fault when examined during a TLB load attempt. this is true not only
27566 + * for PTEs holding a non-present entry but also present entries that will
27567 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27568 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27569 + * for our target pages since their PTEs are simply not in the TLBs at all.
27570 +
27571 + * the best thing in omitting it is that we gain around 15-20% speed in the
27572 + * fast path of the page fault handler and can get rid of tracing since we
27573 + * can no longer flush unintended entries.
27574 + */
27575 + "invlpg (%0)\n"
27576 +#endif
27577 + __copyuser_seg"testb $0,(%0)\n"
27578 + "xorb %3,(%1)\n"
27579 + :
27580 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27581 + : "memory", "cc");
27582 + pte_unmap_unlock(pte, ptl);
27583 + up_read(&mm->mmap_sem);
27584 + return 1;
27585 +}
27586 +#endif
27587 +
27588 /*
27589 * Handle a spurious fault caused by a stale TLB entry.
27590 *
27591 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27592 static inline int
27593 access_error(unsigned long error_code, struct vm_area_struct *vma)
27594 {
27595 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27596 + return 1;
27597 +
27598 if (error_code & PF_WRITE) {
27599 /* write, present and write, not present: */
27600 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27601 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27602 if (error_code & PF_USER)
27603 return false;
27604
27605 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27606 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27607 return false;
27608
27609 return true;
27610 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27611 {
27612 struct vm_area_struct *vma;
27613 struct task_struct *tsk;
27614 - unsigned long address;
27615 struct mm_struct *mm;
27616 int fault;
27617 int write = error_code & PF_WRITE;
27618 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27619 (write ? FAULT_FLAG_WRITE : 0);
27620
27621 - tsk = current;
27622 - mm = tsk->mm;
27623 -
27624 /* Get the faulting address: */
27625 - address = read_cr2();
27626 + unsigned long address = read_cr2();
27627 +
27628 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27629 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27630 + if (!search_exception_tables(regs->ip)) {
27631 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27632 + bad_area_nosemaphore(regs, error_code, address);
27633 + return;
27634 + }
27635 + if (address < pax_user_shadow_base) {
27636 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27637 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27638 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27639 + } else
27640 + address -= pax_user_shadow_base;
27641 + }
27642 +#endif
27643 +
27644 + tsk = current;
27645 + mm = tsk->mm;
27646
27647 /*
27648 * Detect and handle instructions that would cause a page fault for
27649 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27650 * User-mode registers count as a user access even for any
27651 * potential system fault or CPU buglet:
27652 */
27653 - if (user_mode_vm(regs)) {
27654 + if (user_mode(regs)) {
27655 local_irq_enable();
27656 error_code |= PF_USER;
27657 } else {
27658 @@ -1142,6 +1352,11 @@ retry:
27659 might_sleep();
27660 }
27661
27662 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27663 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27664 + return;
27665 +#endif
27666 +
27667 vma = find_vma(mm, address);
27668 if (unlikely(!vma)) {
27669 bad_area(regs, error_code, address);
27670 @@ -1153,18 +1368,24 @@ retry:
27671 bad_area(regs, error_code, address);
27672 return;
27673 }
27674 - if (error_code & PF_USER) {
27675 - /*
27676 - * Accessing the stack below %sp is always a bug.
27677 - * The large cushion allows instructions like enter
27678 - * and pusha to work. ("enter $65535, $31" pushes
27679 - * 32 pointers and then decrements %sp by 65535.)
27680 - */
27681 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27682 - bad_area(regs, error_code, address);
27683 - return;
27684 - }
27685 + /*
27686 + * Accessing the stack below %sp is always a bug.
27687 + * The large cushion allows instructions like enter
27688 + * and pusha to work. ("enter $65535, $31" pushes
27689 + * 32 pointers and then decrements %sp by 65535.)
27690 + */
27691 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27692 + bad_area(regs, error_code, address);
27693 + return;
27694 }
27695 +
27696 +#ifdef CONFIG_PAX_SEGMEXEC
27697 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27698 + bad_area(regs, error_code, address);
27699 + return;
27700 + }
27701 +#endif
27702 +
27703 if (unlikely(expand_stack(vma, address))) {
27704 bad_area(regs, error_code, address);
27705 return;
27706 @@ -1230,3 +1451,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27707 __do_page_fault(regs, error_code);
27708 exception_exit(prev_state);
27709 }
27710 +
27711 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27712 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27713 +{
27714 + struct mm_struct *mm = current->mm;
27715 + unsigned long ip = regs->ip;
27716 +
27717 + if (v8086_mode(regs))
27718 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27719 +
27720 +#ifdef CONFIG_PAX_PAGEEXEC
27721 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27722 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27723 + return true;
27724 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27725 + return true;
27726 + return false;
27727 + }
27728 +#endif
27729 +
27730 +#ifdef CONFIG_PAX_SEGMEXEC
27731 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27732 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27733 + return true;
27734 + return false;
27735 + }
27736 +#endif
27737 +
27738 + return false;
27739 +}
27740 +#endif
27741 +
27742 +#ifdef CONFIG_PAX_EMUTRAMP
27743 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27744 +{
27745 + int err;
27746 +
27747 + do { /* PaX: libffi trampoline emulation */
27748 + unsigned char mov, jmp;
27749 + unsigned int addr1, addr2;
27750 +
27751 +#ifdef CONFIG_X86_64
27752 + if ((regs->ip + 9) >> 32)
27753 + break;
27754 +#endif
27755 +
27756 + err = get_user(mov, (unsigned char __user *)regs->ip);
27757 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27758 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27759 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27760 +
27761 + if (err)
27762 + break;
27763 +
27764 + if (mov == 0xB8 && jmp == 0xE9) {
27765 + regs->ax = addr1;
27766 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27767 + return 2;
27768 + }
27769 + } while (0);
27770 +
27771 + do { /* PaX: gcc trampoline emulation #1 */
27772 + unsigned char mov1, mov2;
27773 + unsigned short jmp;
27774 + unsigned int addr1, addr2;
27775 +
27776 +#ifdef CONFIG_X86_64
27777 + if ((regs->ip + 11) >> 32)
27778 + break;
27779 +#endif
27780 +
27781 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27782 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27783 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27784 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27785 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27786 +
27787 + if (err)
27788 + break;
27789 +
27790 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27791 + regs->cx = addr1;
27792 + regs->ax = addr2;
27793 + regs->ip = addr2;
27794 + return 2;
27795 + }
27796 + } while (0);
27797 +
27798 + do { /* PaX: gcc trampoline emulation #2 */
27799 + unsigned char mov, jmp;
27800 + unsigned int addr1, addr2;
27801 +
27802 +#ifdef CONFIG_X86_64
27803 + if ((regs->ip + 9) >> 32)
27804 + break;
27805 +#endif
27806 +
27807 + err = get_user(mov, (unsigned char __user *)regs->ip);
27808 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27809 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27810 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27811 +
27812 + if (err)
27813 + break;
27814 +
27815 + if (mov == 0xB9 && jmp == 0xE9) {
27816 + regs->cx = addr1;
27817 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27818 + return 2;
27819 + }
27820 + } while (0);
27821 +
27822 + return 1; /* PaX in action */
27823 +}
27824 +
27825 +#ifdef CONFIG_X86_64
27826 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27827 +{
27828 + int err;
27829 +
27830 + do { /* PaX: libffi trampoline emulation */
27831 + unsigned short mov1, mov2, jmp1;
27832 + unsigned char stcclc, jmp2;
27833 + unsigned long addr1, addr2;
27834 +
27835 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27836 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27837 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27838 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27839 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27840 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27841 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27842 +
27843 + if (err)
27844 + break;
27845 +
27846 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27847 + regs->r11 = addr1;
27848 + regs->r10 = addr2;
27849 + if (stcclc == 0xF8)
27850 + regs->flags &= ~X86_EFLAGS_CF;
27851 + else
27852 + regs->flags |= X86_EFLAGS_CF;
27853 + regs->ip = addr1;
27854 + return 2;
27855 + }
27856 + } while (0);
27857 +
27858 + do { /* PaX: gcc trampoline emulation #1 */
27859 + unsigned short mov1, mov2, jmp1;
27860 + unsigned char jmp2;
27861 + unsigned int addr1;
27862 + unsigned long addr2;
27863 +
27864 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27865 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27866 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27867 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27868 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27869 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27870 +
27871 + if (err)
27872 + break;
27873 +
27874 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27875 + regs->r11 = addr1;
27876 + regs->r10 = addr2;
27877 + regs->ip = addr1;
27878 + return 2;
27879 + }
27880 + } while (0);
27881 +
27882 + do { /* PaX: gcc trampoline emulation #2 */
27883 + unsigned short mov1, mov2, jmp1;
27884 + unsigned char jmp2;
27885 + unsigned long addr1, addr2;
27886 +
27887 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27888 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27889 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27890 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27891 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27892 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27893 +
27894 + if (err)
27895 + break;
27896 +
27897 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27898 + regs->r11 = addr1;
27899 + regs->r10 = addr2;
27900 + regs->ip = addr1;
27901 + return 2;
27902 + }
27903 + } while (0);
27904 +
27905 + return 1; /* PaX in action */
27906 +}
27907 +#endif
27908 +
27909 +/*
27910 + * PaX: decide what to do with offenders (regs->ip = fault address)
27911 + *
27912 + * returns 1 when task should be killed
27913 + * 2 when gcc trampoline was detected
27914 + */
27915 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27916 +{
27917 + if (v8086_mode(regs))
27918 + return 1;
27919 +
27920 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27921 + return 1;
27922 +
27923 +#ifdef CONFIG_X86_32
27924 + return pax_handle_fetch_fault_32(regs);
27925 +#else
27926 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27927 + return pax_handle_fetch_fault_32(regs);
27928 + else
27929 + return pax_handle_fetch_fault_64(regs);
27930 +#endif
27931 +}
27932 +#endif
27933 +
27934 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27935 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27936 +{
27937 + long i;
27938 +
27939 + printk(KERN_ERR "PAX: bytes at PC: ");
27940 + for (i = 0; i < 20; i++) {
27941 + unsigned char c;
27942 + if (get_user(c, (unsigned char __force_user *)pc+i))
27943 + printk(KERN_CONT "?? ");
27944 + else
27945 + printk(KERN_CONT "%02x ", c);
27946 + }
27947 + printk("\n");
27948 +
27949 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27950 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27951 + unsigned long c;
27952 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27953 +#ifdef CONFIG_X86_32
27954 + printk(KERN_CONT "???????? ");
27955 +#else
27956 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27957 + printk(KERN_CONT "???????? ???????? ");
27958 + else
27959 + printk(KERN_CONT "???????????????? ");
27960 +#endif
27961 + } else {
27962 +#ifdef CONFIG_X86_64
27963 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27964 + printk(KERN_CONT "%08x ", (unsigned int)c);
27965 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27966 + } else
27967 +#endif
27968 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27969 + }
27970 + }
27971 + printk("\n");
27972 +}
27973 +#endif
27974 +
27975 +/**
27976 + * probe_kernel_write(): safely attempt to write to a location
27977 + * @dst: address to write to
27978 + * @src: pointer to the data that shall be written
27979 + * @size: size of the data chunk
27980 + *
27981 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27982 + * happens, handle that and return -EFAULT.
27983 + */
27984 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27985 +{
27986 + long ret;
27987 + mm_segment_t old_fs = get_fs();
27988 +
27989 + set_fs(KERNEL_DS);
27990 + pagefault_disable();
27991 + pax_open_kernel();
27992 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27993 + pax_close_kernel();
27994 + pagefault_enable();
27995 + set_fs(old_fs);
27996 +
27997 + return ret ? -EFAULT : 0;
27998 +}
27999 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28000 index dd74e46..7d26398 100644
28001 --- a/arch/x86/mm/gup.c
28002 +++ b/arch/x86/mm/gup.c
28003 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28004 addr = start;
28005 len = (unsigned long) nr_pages << PAGE_SHIFT;
28006 end = start + len;
28007 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28008 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28009 (void __user *)start, len)))
28010 return 0;
28011
28012 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28013 index 252b8f5..4dcfdc1 100644
28014 --- a/arch/x86/mm/highmem_32.c
28015 +++ b/arch/x86/mm/highmem_32.c
28016 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28017 idx = type + KM_TYPE_NR*smp_processor_id();
28018 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28019 BUG_ON(!pte_none(*(kmap_pte-idx)));
28020 +
28021 + pax_open_kernel();
28022 set_pte(kmap_pte-idx, mk_pte(page, prot));
28023 + pax_close_kernel();
28024 +
28025 arch_flush_lazy_mmu_mode();
28026
28027 return (void *)vaddr;
28028 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28029 index ae1aa71..d9bea75 100644
28030 --- a/arch/x86/mm/hugetlbpage.c
28031 +++ b/arch/x86/mm/hugetlbpage.c
28032 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
28033 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
28034 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28035 unsigned long addr, unsigned long len,
28036 - unsigned long pgoff, unsigned long flags)
28037 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28038 {
28039 struct hstate *h = hstate_file(file);
28040 struct vm_unmapped_area_info info;
28041 -
28042 +
28043 info.flags = 0;
28044 info.length = len;
28045 info.low_limit = TASK_UNMAPPED_BASE;
28046 +
28047 +#ifdef CONFIG_PAX_RANDMMAP
28048 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28049 + info.low_limit += current->mm->delta_mmap;
28050 +#endif
28051 +
28052 info.high_limit = TASK_SIZE;
28053 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28054 info.align_offset = 0;
28055 + info.threadstack_offset = offset;
28056 return vm_unmapped_area(&info);
28057 }
28058
28059 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28060 unsigned long addr0, unsigned long len,
28061 - unsigned long pgoff, unsigned long flags)
28062 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28063 {
28064 struct hstate *h = hstate_file(file);
28065 struct vm_unmapped_area_info info;
28066 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28067 info.high_limit = current->mm->mmap_base;
28068 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28069 info.align_offset = 0;
28070 + info.threadstack_offset = offset;
28071 addr = vm_unmapped_area(&info);
28072
28073 /*
28074 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28075 VM_BUG_ON(addr != -ENOMEM);
28076 info.flags = 0;
28077 info.low_limit = TASK_UNMAPPED_BASE;
28078 +
28079 +#ifdef CONFIG_PAX_RANDMMAP
28080 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28081 + info.low_limit += current->mm->delta_mmap;
28082 +#endif
28083 +
28084 info.high_limit = TASK_SIZE;
28085 addr = vm_unmapped_area(&info);
28086 }
28087 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28088 struct hstate *h = hstate_file(file);
28089 struct mm_struct *mm = current->mm;
28090 struct vm_area_struct *vma;
28091 + unsigned long pax_task_size = TASK_SIZE;
28092 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28093
28094 if (len & ~huge_page_mask(h))
28095 return -EINVAL;
28096 - if (len > TASK_SIZE)
28097 +
28098 +#ifdef CONFIG_PAX_SEGMEXEC
28099 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28100 + pax_task_size = SEGMEXEC_TASK_SIZE;
28101 +#endif
28102 +
28103 + pax_task_size -= PAGE_SIZE;
28104 +
28105 + if (len > pax_task_size)
28106 return -ENOMEM;
28107
28108 if (flags & MAP_FIXED) {
28109 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28110 return addr;
28111 }
28112
28113 +#ifdef CONFIG_PAX_RANDMMAP
28114 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28115 +#endif
28116 +
28117 if (addr) {
28118 addr = ALIGN(addr, huge_page_size(h));
28119 vma = find_vma(mm, addr);
28120 - if (TASK_SIZE - len >= addr &&
28121 - (!vma || addr + len <= vma->vm_start))
28122 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28123 return addr;
28124 }
28125 if (mm->get_unmapped_area == arch_get_unmapped_area)
28126 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28127 - pgoff, flags);
28128 + pgoff, flags, offset);
28129 else
28130 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28131 - pgoff, flags);
28132 + pgoff, flags, offset);
28133 }
28134
28135 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28136 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28137 index 1f34e92..d252637 100644
28138 --- a/arch/x86/mm/init.c
28139 +++ b/arch/x86/mm/init.c
28140 @@ -4,6 +4,7 @@
28141 #include <linux/swap.h>
28142 #include <linux/memblock.h>
28143 #include <linux/bootmem.h> /* for max_low_pfn */
28144 +#include <linux/tboot.h>
28145
28146 #include <asm/cacheflush.h>
28147 #include <asm/e820.h>
28148 @@ -17,6 +18,8 @@
28149 #include <asm/proto.h>
28150 #include <asm/dma.h> /* for MAX_DMA_PFN */
28151 #include <asm/microcode.h>
28152 +#include <asm/desc.h>
28153 +#include <asm/bios_ebda.h>
28154
28155 #include "mm_internal.h"
28156
28157 @@ -465,7 +468,15 @@ void __init init_mem_mapping(void)
28158 early_ioremap_page_table_range_init();
28159 #endif
28160
28161 +#ifdef CONFIG_PAX_PER_CPU_PGD
28162 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28163 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28164 + KERNEL_PGD_PTRS);
28165 + load_cr3(get_cpu_pgd(0));
28166 +#else
28167 load_cr3(swapper_pg_dir);
28168 +#endif
28169 +
28170 __flush_tlb_all();
28171
28172 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
28173 @@ -481,10 +492,40 @@ void __init init_mem_mapping(void)
28174 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28175 * mmio resources as well as potential bios/acpi data regions.
28176 */
28177 +
28178 +#ifdef CONFIG_GRKERNSEC_KMEM
28179 +static unsigned int ebda_start __read_only;
28180 +static unsigned int ebda_end __read_only;
28181 +#endif
28182 +
28183 int devmem_is_allowed(unsigned long pagenr)
28184 {
28185 - if (pagenr < 256)
28186 +#ifdef CONFIG_GRKERNSEC_KMEM
28187 + /* allow BDA */
28188 + if (!pagenr)
28189 return 1;
28190 + /* allow EBDA */
28191 + if (pagenr >= ebda_start && pagenr < ebda_end)
28192 + return 1;
28193 + /* if tboot is in use, allow access to its hardcoded serial log range */
28194 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28195 + return 1;
28196 +#else
28197 + if (!pagenr)
28198 + return 1;
28199 +#ifdef CONFIG_VM86
28200 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28201 + return 1;
28202 +#endif
28203 +#endif
28204 +
28205 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28206 + return 1;
28207 +#ifdef CONFIG_GRKERNSEC_KMEM
28208 + /* throw out everything else below 1MB */
28209 + if (pagenr <= 256)
28210 + return 0;
28211 +#endif
28212 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28213 return 0;
28214 if (!page_is_ram(pagenr))
28215 @@ -538,8 +579,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28216 #endif
28217 }
28218
28219 +#ifdef CONFIG_GRKERNSEC_KMEM
28220 +static inline void gr_init_ebda(void)
28221 +{
28222 + unsigned int ebda_addr;
28223 + unsigned int ebda_size = 0;
28224 +
28225 + ebda_addr = get_bios_ebda();
28226 + if (ebda_addr) {
28227 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28228 + ebda_size <<= 10;
28229 + }
28230 + if (ebda_addr && ebda_size) {
28231 + ebda_start = ebda_addr >> PAGE_SHIFT;
28232 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28233 + } else {
28234 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28235 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28236 + }
28237 +}
28238 +#else
28239 +static inline void gr_init_ebda(void) { }
28240 +#endif
28241 +
28242 void free_initmem(void)
28243 {
28244 +#ifdef CONFIG_PAX_KERNEXEC
28245 +#ifdef CONFIG_X86_32
28246 + /* PaX: limit KERNEL_CS to actual size */
28247 + unsigned long addr, limit;
28248 + struct desc_struct d;
28249 + int cpu;
28250 +#else
28251 + pgd_t *pgd;
28252 + pud_t *pud;
28253 + pmd_t *pmd;
28254 + unsigned long addr, end;
28255 +#endif
28256 +#endif
28257 +
28258 + gr_init_ebda();
28259 +
28260 +#ifdef CONFIG_PAX_KERNEXEC
28261 +#ifdef CONFIG_X86_32
28262 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28263 + limit = (limit - 1UL) >> PAGE_SHIFT;
28264 +
28265 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28266 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28267 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28268 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28269 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28270 + }
28271 +
28272 + /* PaX: make KERNEL_CS read-only */
28273 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28274 + if (!paravirt_enabled())
28275 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28276 +/*
28277 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28278 + pgd = pgd_offset_k(addr);
28279 + pud = pud_offset(pgd, addr);
28280 + pmd = pmd_offset(pud, addr);
28281 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28282 + }
28283 +*/
28284 +#ifdef CONFIG_X86_PAE
28285 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28286 +/*
28287 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28288 + pgd = pgd_offset_k(addr);
28289 + pud = pud_offset(pgd, addr);
28290 + pmd = pmd_offset(pud, addr);
28291 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28292 + }
28293 +*/
28294 +#endif
28295 +
28296 +#ifdef CONFIG_MODULES
28297 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28298 +#endif
28299 +
28300 +#else
28301 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28302 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28303 + pgd = pgd_offset_k(addr);
28304 + pud = pud_offset(pgd, addr);
28305 + pmd = pmd_offset(pud, addr);
28306 + if (!pmd_present(*pmd))
28307 + continue;
28308 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28309 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28310 + else
28311 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28312 + }
28313 +
28314 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28315 + end = addr + KERNEL_IMAGE_SIZE;
28316 + for (; addr < end; addr += PMD_SIZE) {
28317 + pgd = pgd_offset_k(addr);
28318 + pud = pud_offset(pgd, addr);
28319 + pmd = pmd_offset(pud, addr);
28320 + if (!pmd_present(*pmd))
28321 + continue;
28322 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28323 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28324 + }
28325 +#endif
28326 +
28327 + flush_tlb_all();
28328 +#endif
28329 +
28330 free_init_pages("unused kernel memory",
28331 (unsigned long)(&__init_begin),
28332 (unsigned long)(&__init_end));
28333 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28334 index 3ac7e31..89611b7 100644
28335 --- a/arch/x86/mm/init_32.c
28336 +++ b/arch/x86/mm/init_32.c
28337 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28338 bool __read_mostly __vmalloc_start_set = false;
28339
28340 /*
28341 - * Creates a middle page table and puts a pointer to it in the
28342 - * given global directory entry. This only returns the gd entry
28343 - * in non-PAE compilation mode, since the middle layer is folded.
28344 - */
28345 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28346 -{
28347 - pud_t *pud;
28348 - pmd_t *pmd_table;
28349 -
28350 -#ifdef CONFIG_X86_PAE
28351 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28352 - pmd_table = (pmd_t *)alloc_low_page();
28353 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28354 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28355 - pud = pud_offset(pgd, 0);
28356 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28357 -
28358 - return pmd_table;
28359 - }
28360 -#endif
28361 - pud = pud_offset(pgd, 0);
28362 - pmd_table = pmd_offset(pud, 0);
28363 -
28364 - return pmd_table;
28365 -}
28366 -
28367 -/*
28368 * Create a page table and place a pointer to it in a middle page
28369 * directory entry:
28370 */
28371 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28372 pte_t *page_table = (pte_t *)alloc_low_page();
28373
28374 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28375 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28376 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28377 +#else
28378 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28379 +#endif
28380 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28381 }
28382
28383 return pte_offset_kernel(pmd, 0);
28384 }
28385
28386 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28387 +{
28388 + pud_t *pud;
28389 + pmd_t *pmd_table;
28390 +
28391 + pud = pud_offset(pgd, 0);
28392 + pmd_table = pmd_offset(pud, 0);
28393 +
28394 + return pmd_table;
28395 +}
28396 +
28397 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28398 {
28399 int pgd_idx = pgd_index(vaddr);
28400 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28401 int pgd_idx, pmd_idx;
28402 unsigned long vaddr;
28403 pgd_t *pgd;
28404 + pud_t *pud;
28405 pmd_t *pmd;
28406 pte_t *pte = NULL;
28407 unsigned long count = page_table_range_init_count(start, end);
28408 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28409 pgd = pgd_base + pgd_idx;
28410
28411 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28412 - pmd = one_md_table_init(pgd);
28413 - pmd = pmd + pmd_index(vaddr);
28414 + pud = pud_offset(pgd, vaddr);
28415 + pmd = pmd_offset(pud, vaddr);
28416 +
28417 +#ifdef CONFIG_X86_PAE
28418 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28419 +#endif
28420 +
28421 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28422 pmd++, pmd_idx++) {
28423 pte = page_table_kmap_check(one_page_table_init(pmd),
28424 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28425 }
28426 }
28427
28428 -static inline int is_kernel_text(unsigned long addr)
28429 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28430 {
28431 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28432 - return 1;
28433 - return 0;
28434 + if ((start > ktla_ktva((unsigned long)_etext) ||
28435 + end <= ktla_ktva((unsigned long)_stext)) &&
28436 + (start > ktla_ktva((unsigned long)_einittext) ||
28437 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28438 +
28439 +#ifdef CONFIG_ACPI_SLEEP
28440 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28441 +#endif
28442 +
28443 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28444 + return 0;
28445 + return 1;
28446 }
28447
28448 /*
28449 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28450 unsigned long last_map_addr = end;
28451 unsigned long start_pfn, end_pfn;
28452 pgd_t *pgd_base = swapper_pg_dir;
28453 - int pgd_idx, pmd_idx, pte_ofs;
28454 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28455 unsigned long pfn;
28456 pgd_t *pgd;
28457 + pud_t *pud;
28458 pmd_t *pmd;
28459 pte_t *pte;
28460 unsigned pages_2m, pages_4k;
28461 @@ -291,8 +295,13 @@ repeat:
28462 pfn = start_pfn;
28463 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28464 pgd = pgd_base + pgd_idx;
28465 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28466 - pmd = one_md_table_init(pgd);
28467 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28468 + pud = pud_offset(pgd, 0);
28469 + pmd = pmd_offset(pud, 0);
28470 +
28471 +#ifdef CONFIG_X86_PAE
28472 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28473 +#endif
28474
28475 if (pfn >= end_pfn)
28476 continue;
28477 @@ -304,14 +313,13 @@ repeat:
28478 #endif
28479 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28480 pmd++, pmd_idx++) {
28481 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28482 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28483
28484 /*
28485 * Map with big pages if possible, otherwise
28486 * create normal page tables:
28487 */
28488 if (use_pse) {
28489 - unsigned int addr2;
28490 pgprot_t prot = PAGE_KERNEL_LARGE;
28491 /*
28492 * first pass will use the same initial
28493 @@ -322,11 +330,7 @@ repeat:
28494 _PAGE_PSE);
28495
28496 pfn &= PMD_MASK >> PAGE_SHIFT;
28497 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28498 - PAGE_OFFSET + PAGE_SIZE-1;
28499 -
28500 - if (is_kernel_text(addr) ||
28501 - is_kernel_text(addr2))
28502 + if (is_kernel_text(address, address + PMD_SIZE))
28503 prot = PAGE_KERNEL_LARGE_EXEC;
28504
28505 pages_2m++;
28506 @@ -343,7 +347,7 @@ repeat:
28507 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28508 pte += pte_ofs;
28509 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28510 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28511 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28512 pgprot_t prot = PAGE_KERNEL;
28513 /*
28514 * first pass will use the same initial
28515 @@ -351,7 +355,7 @@ repeat:
28516 */
28517 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28518
28519 - if (is_kernel_text(addr))
28520 + if (is_kernel_text(address, address + PAGE_SIZE))
28521 prot = PAGE_KERNEL_EXEC;
28522
28523 pages_4k++;
28524 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
28525
28526 pud = pud_offset(pgd, va);
28527 pmd = pmd_offset(pud, va);
28528 - if (!pmd_present(*pmd))
28529 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28530 break;
28531
28532 /* should not be large page here */
28533 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
28534
28535 static void __init pagetable_init(void)
28536 {
28537 - pgd_t *pgd_base = swapper_pg_dir;
28538 -
28539 - permanent_kmaps_init(pgd_base);
28540 + permanent_kmaps_init(swapper_pg_dir);
28541 }
28542
28543 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28544 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28545 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28546
28547 /* user-defined highmem size */
28548 @@ -772,7 +774,7 @@ void __init mem_init(void)
28549 after_bootmem = 1;
28550
28551 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28552 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28553 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28554 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28555
28556 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28557 @@ -813,10 +815,10 @@ void __init mem_init(void)
28558 ((unsigned long)&__init_end -
28559 (unsigned long)&__init_begin) >> 10,
28560
28561 - (unsigned long)&_etext, (unsigned long)&_edata,
28562 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28563 + (unsigned long)&_sdata, (unsigned long)&_edata,
28564 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28565
28566 - (unsigned long)&_text, (unsigned long)&_etext,
28567 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28568 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28569
28570 /*
28571 @@ -906,6 +908,7 @@ void set_kernel_text_rw(void)
28572 if (!kernel_set_to_readonly)
28573 return;
28574
28575 + start = ktla_ktva(start);
28576 pr_debug("Set kernel text: %lx - %lx for read write\n",
28577 start, start+size);
28578
28579 @@ -920,6 +923,7 @@ void set_kernel_text_ro(void)
28580 if (!kernel_set_to_readonly)
28581 return;
28582
28583 + start = ktla_ktva(start);
28584 pr_debug("Set kernel text: %lx - %lx for read only\n",
28585 start, start+size);
28586
28587 @@ -948,6 +952,7 @@ void mark_rodata_ro(void)
28588 unsigned long start = PFN_ALIGN(_text);
28589 unsigned long size = PFN_ALIGN(_etext) - start;
28590
28591 + start = ktla_ktva(start);
28592 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28593 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28594 size >> 10);
28595 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28596 index bb00c46..f31d2f0 100644
28597 --- a/arch/x86/mm/init_64.c
28598 +++ b/arch/x86/mm/init_64.c
28599 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28600 * around without checking the pgd every time.
28601 */
28602
28603 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28604 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28605 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28606
28607 int force_personality32;
28608 @@ -184,12 +184,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28609
28610 for (address = start; address <= end; address += PGDIR_SIZE) {
28611 const pgd_t *pgd_ref = pgd_offset_k(address);
28612 +
28613 +#ifdef CONFIG_PAX_PER_CPU_PGD
28614 + unsigned long cpu;
28615 +#else
28616 struct page *page;
28617 +#endif
28618
28619 if (pgd_none(*pgd_ref))
28620 continue;
28621
28622 spin_lock(&pgd_lock);
28623 +
28624 +#ifdef CONFIG_PAX_PER_CPU_PGD
28625 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28626 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28627 +#else
28628 list_for_each_entry(page, &pgd_list, lru) {
28629 pgd_t *pgd;
28630 spinlock_t *pgt_lock;
28631 @@ -198,6 +208,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28632 /* the pgt_lock only for Xen */
28633 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28634 spin_lock(pgt_lock);
28635 +#endif
28636
28637 if (pgd_none(*pgd))
28638 set_pgd(pgd, *pgd_ref);
28639 @@ -205,7 +216,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28640 BUG_ON(pgd_page_vaddr(*pgd)
28641 != pgd_page_vaddr(*pgd_ref));
28642
28643 +#ifndef CONFIG_PAX_PER_CPU_PGD
28644 spin_unlock(pgt_lock);
28645 +#endif
28646 +
28647 }
28648 spin_unlock(&pgd_lock);
28649 }
28650 @@ -238,7 +252,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28651 {
28652 if (pgd_none(*pgd)) {
28653 pud_t *pud = (pud_t *)spp_getpage();
28654 - pgd_populate(&init_mm, pgd, pud);
28655 + pgd_populate_kernel(&init_mm, pgd, pud);
28656 if (pud != pud_offset(pgd, 0))
28657 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28658 pud, pud_offset(pgd, 0));
28659 @@ -250,7 +264,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28660 {
28661 if (pud_none(*pud)) {
28662 pmd_t *pmd = (pmd_t *) spp_getpage();
28663 - pud_populate(&init_mm, pud, pmd);
28664 + pud_populate_kernel(&init_mm, pud, pmd);
28665 if (pmd != pmd_offset(pud, 0))
28666 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28667 pmd, pmd_offset(pud, 0));
28668 @@ -279,7 +293,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28669 pmd = fill_pmd(pud, vaddr);
28670 pte = fill_pte(pmd, vaddr);
28671
28672 + pax_open_kernel();
28673 set_pte(pte, new_pte);
28674 + pax_close_kernel();
28675
28676 /*
28677 * It's enough to flush this one mapping.
28678 @@ -338,14 +354,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28679 pgd = pgd_offset_k((unsigned long)__va(phys));
28680 if (pgd_none(*pgd)) {
28681 pud = (pud_t *) spp_getpage();
28682 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28683 - _PAGE_USER));
28684 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28685 }
28686 pud = pud_offset(pgd, (unsigned long)__va(phys));
28687 if (pud_none(*pud)) {
28688 pmd = (pmd_t *) spp_getpage();
28689 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28690 - _PAGE_USER));
28691 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28692 }
28693 pmd = pmd_offset(pud, phys);
28694 BUG_ON(!pmd_none(*pmd));
28695 @@ -586,7 +600,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28696 prot);
28697
28698 spin_lock(&init_mm.page_table_lock);
28699 - pud_populate(&init_mm, pud, pmd);
28700 + pud_populate_kernel(&init_mm, pud, pmd);
28701 spin_unlock(&init_mm.page_table_lock);
28702 }
28703 __flush_tlb_all();
28704 @@ -627,7 +641,7 @@ kernel_physical_mapping_init(unsigned long start,
28705 page_size_mask);
28706
28707 spin_lock(&init_mm.page_table_lock);
28708 - pgd_populate(&init_mm, pgd, pud);
28709 + pgd_populate_kernel(&init_mm, pgd, pud);
28710 spin_unlock(&init_mm.page_table_lock);
28711 pgd_changed = true;
28712 }
28713 @@ -1221,8 +1235,8 @@ int kern_addr_valid(unsigned long addr)
28714 static struct vm_area_struct gate_vma = {
28715 .vm_start = VSYSCALL_START,
28716 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28717 - .vm_page_prot = PAGE_READONLY_EXEC,
28718 - .vm_flags = VM_READ | VM_EXEC
28719 + .vm_page_prot = PAGE_READONLY,
28720 + .vm_flags = VM_READ
28721 };
28722
28723 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28724 @@ -1256,7 +1270,7 @@ int in_gate_area_no_mm(unsigned long addr)
28725
28726 const char *arch_vma_name(struct vm_area_struct *vma)
28727 {
28728 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28729 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28730 return "[vdso]";
28731 if (vma == &gate_vma)
28732 return "[vsyscall]";
28733 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28734 index 7b179b4..6bd17777 100644
28735 --- a/arch/x86/mm/iomap_32.c
28736 +++ b/arch/x86/mm/iomap_32.c
28737 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28738 type = kmap_atomic_idx_push();
28739 idx = type + KM_TYPE_NR * smp_processor_id();
28740 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28741 +
28742 + pax_open_kernel();
28743 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28744 + pax_close_kernel();
28745 +
28746 arch_flush_lazy_mmu_mode();
28747
28748 return (void *)vaddr;
28749 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28750 index 9a1e658..da003f3 100644
28751 --- a/arch/x86/mm/ioremap.c
28752 +++ b/arch/x86/mm/ioremap.c
28753 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28754 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28755 int is_ram = page_is_ram(pfn);
28756
28757 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28758 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28759 return NULL;
28760 WARN_ON_ONCE(is_ram);
28761 }
28762 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28763 *
28764 * Caller must ensure there is only one unmapping for the same pointer.
28765 */
28766 -void iounmap(volatile void __iomem *addr)
28767 +void iounmap(const volatile void __iomem *addr)
28768 {
28769 struct vm_struct *p, *o;
28770
28771 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28772
28773 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28774 if (page_is_ram(start >> PAGE_SHIFT))
28775 +#ifdef CONFIG_HIGHMEM
28776 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28777 +#endif
28778 return __va(phys);
28779
28780 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28781 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28782 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28783 {
28784 if (page_is_ram(phys >> PAGE_SHIFT))
28785 +#ifdef CONFIG_HIGHMEM
28786 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28787 +#endif
28788 return;
28789
28790 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28791 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
28792 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28793
28794 static __initdata int after_paging_init;
28795 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28796 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28797
28798 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28799 {
28800 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
28801 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28802
28803 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28804 - memset(bm_pte, 0, sizeof(bm_pte));
28805 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28806 + pmd_populate_user(&init_mm, pmd, bm_pte);
28807
28808 /*
28809 * The boot-ioremap range spans multiple pmds, for which
28810 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28811 index d87dd6d..bf3fa66 100644
28812 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28813 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28814 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28815 * memory (e.g. tracked pages)? For now, we need this to avoid
28816 * invoking kmemcheck for PnP BIOS calls.
28817 */
28818 - if (regs->flags & X86_VM_MASK)
28819 + if (v8086_mode(regs))
28820 return false;
28821 - if (regs->cs != __KERNEL_CS)
28822 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28823 return false;
28824
28825 pte = kmemcheck_pte_lookup(address);
28826 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28827 index 845df68..1d8d29f 100644
28828 --- a/arch/x86/mm/mmap.c
28829 +++ b/arch/x86/mm/mmap.c
28830 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28831 * Leave an at least ~128 MB hole with possible stack randomization.
28832 */
28833 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28834 -#define MAX_GAP (TASK_SIZE/6*5)
28835 +#define MAX_GAP (pax_task_size/6*5)
28836
28837 static int mmap_is_legacy(void)
28838 {
28839 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28840 return rnd << PAGE_SHIFT;
28841 }
28842
28843 -static unsigned long mmap_base(void)
28844 +static unsigned long mmap_base(struct mm_struct *mm)
28845 {
28846 unsigned long gap = rlimit(RLIMIT_STACK);
28847 + unsigned long pax_task_size = TASK_SIZE;
28848 +
28849 +#ifdef CONFIG_PAX_SEGMEXEC
28850 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28851 + pax_task_size = SEGMEXEC_TASK_SIZE;
28852 +#endif
28853
28854 if (gap < MIN_GAP)
28855 gap = MIN_GAP;
28856 else if (gap > MAX_GAP)
28857 gap = MAX_GAP;
28858
28859 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28860 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28861 }
28862
28863 /*
28864 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28865 * does, but not when emulating X86_32
28866 */
28867 -static unsigned long mmap_legacy_base(void)
28868 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28869 {
28870 - if (mmap_is_ia32())
28871 + if (mmap_is_ia32()) {
28872 +
28873 +#ifdef CONFIG_PAX_SEGMEXEC
28874 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28875 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28876 + else
28877 +#endif
28878 +
28879 return TASK_UNMAPPED_BASE;
28880 - else
28881 + } else
28882 return TASK_UNMAPPED_BASE + mmap_rnd();
28883 }
28884
28885 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28886 void arch_pick_mmap_layout(struct mm_struct *mm)
28887 {
28888 if (mmap_is_legacy()) {
28889 - mm->mmap_base = mmap_legacy_base();
28890 + mm->mmap_base = mmap_legacy_base(mm);
28891 +
28892 +#ifdef CONFIG_PAX_RANDMMAP
28893 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28894 + mm->mmap_base += mm->delta_mmap;
28895 +#endif
28896 +
28897 mm->get_unmapped_area = arch_get_unmapped_area;
28898 mm->unmap_area = arch_unmap_area;
28899 } else {
28900 - mm->mmap_base = mmap_base();
28901 + mm->mmap_base = mmap_base(mm);
28902 +
28903 +#ifdef CONFIG_PAX_RANDMMAP
28904 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28905 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28906 +#endif
28907 +
28908 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28909 mm->unmap_area = arch_unmap_area_topdown;
28910 }
28911 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28912 index dc0b727..f612039 100644
28913 --- a/arch/x86/mm/mmio-mod.c
28914 +++ b/arch/x86/mm/mmio-mod.c
28915 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28916 break;
28917 default:
28918 {
28919 - unsigned char *ip = (unsigned char *)instptr;
28920 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28921 my_trace->opcode = MMIO_UNKNOWN_OP;
28922 my_trace->width = 0;
28923 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28924 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28925 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28926 void __iomem *addr)
28927 {
28928 - static atomic_t next_id;
28929 + static atomic_unchecked_t next_id;
28930 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28931 /* These are page-unaligned. */
28932 struct mmiotrace_map map = {
28933 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28934 .private = trace
28935 },
28936 .phys = offset,
28937 - .id = atomic_inc_return(&next_id)
28938 + .id = atomic_inc_return_unchecked(&next_id)
28939 };
28940 map.map_id = trace->id;
28941
28942 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28943 ioremap_trace_core(offset, size, addr);
28944 }
28945
28946 -static void iounmap_trace_core(volatile void __iomem *addr)
28947 +static void iounmap_trace_core(const volatile void __iomem *addr)
28948 {
28949 struct mmiotrace_map map = {
28950 .phys = 0,
28951 @@ -328,7 +328,7 @@ not_enabled:
28952 }
28953 }
28954
28955 -void mmiotrace_iounmap(volatile void __iomem *addr)
28956 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28957 {
28958 might_sleep();
28959 if (is_enabled()) /* recheck and proper locking in *_core() */
28960 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28961 index a71c4e2..301ae44 100644
28962 --- a/arch/x86/mm/numa.c
28963 +++ b/arch/x86/mm/numa.c
28964 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28965 return true;
28966 }
28967
28968 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28969 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28970 {
28971 unsigned long uninitialized_var(pfn_align);
28972 int i, nid;
28973 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28974 index d0b1773..4c3327c 100644
28975 --- a/arch/x86/mm/pageattr-test.c
28976 +++ b/arch/x86/mm/pageattr-test.c
28977 @@ -36,7 +36,7 @@ enum {
28978
28979 static int pte_testbit(pte_t pte)
28980 {
28981 - return pte_flags(pte) & _PAGE_UNUSED1;
28982 + return pte_flags(pte) & _PAGE_CPA_TEST;
28983 }
28984
28985 struct split_state {
28986 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28987 index bb32480..aef8278 100644
28988 --- a/arch/x86/mm/pageattr.c
28989 +++ b/arch/x86/mm/pageattr.c
28990 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28991 */
28992 #ifdef CONFIG_PCI_BIOS
28993 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28994 - pgprot_val(forbidden) |= _PAGE_NX;
28995 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28996 #endif
28997
28998 /*
28999 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29000 * Does not cover __inittext since that is gone later on. On
29001 * 64bit we do not enforce !NX on the low mapping
29002 */
29003 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29004 - pgprot_val(forbidden) |= _PAGE_NX;
29005 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29006 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29007
29008 +#ifdef CONFIG_DEBUG_RODATA
29009 /*
29010 * The .rodata section needs to be read-only. Using the pfn
29011 * catches all aliases.
29012 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29013 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
29014 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
29015 pgprot_val(forbidden) |= _PAGE_RW;
29016 +#endif
29017
29018 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29019 /*
29020 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29021 }
29022 #endif
29023
29024 +#ifdef CONFIG_PAX_KERNEXEC
29025 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29026 + pgprot_val(forbidden) |= _PAGE_RW;
29027 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29028 + }
29029 +#endif
29030 +
29031 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29032
29033 return prot;
29034 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
29035 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29036 {
29037 /* change init_mm */
29038 + pax_open_kernel();
29039 set_pte_atomic(kpte, pte);
29040 +
29041 #ifdef CONFIG_X86_32
29042 if (!SHARED_KERNEL_PMD) {
29043 +
29044 +#ifdef CONFIG_PAX_PER_CPU_PGD
29045 + unsigned long cpu;
29046 +#else
29047 struct page *page;
29048 +#endif
29049
29050 +#ifdef CONFIG_PAX_PER_CPU_PGD
29051 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29052 + pgd_t *pgd = get_cpu_pgd(cpu);
29053 +#else
29054 list_for_each_entry(page, &pgd_list, lru) {
29055 - pgd_t *pgd;
29056 + pgd_t *pgd = (pgd_t *)page_address(page);
29057 +#endif
29058 +
29059 pud_t *pud;
29060 pmd_t *pmd;
29061
29062 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29063 + pgd += pgd_index(address);
29064 pud = pud_offset(pgd, address);
29065 pmd = pmd_offset(pud, address);
29066 set_pte_atomic((pte_t *)pmd, pte);
29067 }
29068 }
29069 #endif
29070 + pax_close_kernel();
29071 }
29072
29073 static int
29074 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29075 index 6574388..87e9bef 100644
29076 --- a/arch/x86/mm/pat.c
29077 +++ b/arch/x86/mm/pat.c
29078 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29079
29080 if (!entry) {
29081 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29082 - current->comm, current->pid, start, end - 1);
29083 + current->comm, task_pid_nr(current), start, end - 1);
29084 return -EINVAL;
29085 }
29086
29087 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29088
29089 while (cursor < to) {
29090 if (!devmem_is_allowed(pfn)) {
29091 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29092 - current->comm, from, to - 1);
29093 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29094 + current->comm, from, to - 1, cursor);
29095 return 0;
29096 }
29097 cursor += PAGE_SIZE;
29098 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29099 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29100 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29101 "for [mem %#010Lx-%#010Lx]\n",
29102 - current->comm, current->pid,
29103 + current->comm, task_pid_nr(current),
29104 cattr_name(flags),
29105 base, (unsigned long long)(base + size-1));
29106 return -EINVAL;
29107 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29108 flags = lookup_memtype(paddr);
29109 if (want_flags != flags) {
29110 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29111 - current->comm, current->pid,
29112 + current->comm, task_pid_nr(current),
29113 cattr_name(want_flags),
29114 (unsigned long long)paddr,
29115 (unsigned long long)(paddr + size - 1),
29116 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29117 free_memtype(paddr, paddr + size);
29118 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29119 " for [mem %#010Lx-%#010Lx], got %s\n",
29120 - current->comm, current->pid,
29121 + current->comm, task_pid_nr(current),
29122 cattr_name(want_flags),
29123 (unsigned long long)paddr,
29124 (unsigned long long)(paddr + size - 1),
29125 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
29126 index 415f6c4..d319983 100644
29127 --- a/arch/x86/mm/pat_rbtree.c
29128 +++ b/arch/x86/mm/pat_rbtree.c
29129 @@ -160,7 +160,7 @@ success:
29130
29131 failure:
29132 printk(KERN_INFO "%s:%d conflicting memory types "
29133 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
29134 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
29135 end, cattr_name(found_type), cattr_name(match->type));
29136 return -EBUSY;
29137 }
29138 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29139 index 9f0614d..92ae64a 100644
29140 --- a/arch/x86/mm/pf_in.c
29141 +++ b/arch/x86/mm/pf_in.c
29142 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29143 int i;
29144 enum reason_type rv = OTHERS;
29145
29146 - p = (unsigned char *)ins_addr;
29147 + p = (unsigned char *)ktla_ktva(ins_addr);
29148 p += skip_prefix(p, &prf);
29149 p += get_opcode(p, &opcode);
29150
29151 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29152 struct prefix_bits prf;
29153 int i;
29154
29155 - p = (unsigned char *)ins_addr;
29156 + p = (unsigned char *)ktla_ktva(ins_addr);
29157 p += skip_prefix(p, &prf);
29158 p += get_opcode(p, &opcode);
29159
29160 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29161 struct prefix_bits prf;
29162 int i;
29163
29164 - p = (unsigned char *)ins_addr;
29165 + p = (unsigned char *)ktla_ktva(ins_addr);
29166 p += skip_prefix(p, &prf);
29167 p += get_opcode(p, &opcode);
29168
29169 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29170 struct prefix_bits prf;
29171 int i;
29172
29173 - p = (unsigned char *)ins_addr;
29174 + p = (unsigned char *)ktla_ktva(ins_addr);
29175 p += skip_prefix(p, &prf);
29176 p += get_opcode(p, &opcode);
29177 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29178 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29179 struct prefix_bits prf;
29180 int i;
29181
29182 - p = (unsigned char *)ins_addr;
29183 + p = (unsigned char *)ktla_ktva(ins_addr);
29184 p += skip_prefix(p, &prf);
29185 p += get_opcode(p, &opcode);
29186 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29187 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29188 index 17fda6a..489c74a 100644
29189 --- a/arch/x86/mm/pgtable.c
29190 +++ b/arch/x86/mm/pgtable.c
29191 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29192 list_del(&page->lru);
29193 }
29194
29195 -#define UNSHARED_PTRS_PER_PGD \
29196 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29197 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29198 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29199
29200 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29201 +{
29202 + unsigned int count = USER_PGD_PTRS;
29203
29204 + while (count--)
29205 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29206 +}
29207 +#endif
29208 +
29209 +#ifdef CONFIG_PAX_PER_CPU_PGD
29210 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29211 +{
29212 + unsigned int count = USER_PGD_PTRS;
29213 +
29214 + while (count--) {
29215 + pgd_t pgd;
29216 +
29217 +#ifdef CONFIG_X86_64
29218 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29219 +#else
29220 + pgd = *src++;
29221 +#endif
29222 +
29223 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29224 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29225 +#endif
29226 +
29227 + *dst++ = pgd;
29228 + }
29229 +
29230 +}
29231 +#endif
29232 +
29233 +#ifdef CONFIG_X86_64
29234 +#define pxd_t pud_t
29235 +#define pyd_t pgd_t
29236 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29237 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29238 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29239 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29240 +#define PYD_SIZE PGDIR_SIZE
29241 +#else
29242 +#define pxd_t pmd_t
29243 +#define pyd_t pud_t
29244 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29245 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29246 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29247 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29248 +#define PYD_SIZE PUD_SIZE
29249 +#endif
29250 +
29251 +#ifdef CONFIG_PAX_PER_CPU_PGD
29252 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29253 +static inline void pgd_dtor(pgd_t *pgd) {}
29254 +#else
29255 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29256 {
29257 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29258 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29259 pgd_list_del(pgd);
29260 spin_unlock(&pgd_lock);
29261 }
29262 +#endif
29263
29264 /*
29265 * List of all pgd's needed for non-PAE so it can invalidate entries
29266 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29267 * -- nyc
29268 */
29269
29270 -#ifdef CONFIG_X86_PAE
29271 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29272 /*
29273 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29274 * updating the top-level pagetable entries to guarantee the
29275 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29276 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29277 * and initialize the kernel pmds here.
29278 */
29279 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29280 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29281
29282 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29283 {
29284 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29285 */
29286 flush_tlb_mm(mm);
29287 }
29288 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29289 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29290 #else /* !CONFIG_X86_PAE */
29291
29292 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29293 -#define PREALLOCATED_PMDS 0
29294 +#define PREALLOCATED_PXDS 0
29295
29296 #endif /* CONFIG_X86_PAE */
29297
29298 -static void free_pmds(pmd_t *pmds[])
29299 +static void free_pxds(pxd_t *pxds[])
29300 {
29301 int i;
29302
29303 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29304 - if (pmds[i])
29305 - free_page((unsigned long)pmds[i]);
29306 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29307 + if (pxds[i])
29308 + free_page((unsigned long)pxds[i]);
29309 }
29310
29311 -static int preallocate_pmds(pmd_t *pmds[])
29312 +static int preallocate_pxds(pxd_t *pxds[])
29313 {
29314 int i;
29315 bool failed = false;
29316
29317 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29318 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29319 - if (pmd == NULL)
29320 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29321 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29322 + if (pxd == NULL)
29323 failed = true;
29324 - pmds[i] = pmd;
29325 + pxds[i] = pxd;
29326 }
29327
29328 if (failed) {
29329 - free_pmds(pmds);
29330 + free_pxds(pxds);
29331 return -ENOMEM;
29332 }
29333
29334 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29335 * preallocate which never got a corresponding vma will need to be
29336 * freed manually.
29337 */
29338 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29339 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29340 {
29341 int i;
29342
29343 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29344 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29345 pgd_t pgd = pgdp[i];
29346
29347 if (pgd_val(pgd) != 0) {
29348 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29349 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29350
29351 - pgdp[i] = native_make_pgd(0);
29352 + set_pgd(pgdp + i, native_make_pgd(0));
29353
29354 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29355 - pmd_free(mm, pmd);
29356 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29357 + pxd_free(mm, pxd);
29358 }
29359 }
29360 }
29361
29362 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29363 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29364 {
29365 - pud_t *pud;
29366 + pyd_t *pyd;
29367 unsigned long addr;
29368 int i;
29369
29370 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29371 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29372 return;
29373
29374 - pud = pud_offset(pgd, 0);
29375 +#ifdef CONFIG_X86_64
29376 + pyd = pyd_offset(mm, 0L);
29377 +#else
29378 + pyd = pyd_offset(pgd, 0L);
29379 +#endif
29380
29381 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29382 - i++, pud++, addr += PUD_SIZE) {
29383 - pmd_t *pmd = pmds[i];
29384 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29385 + i++, pyd++, addr += PYD_SIZE) {
29386 + pxd_t *pxd = pxds[i];
29387
29388 if (i >= KERNEL_PGD_BOUNDARY)
29389 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29390 - sizeof(pmd_t) * PTRS_PER_PMD);
29391 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29392 + sizeof(pxd_t) * PTRS_PER_PMD);
29393
29394 - pud_populate(mm, pud, pmd);
29395 + pyd_populate(mm, pyd, pxd);
29396 }
29397 }
29398
29399 pgd_t *pgd_alloc(struct mm_struct *mm)
29400 {
29401 pgd_t *pgd;
29402 - pmd_t *pmds[PREALLOCATED_PMDS];
29403 + pxd_t *pxds[PREALLOCATED_PXDS];
29404
29405 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29406
29407 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29408
29409 mm->pgd = pgd;
29410
29411 - if (preallocate_pmds(pmds) != 0)
29412 + if (preallocate_pxds(pxds) != 0)
29413 goto out_free_pgd;
29414
29415 if (paravirt_pgd_alloc(mm) != 0)
29416 - goto out_free_pmds;
29417 + goto out_free_pxds;
29418
29419 /*
29420 * Make sure that pre-populating the pmds is atomic with
29421 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29422 spin_lock(&pgd_lock);
29423
29424 pgd_ctor(mm, pgd);
29425 - pgd_prepopulate_pmd(mm, pgd, pmds);
29426 + pgd_prepopulate_pxd(mm, pgd, pxds);
29427
29428 spin_unlock(&pgd_lock);
29429
29430 return pgd;
29431
29432 -out_free_pmds:
29433 - free_pmds(pmds);
29434 +out_free_pxds:
29435 + free_pxds(pxds);
29436 out_free_pgd:
29437 free_page((unsigned long)pgd);
29438 out:
29439 @@ -302,7 +363,7 @@ out:
29440
29441 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29442 {
29443 - pgd_mop_up_pmds(mm, pgd);
29444 + pgd_mop_up_pxds(mm, pgd);
29445 pgd_dtor(pgd);
29446 paravirt_pgd_free(mm, pgd);
29447 free_page((unsigned long)pgd);
29448 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29449 index a69bcb8..19068ab 100644
29450 --- a/arch/x86/mm/pgtable_32.c
29451 +++ b/arch/x86/mm/pgtable_32.c
29452 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29453 return;
29454 }
29455 pte = pte_offset_kernel(pmd, vaddr);
29456 +
29457 + pax_open_kernel();
29458 if (pte_val(pteval))
29459 set_pte_at(&init_mm, vaddr, pte, pteval);
29460 else
29461 pte_clear(&init_mm, vaddr, pte);
29462 + pax_close_kernel();
29463
29464 /*
29465 * It's enough to flush this one mapping.
29466 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29467 index e666cbb..61788c45 100644
29468 --- a/arch/x86/mm/physaddr.c
29469 +++ b/arch/x86/mm/physaddr.c
29470 @@ -10,7 +10,7 @@
29471 #ifdef CONFIG_X86_64
29472
29473 #ifdef CONFIG_DEBUG_VIRTUAL
29474 -unsigned long __phys_addr(unsigned long x)
29475 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29476 {
29477 unsigned long y = x - __START_KERNEL_map;
29478
29479 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29480 #else
29481
29482 #ifdef CONFIG_DEBUG_VIRTUAL
29483 -unsigned long __phys_addr(unsigned long x)
29484 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29485 {
29486 unsigned long phys_addr = x - PAGE_OFFSET;
29487 /* VMALLOC_* aren't constants */
29488 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29489 index 410531d..0f16030 100644
29490 --- a/arch/x86/mm/setup_nx.c
29491 +++ b/arch/x86/mm/setup_nx.c
29492 @@ -5,8 +5,10 @@
29493 #include <asm/pgtable.h>
29494 #include <asm/proto.h>
29495
29496 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29497 static int disable_nx __cpuinitdata;
29498
29499 +#ifndef CONFIG_PAX_PAGEEXEC
29500 /*
29501 * noexec = on|off
29502 *
29503 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29504 return 0;
29505 }
29506 early_param("noexec", noexec_setup);
29507 +#endif
29508 +
29509 +#endif
29510
29511 void __cpuinit x86_configure_nx(void)
29512 {
29513 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29514 if (cpu_has_nx && !disable_nx)
29515 __supported_pte_mask |= _PAGE_NX;
29516 else
29517 +#endif
29518 __supported_pte_mask &= ~_PAGE_NX;
29519 }
29520
29521 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29522 index 282375f..e03a98f 100644
29523 --- a/arch/x86/mm/tlb.c
29524 +++ b/arch/x86/mm/tlb.c
29525 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29526 BUG();
29527 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29528 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29529 +
29530 +#ifndef CONFIG_PAX_PER_CPU_PGD
29531 load_cr3(swapper_pg_dir);
29532 +#endif
29533 +
29534 }
29535 }
29536 EXPORT_SYMBOL_GPL(leave_mm);
29537 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29538 index 877b9a1..a8ecf42 100644
29539 --- a/arch/x86/net/bpf_jit.S
29540 +++ b/arch/x86/net/bpf_jit.S
29541 @@ -9,6 +9,7 @@
29542 */
29543 #include <linux/linkage.h>
29544 #include <asm/dwarf2.h>
29545 +#include <asm/alternative-asm.h>
29546
29547 /*
29548 * Calling convention :
29549 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29550 jle bpf_slow_path_word
29551 mov (SKBDATA,%rsi),%eax
29552 bswap %eax /* ntohl() */
29553 + pax_force_retaddr
29554 ret
29555
29556 sk_load_half:
29557 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29558 jle bpf_slow_path_half
29559 movzwl (SKBDATA,%rsi),%eax
29560 rol $8,%ax # ntohs()
29561 + pax_force_retaddr
29562 ret
29563
29564 sk_load_byte:
29565 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29566 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29567 jle bpf_slow_path_byte
29568 movzbl (SKBDATA,%rsi),%eax
29569 + pax_force_retaddr
29570 ret
29571
29572 /**
29573 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29574 movzbl (SKBDATA,%rsi),%ebx
29575 and $15,%bl
29576 shl $2,%bl
29577 + pax_force_retaddr
29578 ret
29579
29580 /* rsi contains offset and can be scratched */
29581 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29582 js bpf_error
29583 mov -12(%rbp),%eax
29584 bswap %eax
29585 + pax_force_retaddr
29586 ret
29587
29588 bpf_slow_path_half:
29589 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29590 mov -12(%rbp),%ax
29591 rol $8,%ax
29592 movzwl %ax,%eax
29593 + pax_force_retaddr
29594 ret
29595
29596 bpf_slow_path_byte:
29597 bpf_slow_path_common(1)
29598 js bpf_error
29599 movzbl -12(%rbp),%eax
29600 + pax_force_retaddr
29601 ret
29602
29603 bpf_slow_path_byte_msh:
29604 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29605 and $15,%al
29606 shl $2,%al
29607 xchg %eax,%ebx
29608 + pax_force_retaddr
29609 ret
29610
29611 #define sk_negative_common(SIZE) \
29612 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29613 sk_negative_common(4)
29614 mov (%rax), %eax
29615 bswap %eax
29616 + pax_force_retaddr
29617 ret
29618
29619 bpf_slow_path_half_neg:
29620 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29621 mov (%rax),%ax
29622 rol $8,%ax
29623 movzwl %ax,%eax
29624 + pax_force_retaddr
29625 ret
29626
29627 bpf_slow_path_byte_neg:
29628 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29629 .globl sk_load_byte_negative_offset
29630 sk_negative_common(1)
29631 movzbl (%rax), %eax
29632 + pax_force_retaddr
29633 ret
29634
29635 bpf_slow_path_byte_msh_neg:
29636 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29637 and $15,%al
29638 shl $2,%al
29639 xchg %eax,%ebx
29640 + pax_force_retaddr
29641 ret
29642
29643 bpf_error:
29644 @@ -197,4 +210,5 @@ bpf_error:
29645 xor %eax,%eax
29646 mov -8(%rbp),%rbx
29647 leaveq
29648 + pax_force_retaddr
29649 ret
29650 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29651 index f66b540..3e88dfb 100644
29652 --- a/arch/x86/net/bpf_jit_comp.c
29653 +++ b/arch/x86/net/bpf_jit_comp.c
29654 @@ -12,6 +12,7 @@
29655 #include <linux/netdevice.h>
29656 #include <linux/filter.h>
29657 #include <linux/if_vlan.h>
29658 +#include <linux/random.h>
29659
29660 /*
29661 * Conventions :
29662 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29663 return ptr + len;
29664 }
29665
29666 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29667 +#define MAX_INSTR_CODE_SIZE 96
29668 +#else
29669 +#define MAX_INSTR_CODE_SIZE 64
29670 +#endif
29671 +
29672 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29673
29674 #define EMIT1(b1) EMIT(b1, 1)
29675 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29676 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29677 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29678 +
29679 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29680 +/* original constant will appear in ecx */
29681 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29682 +do { \
29683 + /* mov ecx, randkey */ \
29684 + EMIT1(0xb9); \
29685 + EMIT(_key, 4); \
29686 + /* xor ecx, randkey ^ off */ \
29687 + EMIT2(0x81, 0xf1); \
29688 + EMIT((_key) ^ (_off), 4); \
29689 +} while (0)
29690 +
29691 +#define EMIT1_off32(b1, _off) \
29692 +do { \
29693 + switch (b1) { \
29694 + case 0x05: /* add eax, imm32 */ \
29695 + case 0x2d: /* sub eax, imm32 */ \
29696 + case 0x25: /* and eax, imm32 */ \
29697 + case 0x0d: /* or eax, imm32 */ \
29698 + case 0xb8: /* mov eax, imm32 */ \
29699 + case 0x35: /* xor eax, imm32 */ \
29700 + case 0x3d: /* cmp eax, imm32 */ \
29701 + case 0xa9: /* test eax, imm32 */ \
29702 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29703 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29704 + break; \
29705 + case 0xbb: /* mov ebx, imm32 */ \
29706 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29707 + /* mov ebx, ecx */ \
29708 + EMIT2(0x89, 0xcb); \
29709 + break; \
29710 + case 0xbe: /* mov esi, imm32 */ \
29711 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29712 + /* mov esi, ecx */ \
29713 + EMIT2(0x89, 0xce); \
29714 + break; \
29715 + case 0xe8: /* call rel imm32, always to known funcs */ \
29716 + EMIT1(b1); \
29717 + EMIT(_off, 4); \
29718 + break; \
29719 + case 0xe9: /* jmp rel imm32 */ \
29720 + EMIT1(b1); \
29721 + EMIT(_off, 4); \
29722 + /* prevent fall-through, we're not called if off = 0 */ \
29723 + EMIT(0xcccccccc, 4); \
29724 + EMIT(0xcccccccc, 4); \
29725 + break; \
29726 + default: \
29727 + BUILD_BUG(); \
29728 + } \
29729 +} while (0)
29730 +
29731 +#define EMIT2_off32(b1, b2, _off) \
29732 +do { \
29733 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29734 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29735 + EMIT(randkey, 4); \
29736 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29737 + EMIT((_off) - randkey, 4); \
29738 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29739 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29740 + /* imul eax, ecx */ \
29741 + EMIT3(0x0f, 0xaf, 0xc1); \
29742 + } else { \
29743 + BUILD_BUG(); \
29744 + } \
29745 +} while (0)
29746 +#else
29747 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29748 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29749 +#endif
29750
29751 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29752 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29753 @@ -90,6 +168,24 @@ do { \
29754 #define X86_JBE 0x76
29755 #define X86_JA 0x77
29756
29757 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29758 +#define APPEND_FLOW_VERIFY() \
29759 +do { \
29760 + /* mov ecx, randkey */ \
29761 + EMIT1(0xb9); \
29762 + EMIT(randkey, 4); \
29763 + /* cmp ecx, randkey */ \
29764 + EMIT2(0x81, 0xf9); \
29765 + EMIT(randkey, 4); \
29766 + /* jz after 8 int 3s */ \
29767 + EMIT2(0x74, 0x08); \
29768 + EMIT(0xcccccccc, 4); \
29769 + EMIT(0xcccccccc, 4); \
29770 +} while (0)
29771 +#else
29772 +#define APPEND_FLOW_VERIFY() do { } while (0)
29773 +#endif
29774 +
29775 #define EMIT_COND_JMP(op, offset) \
29776 do { \
29777 if (is_near(offset)) \
29778 @@ -97,6 +193,7 @@ do { \
29779 else { \
29780 EMIT2(0x0f, op + 0x10); \
29781 EMIT(offset, 4); /* jxx .+off32 */ \
29782 + APPEND_FLOW_VERIFY(); \
29783 } \
29784 } while (0)
29785
29786 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29787 set_fs(old_fs);
29788 }
29789
29790 +struct bpf_jit_work {
29791 + struct work_struct work;
29792 + void *image;
29793 +};
29794 +
29795 #define CHOOSE_LOAD_FUNC(K, func) \
29796 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29797
29798 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29799
29800 void bpf_jit_compile(struct sk_filter *fp)
29801 {
29802 - u8 temp[64];
29803 + u8 temp[MAX_INSTR_CODE_SIZE];
29804 u8 *prog;
29805 unsigned int proglen, oldproglen = 0;
29806 int ilen, i;
29807 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29808 unsigned int *addrs;
29809 const struct sock_filter *filter = fp->insns;
29810 int flen = fp->len;
29811 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29812 + unsigned int randkey;
29813 +#endif
29814
29815 if (!bpf_jit_enable)
29816 return;
29817 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29818 if (addrs == NULL)
29819 return;
29820
29821 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29822 + if (!fp->work)
29823 + goto out;
29824 +
29825 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29826 + randkey = get_random_int();
29827 +#endif
29828 +
29829 /* Before first pass, make a rough estimation of addrs[]
29830 - * each bpf instruction is translated to less than 64 bytes
29831 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29832 */
29833 for (proglen = 0, i = 0; i < flen; i++) {
29834 - proglen += 64;
29835 + proglen += MAX_INSTR_CODE_SIZE;
29836 addrs[i] = proglen;
29837 }
29838 cleanup_addr = proglen; /* epilogue address */
29839 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29840 case BPF_S_ALU_MUL_K: /* A *= K */
29841 if (is_imm8(K))
29842 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29843 - else {
29844 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29845 - EMIT(K, 4);
29846 - }
29847 + else
29848 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29849 break;
29850 case BPF_S_ALU_DIV_X: /* A /= X; */
29851 seen |= SEEN_XREG;
29852 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29853 break;
29854 case BPF_S_ALU_MOD_K: /* A %= K; */
29855 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29856 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29857 + DILUTE_CONST_SEQUENCE(K, randkey);
29858 +#else
29859 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29860 +#endif
29861 EMIT2(0xf7, 0xf1); /* div %ecx */
29862 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29863 break;
29864 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29865 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29866 + DILUTE_CONST_SEQUENCE(K, randkey);
29867 + // imul rax, rcx
29868 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29869 +#else
29870 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29871 EMIT(K, 4);
29872 +#endif
29873 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29874 break;
29875 case BPF_S_ALU_AND_X:
29876 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29877 if (is_imm8(K)) {
29878 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29879 } else {
29880 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29881 - EMIT(K, 4);
29882 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29883 }
29884 } else {
29885 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29886 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29887 break;
29888 default:
29889 /* hmm, too complex filter, give up with jit compiler */
29890 - goto out;
29891 + goto error;
29892 }
29893 ilen = prog - temp;
29894 if (image) {
29895 if (unlikely(proglen + ilen > oldproglen)) {
29896 pr_err("bpb_jit_compile fatal error\n");
29897 - kfree(addrs);
29898 - module_free(NULL, image);
29899 - return;
29900 + module_free_exec(NULL, image);
29901 + goto error;
29902 }
29903 + pax_open_kernel();
29904 memcpy(image + proglen, temp, ilen);
29905 + pax_close_kernel();
29906 }
29907 proglen += ilen;
29908 addrs[i] = proglen;
29909 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29910 break;
29911 }
29912 if (proglen == oldproglen) {
29913 - image = module_alloc(max_t(unsigned int,
29914 - proglen,
29915 - sizeof(struct work_struct)));
29916 + image = module_alloc_exec(proglen);
29917 if (!image)
29918 - goto out;
29919 + goto error;
29920 }
29921 oldproglen = proglen;
29922 }
29923 @@ -732,7 +851,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29924 if (image) {
29925 bpf_flush_icache(image, image + proglen);
29926 fp->bpf_func = (void *)image;
29927 - }
29928 + } else
29929 +error:
29930 + kfree(fp->work);
29931 +
29932 out:
29933 kfree(addrs);
29934 return;
29935 @@ -740,18 +862,20 @@ out:
29936
29937 static void jit_free_defer(struct work_struct *arg)
29938 {
29939 - module_free(NULL, arg);
29940 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29941 + kfree(arg);
29942 }
29943
29944 /* run from softirq, we must use a work_struct to call
29945 - * module_free() from process context
29946 + * module_free_exec() from process context
29947 */
29948 void bpf_jit_free(struct sk_filter *fp)
29949 {
29950 if (fp->bpf_func != sk_run_filter) {
29951 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29952 + struct work_struct *work = &fp->work->work;
29953
29954 INIT_WORK(work, jit_free_defer);
29955 + fp->work->image = fp->bpf_func;
29956 schedule_work(work);
29957 }
29958 }
29959 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29960 index d6aa6e8..266395a 100644
29961 --- a/arch/x86/oprofile/backtrace.c
29962 +++ b/arch/x86/oprofile/backtrace.c
29963 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29964 struct stack_frame_ia32 *fp;
29965 unsigned long bytes;
29966
29967 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29968 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29969 if (bytes != sizeof(bufhead))
29970 return NULL;
29971
29972 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29973 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29974
29975 oprofile_add_trace(bufhead[0].return_address);
29976
29977 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29978 struct stack_frame bufhead[2];
29979 unsigned long bytes;
29980
29981 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29982 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29983 if (bytes != sizeof(bufhead))
29984 return NULL;
29985
29986 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29987 {
29988 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29989
29990 - if (!user_mode_vm(regs)) {
29991 + if (!user_mode(regs)) {
29992 unsigned long stack = kernel_stack_pointer(regs);
29993 if (depth)
29994 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29995 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29996 index 48768df..ba9143c 100644
29997 --- a/arch/x86/oprofile/nmi_int.c
29998 +++ b/arch/x86/oprofile/nmi_int.c
29999 @@ -23,6 +23,7 @@
30000 #include <asm/nmi.h>
30001 #include <asm/msr.h>
30002 #include <asm/apic.h>
30003 +#include <asm/pgtable.h>
30004
30005 #include "op_counter.h"
30006 #include "op_x86_model.h"
30007 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30008 if (ret)
30009 return ret;
30010
30011 - if (!model->num_virt_counters)
30012 - model->num_virt_counters = model->num_counters;
30013 + if (!model->num_virt_counters) {
30014 + pax_open_kernel();
30015 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30016 + pax_close_kernel();
30017 + }
30018
30019 mux_init(ops);
30020
30021 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30022 index b2b9443..be58856 100644
30023 --- a/arch/x86/oprofile/op_model_amd.c
30024 +++ b/arch/x86/oprofile/op_model_amd.c
30025 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30026 num_counters = AMD64_NUM_COUNTERS;
30027 }
30028
30029 - op_amd_spec.num_counters = num_counters;
30030 - op_amd_spec.num_controls = num_counters;
30031 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30032 + pax_open_kernel();
30033 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30034 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30035 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30036 + pax_close_kernel();
30037
30038 return 0;
30039 }
30040 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30041 index d90528e..0127e2b 100644
30042 --- a/arch/x86/oprofile/op_model_ppro.c
30043 +++ b/arch/x86/oprofile/op_model_ppro.c
30044 @@ -19,6 +19,7 @@
30045 #include <asm/msr.h>
30046 #include <asm/apic.h>
30047 #include <asm/nmi.h>
30048 +#include <asm/pgtable.h>
30049
30050 #include "op_x86_model.h"
30051 #include "op_counter.h"
30052 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30053
30054 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30055
30056 - op_arch_perfmon_spec.num_counters = num_counters;
30057 - op_arch_perfmon_spec.num_controls = num_counters;
30058 + pax_open_kernel();
30059 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30060 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30061 + pax_close_kernel();
30062 }
30063
30064 static int arch_perfmon_init(struct oprofile_operations *ignore)
30065 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30066 index 71e8a67..6a313bb 100644
30067 --- a/arch/x86/oprofile/op_x86_model.h
30068 +++ b/arch/x86/oprofile/op_x86_model.h
30069 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30070 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30071 struct op_msrs const * const msrs);
30072 #endif
30073 -};
30074 +} __do_const;
30075
30076 struct op_counter_config;
30077
30078 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30079 index e9e6ed5..e47ae67 100644
30080 --- a/arch/x86/pci/amd_bus.c
30081 +++ b/arch/x86/pci/amd_bus.c
30082 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30083 return NOTIFY_OK;
30084 }
30085
30086 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30087 +static struct notifier_block amd_cpu_notifier = {
30088 .notifier_call = amd_cpu_notify,
30089 };
30090
30091 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30092 index 372e9b8..e775a6c 100644
30093 --- a/arch/x86/pci/irq.c
30094 +++ b/arch/x86/pci/irq.c
30095 @@ -50,7 +50,7 @@ struct irq_router {
30096 struct irq_router_handler {
30097 u16 vendor;
30098 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30099 -};
30100 +} __do_const;
30101
30102 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30103 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30104 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30105 return 0;
30106 }
30107
30108 -static __initdata struct irq_router_handler pirq_routers[] = {
30109 +static __initconst const struct irq_router_handler pirq_routers[] = {
30110 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30111 { PCI_VENDOR_ID_AL, ali_router_probe },
30112 { PCI_VENDOR_ID_ITE, ite_router_probe },
30113 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30114 static void __init pirq_find_router(struct irq_router *r)
30115 {
30116 struct irq_routing_table *rt = pirq_table;
30117 - struct irq_router_handler *h;
30118 + const struct irq_router_handler *h;
30119
30120 #ifdef CONFIG_PCI_BIOS
30121 if (!rt->signature) {
30122 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30123 return 0;
30124 }
30125
30126 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30127 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30128 {
30129 .callback = fix_broken_hp_bios_irq9,
30130 .ident = "HP Pavilion N5400 Series Laptop",
30131 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30132 index 6eb18c4..20d83de 100644
30133 --- a/arch/x86/pci/mrst.c
30134 +++ b/arch/x86/pci/mrst.c
30135 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30136 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30137 pci_mmcfg_late_init();
30138 pcibios_enable_irq = mrst_pci_irq_enable;
30139 - pci_root_ops = pci_mrst_ops;
30140 + pax_open_kernel();
30141 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30142 + pax_close_kernel();
30143 pci_soc_mode = 1;
30144 /* Continue with standard init */
30145 return 1;
30146 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30147 index c77b24a..c979855 100644
30148 --- a/arch/x86/pci/pcbios.c
30149 +++ b/arch/x86/pci/pcbios.c
30150 @@ -79,7 +79,7 @@ union bios32 {
30151 static struct {
30152 unsigned long address;
30153 unsigned short segment;
30154 -} bios32_indirect = { 0, __KERNEL_CS };
30155 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30156
30157 /*
30158 * Returns the entry point for the given service, NULL on error
30159 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30160 unsigned long length; /* %ecx */
30161 unsigned long entry; /* %edx */
30162 unsigned long flags;
30163 + struct desc_struct d, *gdt;
30164
30165 local_irq_save(flags);
30166 - __asm__("lcall *(%%edi); cld"
30167 +
30168 + gdt = get_cpu_gdt_table(smp_processor_id());
30169 +
30170 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30171 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30172 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30173 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30174 +
30175 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30176 : "=a" (return_code),
30177 "=b" (address),
30178 "=c" (length),
30179 "=d" (entry)
30180 : "0" (service),
30181 "1" (0),
30182 - "D" (&bios32_indirect));
30183 + "D" (&bios32_indirect),
30184 + "r"(__PCIBIOS_DS)
30185 + : "memory");
30186 +
30187 + pax_open_kernel();
30188 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30189 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30190 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30191 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30192 + pax_close_kernel();
30193 +
30194 local_irq_restore(flags);
30195
30196 switch (return_code) {
30197 - case 0:
30198 - return address + entry;
30199 - case 0x80: /* Not present */
30200 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30201 - return 0;
30202 - default: /* Shouldn't happen */
30203 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30204 - service, return_code);
30205 + case 0: {
30206 + int cpu;
30207 + unsigned char flags;
30208 +
30209 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30210 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30211 + printk(KERN_WARNING "bios32_service: not valid\n");
30212 return 0;
30213 + }
30214 + address = address + PAGE_OFFSET;
30215 + length += 16UL; /* some BIOSs underreport this... */
30216 + flags = 4;
30217 + if (length >= 64*1024*1024) {
30218 + length >>= PAGE_SHIFT;
30219 + flags |= 8;
30220 + }
30221 +
30222 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30223 + gdt = get_cpu_gdt_table(cpu);
30224 + pack_descriptor(&d, address, length, 0x9b, flags);
30225 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30226 + pack_descriptor(&d, address, length, 0x93, flags);
30227 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30228 + }
30229 + return entry;
30230 + }
30231 + case 0x80: /* Not present */
30232 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30233 + return 0;
30234 + default: /* Shouldn't happen */
30235 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30236 + service, return_code);
30237 + return 0;
30238 }
30239 }
30240
30241 static struct {
30242 unsigned long address;
30243 unsigned short segment;
30244 -} pci_indirect = { 0, __KERNEL_CS };
30245 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30246
30247 -static int pci_bios_present;
30248 +static int pci_bios_present __read_only;
30249
30250 static int check_pcibios(void)
30251 {
30252 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30253 unsigned long flags, pcibios_entry;
30254
30255 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30256 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30257 + pci_indirect.address = pcibios_entry;
30258
30259 local_irq_save(flags);
30260 - __asm__(
30261 - "lcall *(%%edi); cld\n\t"
30262 + __asm__("movw %w6, %%ds\n\t"
30263 + "lcall *%%ss:(%%edi); cld\n\t"
30264 + "push %%ss\n\t"
30265 + "pop %%ds\n\t"
30266 "jc 1f\n\t"
30267 "xor %%ah, %%ah\n"
30268 "1:"
30269 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30270 "=b" (ebx),
30271 "=c" (ecx)
30272 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30273 - "D" (&pci_indirect)
30274 + "D" (&pci_indirect),
30275 + "r" (__PCIBIOS_DS)
30276 : "memory");
30277 local_irq_restore(flags);
30278
30279 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30280
30281 switch (len) {
30282 case 1:
30283 - __asm__("lcall *(%%esi); cld\n\t"
30284 + __asm__("movw %w6, %%ds\n\t"
30285 + "lcall *%%ss:(%%esi); cld\n\t"
30286 + "push %%ss\n\t"
30287 + "pop %%ds\n\t"
30288 "jc 1f\n\t"
30289 "xor %%ah, %%ah\n"
30290 "1:"
30291 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30292 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30293 "b" (bx),
30294 "D" ((long)reg),
30295 - "S" (&pci_indirect));
30296 + "S" (&pci_indirect),
30297 + "r" (__PCIBIOS_DS));
30298 /*
30299 * Zero-extend the result beyond 8 bits, do not trust the
30300 * BIOS having done it:
30301 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30302 *value &= 0xff;
30303 break;
30304 case 2:
30305 - __asm__("lcall *(%%esi); cld\n\t"
30306 + __asm__("movw %w6, %%ds\n\t"
30307 + "lcall *%%ss:(%%esi); cld\n\t"
30308 + "push %%ss\n\t"
30309 + "pop %%ds\n\t"
30310 "jc 1f\n\t"
30311 "xor %%ah, %%ah\n"
30312 "1:"
30313 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30314 : "1" (PCIBIOS_READ_CONFIG_WORD),
30315 "b" (bx),
30316 "D" ((long)reg),
30317 - "S" (&pci_indirect));
30318 + "S" (&pci_indirect),
30319 + "r" (__PCIBIOS_DS));
30320 /*
30321 * Zero-extend the result beyond 16 bits, do not trust the
30322 * BIOS having done it:
30323 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30324 *value &= 0xffff;
30325 break;
30326 case 4:
30327 - __asm__("lcall *(%%esi); cld\n\t"
30328 + __asm__("movw %w6, %%ds\n\t"
30329 + "lcall *%%ss:(%%esi); cld\n\t"
30330 + "push %%ss\n\t"
30331 + "pop %%ds\n\t"
30332 "jc 1f\n\t"
30333 "xor %%ah, %%ah\n"
30334 "1:"
30335 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30336 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30337 "b" (bx),
30338 "D" ((long)reg),
30339 - "S" (&pci_indirect));
30340 + "S" (&pci_indirect),
30341 + "r" (__PCIBIOS_DS));
30342 break;
30343 }
30344
30345 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30346
30347 switch (len) {
30348 case 1:
30349 - __asm__("lcall *(%%esi); cld\n\t"
30350 + __asm__("movw %w6, %%ds\n\t"
30351 + "lcall *%%ss:(%%esi); cld\n\t"
30352 + "push %%ss\n\t"
30353 + "pop %%ds\n\t"
30354 "jc 1f\n\t"
30355 "xor %%ah, %%ah\n"
30356 "1:"
30357 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30358 "c" (value),
30359 "b" (bx),
30360 "D" ((long)reg),
30361 - "S" (&pci_indirect));
30362 + "S" (&pci_indirect),
30363 + "r" (__PCIBIOS_DS));
30364 break;
30365 case 2:
30366 - __asm__("lcall *(%%esi); cld\n\t"
30367 + __asm__("movw %w6, %%ds\n\t"
30368 + "lcall *%%ss:(%%esi); cld\n\t"
30369 + "push %%ss\n\t"
30370 + "pop %%ds\n\t"
30371 "jc 1f\n\t"
30372 "xor %%ah, %%ah\n"
30373 "1:"
30374 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30375 "c" (value),
30376 "b" (bx),
30377 "D" ((long)reg),
30378 - "S" (&pci_indirect));
30379 + "S" (&pci_indirect),
30380 + "r" (__PCIBIOS_DS));
30381 break;
30382 case 4:
30383 - __asm__("lcall *(%%esi); cld\n\t"
30384 + __asm__("movw %w6, %%ds\n\t"
30385 + "lcall *%%ss:(%%esi); cld\n\t"
30386 + "push %%ss\n\t"
30387 + "pop %%ds\n\t"
30388 "jc 1f\n\t"
30389 "xor %%ah, %%ah\n"
30390 "1:"
30391 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30392 "c" (value),
30393 "b" (bx),
30394 "D" ((long)reg),
30395 - "S" (&pci_indirect));
30396 + "S" (&pci_indirect),
30397 + "r" (__PCIBIOS_DS));
30398 break;
30399 }
30400
30401 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30402
30403 DBG("PCI: Fetching IRQ routing table... ");
30404 __asm__("push %%es\n\t"
30405 + "movw %w8, %%ds\n\t"
30406 "push %%ds\n\t"
30407 "pop %%es\n\t"
30408 - "lcall *(%%esi); cld\n\t"
30409 + "lcall *%%ss:(%%esi); cld\n\t"
30410 "pop %%es\n\t"
30411 + "push %%ss\n\t"
30412 + "pop %%ds\n"
30413 "jc 1f\n\t"
30414 "xor %%ah, %%ah\n"
30415 "1:"
30416 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30417 "1" (0),
30418 "D" ((long) &opt),
30419 "S" (&pci_indirect),
30420 - "m" (opt)
30421 + "m" (opt),
30422 + "r" (__PCIBIOS_DS)
30423 : "memory");
30424 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30425 if (ret & 0xff00)
30426 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30427 {
30428 int ret;
30429
30430 - __asm__("lcall *(%%esi); cld\n\t"
30431 + __asm__("movw %w5, %%ds\n\t"
30432 + "lcall *%%ss:(%%esi); cld\n\t"
30433 + "push %%ss\n\t"
30434 + "pop %%ds\n"
30435 "jc 1f\n\t"
30436 "xor %%ah, %%ah\n"
30437 "1:"
30438 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30439 : "0" (PCIBIOS_SET_PCI_HW_INT),
30440 "b" ((dev->bus->number << 8) | dev->devfn),
30441 "c" ((irq << 8) | (pin + 10)),
30442 - "S" (&pci_indirect));
30443 + "S" (&pci_indirect),
30444 + "r" (__PCIBIOS_DS));
30445 return !(ret & 0xff00);
30446 }
30447 EXPORT_SYMBOL(pcibios_set_irq_routing);
30448 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30449 index 40e4469..0592924 100644
30450 --- a/arch/x86/platform/efi/efi_32.c
30451 +++ b/arch/x86/platform/efi/efi_32.c
30452 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30453 {
30454 struct desc_ptr gdt_descr;
30455
30456 +#ifdef CONFIG_PAX_KERNEXEC
30457 + struct desc_struct d;
30458 +#endif
30459 +
30460 local_irq_save(efi_rt_eflags);
30461
30462 load_cr3(initial_page_table);
30463 __flush_tlb_all();
30464
30465 +#ifdef CONFIG_PAX_KERNEXEC
30466 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30467 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30468 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30469 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30470 +#endif
30471 +
30472 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30473 gdt_descr.size = GDT_SIZE - 1;
30474 load_gdt(&gdt_descr);
30475 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
30476 {
30477 struct desc_ptr gdt_descr;
30478
30479 +#ifdef CONFIG_PAX_KERNEXEC
30480 + struct desc_struct d;
30481 +
30482 + memset(&d, 0, sizeof d);
30483 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30484 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30485 +#endif
30486 +
30487 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30488 gdt_descr.size = GDT_SIZE - 1;
30489 load_gdt(&gdt_descr);
30490
30491 +#ifdef CONFIG_PAX_PER_CPU_PGD
30492 + load_cr3(get_cpu_pgd(smp_processor_id()));
30493 +#else
30494 load_cr3(swapper_pg_dir);
30495 +#endif
30496 +
30497 __flush_tlb_all();
30498
30499 local_irq_restore(efi_rt_eflags);
30500 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
30501 index 39a0e7f1..ecc2f1e 100644
30502 --- a/arch/x86/platform/efi/efi_64.c
30503 +++ b/arch/x86/platform/efi/efi_64.c
30504 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
30505 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
30506 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
30507 }
30508 +
30509 +#ifdef CONFIG_PAX_PER_CPU_PGD
30510 + load_cr3(swapper_pg_dir);
30511 +#endif
30512 +
30513 __flush_tlb_all();
30514 }
30515
30516 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
30517 for (pgd = 0; pgd < n_pgds; pgd++)
30518 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
30519 kfree(save_pgd);
30520 +
30521 +#ifdef CONFIG_PAX_PER_CPU_PGD
30522 + load_cr3(get_cpu_pgd(smp_processor_id()));
30523 +#endif
30524 +
30525 __flush_tlb_all();
30526 local_irq_restore(efi_flags);
30527 early_code_mapping_set_exec(0);
30528 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30529 index fbe66e6..eae5e38 100644
30530 --- a/arch/x86/platform/efi/efi_stub_32.S
30531 +++ b/arch/x86/platform/efi/efi_stub_32.S
30532 @@ -6,7 +6,9 @@
30533 */
30534
30535 #include <linux/linkage.h>
30536 +#include <linux/init.h>
30537 #include <asm/page_types.h>
30538 +#include <asm/segment.h>
30539
30540 /*
30541 * efi_call_phys(void *, ...) is a function with variable parameters.
30542 @@ -20,7 +22,7 @@
30543 * service functions will comply with gcc calling convention, too.
30544 */
30545
30546 -.text
30547 +__INIT
30548 ENTRY(efi_call_phys)
30549 /*
30550 * 0. The function can only be called in Linux kernel. So CS has been
30551 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30552 * The mapping of lower virtual memory has been created in prelog and
30553 * epilog.
30554 */
30555 - movl $1f, %edx
30556 - subl $__PAGE_OFFSET, %edx
30557 - jmp *%edx
30558 +#ifdef CONFIG_PAX_KERNEXEC
30559 + movl $(__KERNEXEC_EFI_DS), %edx
30560 + mov %edx, %ds
30561 + mov %edx, %es
30562 + mov %edx, %ss
30563 + addl $2f,(1f)
30564 + ljmp *(1f)
30565 +
30566 +__INITDATA
30567 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30568 +.previous
30569 +
30570 +2:
30571 + subl $2b,(1b)
30572 +#else
30573 + jmp 1f-__PAGE_OFFSET
30574 1:
30575 +#endif
30576
30577 /*
30578 * 2. Now on the top of stack is the return
30579 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30580 * parameter 2, ..., param n. To make things easy, we save the return
30581 * address of efi_call_phys in a global variable.
30582 */
30583 - popl %edx
30584 - movl %edx, saved_return_addr
30585 - /* get the function pointer into ECX*/
30586 - popl %ecx
30587 - movl %ecx, efi_rt_function_ptr
30588 - movl $2f, %edx
30589 - subl $__PAGE_OFFSET, %edx
30590 - pushl %edx
30591 + popl (saved_return_addr)
30592 + popl (efi_rt_function_ptr)
30593
30594 /*
30595 * 3. Clear PG bit in %CR0.
30596 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30597 /*
30598 * 5. Call the physical function.
30599 */
30600 - jmp *%ecx
30601 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30602
30603 -2:
30604 /*
30605 * 6. After EFI runtime service returns, control will return to
30606 * following instruction. We'd better readjust stack pointer first.
30607 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30608 movl %cr0, %edx
30609 orl $0x80000000, %edx
30610 movl %edx, %cr0
30611 - jmp 1f
30612 -1:
30613 +
30614 /*
30615 * 8. Now restore the virtual mode from flat mode by
30616 * adding EIP with PAGE_OFFSET.
30617 */
30618 - movl $1f, %edx
30619 - jmp *%edx
30620 +#ifdef CONFIG_PAX_KERNEXEC
30621 + movl $(__KERNEL_DS), %edx
30622 + mov %edx, %ds
30623 + mov %edx, %es
30624 + mov %edx, %ss
30625 + ljmp $(__KERNEL_CS),$1f
30626 +#else
30627 + jmp 1f+__PAGE_OFFSET
30628 +#endif
30629 1:
30630
30631 /*
30632 * 9. Balance the stack. And because EAX contain the return value,
30633 * we'd better not clobber it.
30634 */
30635 - leal efi_rt_function_ptr, %edx
30636 - movl (%edx), %ecx
30637 - pushl %ecx
30638 + pushl (efi_rt_function_ptr)
30639
30640 /*
30641 - * 10. Push the saved return address onto the stack and return.
30642 + * 10. Return to the saved return address.
30643 */
30644 - leal saved_return_addr, %edx
30645 - movl (%edx), %ecx
30646 - pushl %ecx
30647 - ret
30648 + jmpl *(saved_return_addr)
30649 ENDPROC(efi_call_phys)
30650 .previous
30651
30652 -.data
30653 +__INITDATA
30654 saved_return_addr:
30655 .long 0
30656 efi_rt_function_ptr:
30657 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30658 index 4c07cca..2c8427d 100644
30659 --- a/arch/x86/platform/efi/efi_stub_64.S
30660 +++ b/arch/x86/platform/efi/efi_stub_64.S
30661 @@ -7,6 +7,7 @@
30662 */
30663
30664 #include <linux/linkage.h>
30665 +#include <asm/alternative-asm.h>
30666
30667 #define SAVE_XMM \
30668 mov %rsp, %rax; \
30669 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30670 call *%rdi
30671 addq $32, %rsp
30672 RESTORE_XMM
30673 + pax_force_retaddr 0, 1
30674 ret
30675 ENDPROC(efi_call0)
30676
30677 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30678 call *%rdi
30679 addq $32, %rsp
30680 RESTORE_XMM
30681 + pax_force_retaddr 0, 1
30682 ret
30683 ENDPROC(efi_call1)
30684
30685 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30686 call *%rdi
30687 addq $32, %rsp
30688 RESTORE_XMM
30689 + pax_force_retaddr 0, 1
30690 ret
30691 ENDPROC(efi_call2)
30692
30693 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30694 call *%rdi
30695 addq $32, %rsp
30696 RESTORE_XMM
30697 + pax_force_retaddr 0, 1
30698 ret
30699 ENDPROC(efi_call3)
30700
30701 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30702 call *%rdi
30703 addq $32, %rsp
30704 RESTORE_XMM
30705 + pax_force_retaddr 0, 1
30706 ret
30707 ENDPROC(efi_call4)
30708
30709 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30710 call *%rdi
30711 addq $48, %rsp
30712 RESTORE_XMM
30713 + pax_force_retaddr 0, 1
30714 ret
30715 ENDPROC(efi_call5)
30716
30717 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30718 call *%rdi
30719 addq $48, %rsp
30720 RESTORE_XMM
30721 + pax_force_retaddr 0, 1
30722 ret
30723 ENDPROC(efi_call6)
30724 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30725 index a0a0a43..a48e233 100644
30726 --- a/arch/x86/platform/mrst/mrst.c
30727 +++ b/arch/x86/platform/mrst/mrst.c
30728 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30729 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30730 int sfi_mrtc_num;
30731
30732 -static void mrst_power_off(void)
30733 +static __noreturn void mrst_power_off(void)
30734 {
30735 + BUG();
30736 }
30737
30738 -static void mrst_reboot(void)
30739 +static __noreturn void mrst_reboot(void)
30740 {
30741 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30742 + BUG();
30743 }
30744
30745 /* parse all the mtimer info to a static mtimer array */
30746 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30747 index d6ee929..3637cb5 100644
30748 --- a/arch/x86/platform/olpc/olpc_dt.c
30749 +++ b/arch/x86/platform/olpc/olpc_dt.c
30750 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30751 return res;
30752 }
30753
30754 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30755 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30756 .nextprop = olpc_dt_nextprop,
30757 .getproplen = olpc_dt_getproplen,
30758 .getproperty = olpc_dt_getproperty,
30759 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30760 index 1cf5b30..fd45732 100644
30761 --- a/arch/x86/power/cpu.c
30762 +++ b/arch/x86/power/cpu.c
30763 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
30764 static void fix_processor_context(void)
30765 {
30766 int cpu = smp_processor_id();
30767 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30768 -#ifdef CONFIG_X86_64
30769 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
30770 - tss_desc tss;
30771 -#endif
30772 + struct tss_struct *t = init_tss + cpu;
30773 +
30774 set_tss_desc(cpu, t); /*
30775 * This just modifies memory; should not be
30776 * necessary. But... This is necessary, because
30777 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
30778 */
30779
30780 #ifdef CONFIG_X86_64
30781 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
30782 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
30783 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
30784 -
30785 syscall_init(); /* This sets MSR_*STAR and related */
30786 #endif
30787 load_TR_desc(); /* This does ltr */
30788 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30789 index a44f457..9140171 100644
30790 --- a/arch/x86/realmode/init.c
30791 +++ b/arch/x86/realmode/init.c
30792 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30793 __va(real_mode_header->trampoline_header);
30794
30795 #ifdef CONFIG_X86_32
30796 - trampoline_header->start = __pa_symbol(startup_32_smp);
30797 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30798 +
30799 +#ifdef CONFIG_PAX_KERNEXEC
30800 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30801 +#endif
30802 +
30803 + trampoline_header->boot_cs = __BOOT_CS;
30804 trampoline_header->gdt_limit = __BOOT_DS + 7;
30805 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30806 #else
30807 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30808 *trampoline_cr4_features = read_cr4();
30809
30810 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30811 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30812 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30813 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30814 #endif
30815 }
30816 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30817 index 8869287..d577672 100644
30818 --- a/arch/x86/realmode/rm/Makefile
30819 +++ b/arch/x86/realmode/rm/Makefile
30820 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30821 $(call cc-option, -fno-unit-at-a-time)) \
30822 $(call cc-option, -fno-stack-protector) \
30823 $(call cc-option, -mpreferred-stack-boundary=2)
30824 +ifdef CONSTIFY_PLUGIN
30825 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30826 +endif
30827 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30828 GCOV_PROFILE := n
30829 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30830 index a28221d..93c40f1 100644
30831 --- a/arch/x86/realmode/rm/header.S
30832 +++ b/arch/x86/realmode/rm/header.S
30833 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30834 #endif
30835 /* APM/BIOS reboot */
30836 .long pa_machine_real_restart_asm
30837 -#ifdef CONFIG_X86_64
30838 +#ifdef CONFIG_X86_32
30839 + .long __KERNEL_CS
30840 +#else
30841 .long __KERNEL32_CS
30842 #endif
30843 END(real_mode_header)
30844 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30845 index c1b2791..f9e31c7 100644
30846 --- a/arch/x86/realmode/rm/trampoline_32.S
30847 +++ b/arch/x86/realmode/rm/trampoline_32.S
30848 @@ -25,6 +25,12 @@
30849 #include <asm/page_types.h>
30850 #include "realmode.h"
30851
30852 +#ifdef CONFIG_PAX_KERNEXEC
30853 +#define ta(X) (X)
30854 +#else
30855 +#define ta(X) (pa_ ## X)
30856 +#endif
30857 +
30858 .text
30859 .code16
30860
30861 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30862
30863 cli # We should be safe anyway
30864
30865 - movl tr_start, %eax # where we need to go
30866 -
30867 movl $0xA5A5A5A5, trampoline_status
30868 # write marker for master knows we're running
30869
30870 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30871 movw $1, %dx # protected mode (PE) bit
30872 lmsw %dx # into protected mode
30873
30874 - ljmpl $__BOOT_CS, $pa_startup_32
30875 + ljmpl *(trampoline_header)
30876
30877 .section ".text32","ax"
30878 .code32
30879 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30880 .balign 8
30881 GLOBAL(trampoline_header)
30882 tr_start: .space 4
30883 - tr_gdt_pad: .space 2
30884 + tr_boot_cs: .space 2
30885 tr_gdt: .space 6
30886 END(trampoline_header)
30887
30888 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30889 index bb360dc..3e5945f 100644
30890 --- a/arch/x86/realmode/rm/trampoline_64.S
30891 +++ b/arch/x86/realmode/rm/trampoline_64.S
30892 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30893 wrmsr
30894
30895 # Enable paging and in turn activate Long Mode
30896 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30897 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30898 movl %eax, %cr0
30899
30900 /*
30901 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
30902 index e812034..c747134 100644
30903 --- a/arch/x86/tools/Makefile
30904 +++ b/arch/x86/tools/Makefile
30905 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
30906
30907 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
30908
30909 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
30910 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
30911 hostprogs-y += relocs
30912 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
30913 relocs: $(obj)/relocs
30914 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30915 index f7bab68..b6d9886 100644
30916 --- a/arch/x86/tools/relocs.c
30917 +++ b/arch/x86/tools/relocs.c
30918 @@ -1,5 +1,7 @@
30919 /* This is included from relocs_32/64.c */
30920
30921 +#include "../../../include/generated/autoconf.h"
30922 +
30923 #define ElfW(type) _ElfW(ELF_BITS, type)
30924 #define _ElfW(bits, type) __ElfW(bits, type)
30925 #define __ElfW(bits, type) Elf##bits##_##type
30926 @@ -11,6 +13,7 @@
30927 #define Elf_Sym ElfW(Sym)
30928
30929 static Elf_Ehdr ehdr;
30930 +static Elf_Phdr *phdr;
30931
30932 struct relocs {
30933 uint32_t *offset;
30934 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
30935 }
30936 }
30937
30938 +static void read_phdrs(FILE *fp)
30939 +{
30940 + unsigned int i;
30941 +
30942 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
30943 + if (!phdr) {
30944 + die("Unable to allocate %d program headers\n",
30945 + ehdr.e_phnum);
30946 + }
30947 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30948 + die("Seek to %d failed: %s\n",
30949 + ehdr.e_phoff, strerror(errno));
30950 + }
30951 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30952 + die("Cannot read ELF program headers: %s\n",
30953 + strerror(errno));
30954 + }
30955 + for(i = 0; i < ehdr.e_phnum; i++) {
30956 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
30957 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
30958 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
30959 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
30960 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
30961 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
30962 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
30963 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
30964 + }
30965 +
30966 +}
30967 +
30968 static void read_shdrs(FILE *fp)
30969 {
30970 - int i;
30971 + unsigned int i;
30972 Elf_Shdr shdr;
30973
30974 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30975 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
30976
30977 static void read_strtabs(FILE *fp)
30978 {
30979 - int i;
30980 + unsigned int i;
30981 for (i = 0; i < ehdr.e_shnum; i++) {
30982 struct section *sec = &secs[i];
30983 if (sec->shdr.sh_type != SHT_STRTAB) {
30984 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
30985
30986 static void read_symtabs(FILE *fp)
30987 {
30988 - int i,j;
30989 + unsigned int i,j;
30990 for (i = 0; i < ehdr.e_shnum; i++) {
30991 struct section *sec = &secs[i];
30992 if (sec->shdr.sh_type != SHT_SYMTAB) {
30993 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
30994 }
30995
30996
30997 -static void read_relocs(FILE *fp)
30998 +static void read_relocs(FILE *fp, int use_real_mode)
30999 {
31000 - int i,j;
31001 + unsigned int i,j;
31002 + uint32_t base;
31003 +
31004 for (i = 0; i < ehdr.e_shnum; i++) {
31005 struct section *sec = &secs[i];
31006 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31007 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
31008 die("Cannot read symbol table: %s\n",
31009 strerror(errno));
31010 }
31011 + base = 0;
31012 +
31013 +#ifdef CONFIG_X86_32
31014 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31015 + if (phdr[j].p_type != PT_LOAD )
31016 + continue;
31017 + 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)
31018 + continue;
31019 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31020 + break;
31021 + }
31022 +#endif
31023 +
31024 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
31025 Elf_Rel *rel = &sec->reltab[j];
31026 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
31027 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
31028 rel->r_info = elf_xword_to_cpu(rel->r_info);
31029 #if (SHT_REL_TYPE == SHT_RELA)
31030 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
31031 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
31032
31033 static void print_absolute_symbols(void)
31034 {
31035 - int i;
31036 + unsigned int i;
31037 const char *format;
31038
31039 if (ELF_BITS == 64)
31040 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
31041 for (i = 0; i < ehdr.e_shnum; i++) {
31042 struct section *sec = &secs[i];
31043 char *sym_strtab;
31044 - int j;
31045 + unsigned int j;
31046
31047 if (sec->shdr.sh_type != SHT_SYMTAB) {
31048 continue;
31049 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
31050
31051 static void print_absolute_relocs(void)
31052 {
31053 - int i, printed = 0;
31054 + unsigned int i, printed = 0;
31055 const char *format;
31056
31057 if (ELF_BITS == 64)
31058 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
31059 struct section *sec_applies, *sec_symtab;
31060 char *sym_strtab;
31061 Elf_Sym *sh_symtab;
31062 - int j;
31063 + unsigned int j;
31064 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31065 continue;
31066 }
31067 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
31068 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
31069 Elf_Sym *sym, const char *symname))
31070 {
31071 - int i;
31072 + unsigned int i;
31073 /* Walk through the relocations */
31074 for (i = 0; i < ehdr.e_shnum; i++) {
31075 char *sym_strtab;
31076 Elf_Sym *sh_symtab;
31077 struct section *sec_applies, *sec_symtab;
31078 - int j;
31079 + unsigned int j;
31080 struct section *sec = &secs[i];
31081
31082 if (sec->shdr.sh_type != SHT_REL_TYPE) {
31083 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31084 {
31085 unsigned r_type = ELF32_R_TYPE(rel->r_info);
31086 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
31087 + char *sym_strtab = sec->link->link->strtab;
31088 +
31089 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31090 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31091 + return 0;
31092 +
31093 +#ifdef CONFIG_PAX_KERNEXEC
31094 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31095 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31096 + return 0;
31097 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31098 + return 0;
31099 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31100 + return 0;
31101 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31102 + return 0;
31103 +#endif
31104
31105 switch (r_type) {
31106 case R_386_NONE:
31107 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
31108
31109 static void emit_relocs(int as_text, int use_real_mode)
31110 {
31111 - int i;
31112 + unsigned int i;
31113 int (*write_reloc)(uint32_t, FILE *) = write32;
31114 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31115 const char *symname);
31116 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
31117 {
31118 regex_init(use_real_mode);
31119 read_ehdr(fp);
31120 + read_phdrs(fp);
31121 read_shdrs(fp);
31122 read_strtabs(fp);
31123 read_symtabs(fp);
31124 - read_relocs(fp);
31125 + read_relocs(fp, use_real_mode);
31126 if (ELF_BITS == 64)
31127 percpu_init();
31128 if (show_absolute_syms) {
31129 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
31130 index 80ffa5b..a33bd15 100644
31131 --- a/arch/x86/um/tls_32.c
31132 +++ b/arch/x86/um/tls_32.c
31133 @@ -260,7 +260,7 @@ out:
31134 if (unlikely(task == current &&
31135 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
31136 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
31137 - "without flushed TLS.", current->pid);
31138 + "without flushed TLS.", task_pid_nr(current));
31139 }
31140
31141 return 0;
31142 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31143 index fd14be1..e3c79c0 100644
31144 --- a/arch/x86/vdso/Makefile
31145 +++ b/arch/x86/vdso/Makefile
31146 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31147 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31148 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31149
31150 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31151 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31152 GCOV_PROFILE := n
31153
31154 #
31155 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31156 index 0faad64..39ef157 100644
31157 --- a/arch/x86/vdso/vdso32-setup.c
31158 +++ b/arch/x86/vdso/vdso32-setup.c
31159 @@ -25,6 +25,7 @@
31160 #include <asm/tlbflush.h>
31161 #include <asm/vdso.h>
31162 #include <asm/proto.h>
31163 +#include <asm/mman.h>
31164
31165 enum {
31166 VDSO_DISABLED = 0,
31167 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31168 void enable_sep_cpu(void)
31169 {
31170 int cpu = get_cpu();
31171 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31172 + struct tss_struct *tss = init_tss + cpu;
31173
31174 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31175 put_cpu();
31176 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31177 gate_vma.vm_start = FIXADDR_USER_START;
31178 gate_vma.vm_end = FIXADDR_USER_END;
31179 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31180 - gate_vma.vm_page_prot = __P101;
31181 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31182
31183 return 0;
31184 }
31185 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31186 if (compat)
31187 addr = VDSO_HIGH_BASE;
31188 else {
31189 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31190 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31191 if (IS_ERR_VALUE(addr)) {
31192 ret = addr;
31193 goto up_fail;
31194 }
31195 }
31196
31197 - current->mm->context.vdso = (void *)addr;
31198 + current->mm->context.vdso = addr;
31199
31200 if (compat_uses_vma || !compat) {
31201 /*
31202 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31203 }
31204
31205 current_thread_info()->sysenter_return =
31206 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31207 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31208
31209 up_fail:
31210 if (ret)
31211 - current->mm->context.vdso = NULL;
31212 + current->mm->context.vdso = 0;
31213
31214 up_write(&mm->mmap_sem);
31215
31216 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31217
31218 const char *arch_vma_name(struct vm_area_struct *vma)
31219 {
31220 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31221 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31222 return "[vdso]";
31223 +
31224 +#ifdef CONFIG_PAX_SEGMEXEC
31225 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31226 + return "[vdso]";
31227 +#endif
31228 +
31229 return NULL;
31230 }
31231
31232 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31233 * Check to see if the corresponding task was created in compat vdso
31234 * mode.
31235 */
31236 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31237 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31238 return &gate_vma;
31239 return NULL;
31240 }
31241 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31242 index 431e875..cbb23f3 100644
31243 --- a/arch/x86/vdso/vma.c
31244 +++ b/arch/x86/vdso/vma.c
31245 @@ -16,8 +16,6 @@
31246 #include <asm/vdso.h>
31247 #include <asm/page.h>
31248
31249 -unsigned int __read_mostly vdso_enabled = 1;
31250 -
31251 extern char vdso_start[], vdso_end[];
31252 extern unsigned short vdso_sync_cpuid;
31253
31254 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31255 * unaligned here as a result of stack start randomization.
31256 */
31257 addr = PAGE_ALIGN(addr);
31258 - addr = align_vdso_addr(addr);
31259
31260 return addr;
31261 }
31262 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31263 unsigned size)
31264 {
31265 struct mm_struct *mm = current->mm;
31266 - unsigned long addr;
31267 + unsigned long addr = 0;
31268 int ret;
31269
31270 - if (!vdso_enabled)
31271 - return 0;
31272 -
31273 down_write(&mm->mmap_sem);
31274 +
31275 +#ifdef CONFIG_PAX_RANDMMAP
31276 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31277 +#endif
31278 +
31279 addr = vdso_addr(mm->start_stack, size);
31280 + addr = align_vdso_addr(addr);
31281 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31282 if (IS_ERR_VALUE(addr)) {
31283 ret = addr;
31284 goto up_fail;
31285 }
31286
31287 - current->mm->context.vdso = (void *)addr;
31288 + mm->context.vdso = addr;
31289
31290 ret = install_special_mapping(mm, addr, size,
31291 VM_READ|VM_EXEC|
31292 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31293 pages);
31294 - if (ret) {
31295 - current->mm->context.vdso = NULL;
31296 - goto up_fail;
31297 - }
31298 + if (ret)
31299 + mm->context.vdso = 0;
31300
31301 up_fail:
31302 up_write(&mm->mmap_sem);
31303 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31304 vdsox32_size);
31305 }
31306 #endif
31307 -
31308 -static __init int vdso_setup(char *s)
31309 -{
31310 - vdso_enabled = simple_strtoul(s, NULL, 0);
31311 - return 0;
31312 -}
31313 -__setup("vdso=", vdso_setup);
31314 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31315 index a492be2..08678da 100644
31316 --- a/arch/x86/xen/enlighten.c
31317 +++ b/arch/x86/xen/enlighten.c
31318 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31319
31320 struct shared_info xen_dummy_shared_info;
31321
31322 -void *xen_initial_gdt;
31323 -
31324 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31325 __read_mostly int xen_have_vector_callback;
31326 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31327 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31328 {
31329 unsigned long va = dtr->address;
31330 unsigned int size = dtr->size + 1;
31331 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31332 - unsigned long frames[pages];
31333 + unsigned long frames[65536 / PAGE_SIZE];
31334 int f;
31335
31336 /*
31337 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31338 {
31339 unsigned long va = dtr->address;
31340 unsigned int size = dtr->size + 1;
31341 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31342 - unsigned long frames[pages];
31343 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31344 int f;
31345
31346 /*
31347 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31348 * 8-byte entries, or 16 4k pages..
31349 */
31350
31351 - BUG_ON(size > 65536);
31352 + BUG_ON(size > GDT_SIZE);
31353 BUG_ON(va & ~PAGE_MASK);
31354
31355 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31356 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31357 return 0;
31358 }
31359
31360 -static void set_xen_basic_apic_ops(void)
31361 +static void __init set_xen_basic_apic_ops(void)
31362 {
31363 apic->read = xen_apic_read;
31364 apic->write = xen_apic_write;
31365 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31366 #endif
31367 };
31368
31369 -static void xen_reboot(int reason)
31370 +static __noreturn void xen_reboot(int reason)
31371 {
31372 struct sched_shutdown r = { .reason = reason };
31373
31374 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31375 - BUG();
31376 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31377 + BUG();
31378 }
31379
31380 -static void xen_restart(char *msg)
31381 +static __noreturn void xen_restart(char *msg)
31382 {
31383 xen_reboot(SHUTDOWN_reboot);
31384 }
31385
31386 -static void xen_emergency_restart(void)
31387 +static __noreturn void xen_emergency_restart(void)
31388 {
31389 xen_reboot(SHUTDOWN_reboot);
31390 }
31391
31392 -static void xen_machine_halt(void)
31393 +static __noreturn void xen_machine_halt(void)
31394 {
31395 xen_reboot(SHUTDOWN_poweroff);
31396 }
31397
31398 -static void xen_machine_power_off(void)
31399 +static __noreturn void xen_machine_power_off(void)
31400 {
31401 if (pm_power_off)
31402 pm_power_off();
31403 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
31404 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31405
31406 /* Work out if we support NX */
31407 - x86_configure_nx();
31408 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31409 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31410 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31411 + unsigned l, h;
31412 +
31413 + __supported_pte_mask |= _PAGE_NX;
31414 + rdmsr(MSR_EFER, l, h);
31415 + l |= EFER_NX;
31416 + wrmsr(MSR_EFER, l, h);
31417 + }
31418 +#endif
31419
31420 xen_setup_features();
31421
31422 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
31423
31424 machine_ops = xen_machine_ops;
31425
31426 - /*
31427 - * The only reliable way to retain the initial address of the
31428 - * percpu gdt_page is to remember it here, so we can go and
31429 - * mark it RW later, when the initial percpu area is freed.
31430 - */
31431 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31432 -
31433 xen_smp_init();
31434
31435 #ifdef CONFIG_ACPI_NUMA
31436 @@ -1700,7 +1699,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31437 return NOTIFY_OK;
31438 }
31439
31440 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31441 +static struct notifier_block xen_hvm_cpu_notifier = {
31442 .notifier_call = xen_hvm_cpu_notify,
31443 };
31444
31445 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31446 index fdc3ba2..3daee39 100644
31447 --- a/arch/x86/xen/mmu.c
31448 +++ b/arch/x86/xen/mmu.c
31449 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31450 /* L3_k[510] -> level2_kernel_pgt
31451 * L3_i[511] -> level2_fixmap_pgt */
31452 convert_pfn_mfn(level3_kernel_pgt);
31453 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31454 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31455 + convert_pfn_mfn(level3_vmemmap_pgt);
31456
31457 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31458 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31459 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31460 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31461 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31462 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31463 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31464 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31465 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31466 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31467 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31468 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31469 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31470 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31471
31472 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
31473 pv_mmu_ops.set_pud = xen_set_pud;
31474 #if PAGETABLE_LEVELS == 4
31475 pv_mmu_ops.set_pgd = xen_set_pgd;
31476 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31477 #endif
31478
31479 /* This will work as long as patching hasn't happened yet
31480 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31481 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31482 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31483 .set_pgd = xen_set_pgd_hyper,
31484 + .set_pgd_batched = xen_set_pgd_hyper,
31485
31486 .alloc_pud = xen_alloc_pmd_init,
31487 .release_pud = xen_release_pmd_init,
31488 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31489 index d99cae8..18401e1 100644
31490 --- a/arch/x86/xen/smp.c
31491 +++ b/arch/x86/xen/smp.c
31492 @@ -240,11 +240,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31493 {
31494 BUG_ON(smp_processor_id() != 0);
31495 native_smp_prepare_boot_cpu();
31496 -
31497 - /* We've switched to the "real" per-cpu gdt, so make sure the
31498 - old memory can be recycled */
31499 - make_lowmem_page_readwrite(xen_initial_gdt);
31500 -
31501 xen_filter_cpu_maps();
31502 xen_setup_vcpu_info_placement();
31503 }
31504 @@ -314,7 +309,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31505 ctxt->user_regs.ss = __KERNEL_DS;
31506 #ifdef CONFIG_X86_32
31507 ctxt->user_regs.fs = __KERNEL_PERCPU;
31508 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31509 + savesegment(gs, ctxt->user_regs.gs);
31510 #else
31511 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31512 #endif
31513 @@ -324,8 +319,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31514
31515 {
31516 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31517 - ctxt->user_regs.ds = __USER_DS;
31518 - ctxt->user_regs.es = __USER_DS;
31519 + ctxt->user_regs.ds = __KERNEL_DS;
31520 + ctxt->user_regs.es = __KERNEL_DS;
31521
31522 xen_copy_trap_info(ctxt->trap_ctxt);
31523
31524 @@ -370,13 +365,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31525 int rc;
31526
31527 per_cpu(current_task, cpu) = idle;
31528 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31529 #ifdef CONFIG_X86_32
31530 irq_ctx_init(cpu);
31531 #else
31532 clear_tsk_thread_flag(idle, TIF_FORK);
31533 - per_cpu(kernel_stack, cpu) =
31534 - (unsigned long)task_stack_page(idle) -
31535 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31536 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31537 #endif
31538 xen_setup_runstate_info(cpu);
31539 xen_setup_timer(cpu);
31540 @@ -651,7 +645,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31541
31542 void __init xen_smp_init(void)
31543 {
31544 - smp_ops = xen_smp_ops;
31545 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31546 xen_fill_possible_map();
31547 xen_init_spinlocks();
31548 }
31549 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31550 index 33ca6e4..0ded929 100644
31551 --- a/arch/x86/xen/xen-asm_32.S
31552 +++ b/arch/x86/xen/xen-asm_32.S
31553 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31554 ESP_OFFSET=4 # bytes pushed onto stack
31555
31556 /*
31557 - * Store vcpu_info pointer for easy access. Do it this way to
31558 - * avoid having to reload %fs
31559 + * Store vcpu_info pointer for easy access.
31560 */
31561 #ifdef CONFIG_SMP
31562 - GET_THREAD_INFO(%eax)
31563 - movl %ss:TI_cpu(%eax), %eax
31564 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31565 - mov %ss:xen_vcpu(%eax), %eax
31566 + push %fs
31567 + mov $(__KERNEL_PERCPU), %eax
31568 + mov %eax, %fs
31569 + mov PER_CPU_VAR(xen_vcpu), %eax
31570 + pop %fs
31571 #else
31572 movl %ss:xen_vcpu, %eax
31573 #endif
31574 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31575 index 7faed58..ba4427c 100644
31576 --- a/arch/x86/xen/xen-head.S
31577 +++ b/arch/x86/xen/xen-head.S
31578 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31579 #ifdef CONFIG_X86_32
31580 mov %esi,xen_start_info
31581 mov $init_thread_union+THREAD_SIZE,%esp
31582 +#ifdef CONFIG_SMP
31583 + movl $cpu_gdt_table,%edi
31584 + movl $__per_cpu_load,%eax
31585 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31586 + rorl $16,%eax
31587 + movb %al,__KERNEL_PERCPU + 4(%edi)
31588 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31589 + movl $__per_cpu_end - 1,%eax
31590 + subl $__per_cpu_start,%eax
31591 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31592 +#endif
31593 #else
31594 mov %rsi,xen_start_info
31595 mov $init_thread_union+THREAD_SIZE,%rsp
31596 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31597 index a95b417..b6dbd0b 100644
31598 --- a/arch/x86/xen/xen-ops.h
31599 +++ b/arch/x86/xen/xen-ops.h
31600 @@ -10,8 +10,6 @@
31601 extern const char xen_hypervisor_callback[];
31602 extern const char xen_failsafe_callback[];
31603
31604 -extern void *xen_initial_gdt;
31605 -
31606 struct trap_info;
31607 void xen_copy_trap_info(struct trap_info *traps);
31608
31609 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31610 index 525bd3d..ef888b1 100644
31611 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31612 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31613 @@ -119,9 +119,9 @@
31614 ----------------------------------------------------------------------*/
31615
31616 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31617 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31618 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31619 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31620 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31621
31622 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31623 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31624 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31625 index 2f33760..835e50a 100644
31626 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31627 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31628 @@ -11,6 +11,7 @@
31629 #ifndef _XTENSA_CORE_H
31630 #define _XTENSA_CORE_H
31631
31632 +#include <linux/const.h>
31633
31634 /****************************************************************************
31635 Parameters Useful for Any Code, USER or PRIVILEGED
31636 @@ -112,9 +113,9 @@
31637 ----------------------------------------------------------------------*/
31638
31639 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31640 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31641 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31642 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31643 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31644
31645 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31646 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31647 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31648 index af00795..2bb8105 100644
31649 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31650 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31651 @@ -11,6 +11,7 @@
31652 #ifndef _XTENSA_CORE_CONFIGURATION_H
31653 #define _XTENSA_CORE_CONFIGURATION_H
31654
31655 +#include <linux/const.h>
31656
31657 /****************************************************************************
31658 Parameters Useful for Any Code, USER or PRIVILEGED
31659 @@ -118,9 +119,9 @@
31660 ----------------------------------------------------------------------*/
31661
31662 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31663 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31664 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31665 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31666 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31667
31668 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31669 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31670 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31671 index 58916af..eb9dbcf6 100644
31672 --- a/block/blk-iopoll.c
31673 +++ b/block/blk-iopoll.c
31674 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31675 }
31676 EXPORT_SYMBOL(blk_iopoll_complete);
31677
31678 -static void blk_iopoll_softirq(struct softirq_action *h)
31679 +static void blk_iopoll_softirq(void)
31680 {
31681 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31682 int rearm = 0, budget = blk_iopoll_budget;
31683 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31684 return NOTIFY_OK;
31685 }
31686
31687 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31688 +static struct notifier_block blk_iopoll_cpu_notifier = {
31689 .notifier_call = blk_iopoll_cpu_notify,
31690 };
31691
31692 diff --git a/block/blk-map.c b/block/blk-map.c
31693 index 623e1cd..ca1e109 100644
31694 --- a/block/blk-map.c
31695 +++ b/block/blk-map.c
31696 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31697 if (!len || !kbuf)
31698 return -EINVAL;
31699
31700 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31701 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31702 if (do_copy)
31703 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31704 else
31705 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31706 index 467c8de..f3628c5 100644
31707 --- a/block/blk-softirq.c
31708 +++ b/block/blk-softirq.c
31709 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31710 * Softirq action handler - move entries to local list and loop over them
31711 * while passing them to the queue registered handler.
31712 */
31713 -static void blk_done_softirq(struct softirq_action *h)
31714 +static void blk_done_softirq(void)
31715 {
31716 struct list_head *cpu_list, local_list;
31717
31718 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31719 return NOTIFY_OK;
31720 }
31721
31722 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31723 +static struct notifier_block blk_cpu_notifier = {
31724 .notifier_call = blk_cpu_notify,
31725 };
31726
31727 diff --git a/block/bsg.c b/block/bsg.c
31728 index 420a5a9..23834aa 100644
31729 --- a/block/bsg.c
31730 +++ b/block/bsg.c
31731 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31732 struct sg_io_v4 *hdr, struct bsg_device *bd,
31733 fmode_t has_write_perm)
31734 {
31735 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31736 + unsigned char *cmdptr;
31737 +
31738 if (hdr->request_len > BLK_MAX_CDB) {
31739 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31740 if (!rq->cmd)
31741 return -ENOMEM;
31742 - }
31743 + cmdptr = rq->cmd;
31744 + } else
31745 + cmdptr = tmpcmd;
31746
31747 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31748 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31749 hdr->request_len))
31750 return -EFAULT;
31751
31752 + if (cmdptr != rq->cmd)
31753 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31754 +
31755 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31756 if (blk_verify_command(rq->cmd, has_write_perm))
31757 return -EPERM;
31758 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31759 index 7c668c8..db3521c 100644
31760 --- a/block/compat_ioctl.c
31761 +++ b/block/compat_ioctl.c
31762 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31763 err |= __get_user(f->spec1, &uf->spec1);
31764 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31765 err |= __get_user(name, &uf->name);
31766 - f->name = compat_ptr(name);
31767 + f->name = (void __force_kernel *)compat_ptr(name);
31768 if (err) {
31769 err = -EFAULT;
31770 goto out;
31771 diff --git a/block/genhd.c b/block/genhd.c
31772 index cdeb527..10aa34db 100644
31773 --- a/block/genhd.c
31774 +++ b/block/genhd.c
31775 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
31776
31777 /*
31778 * Register device numbers dev..(dev+range-1)
31779 - * range must be nonzero
31780 + * Noop if @range is zero.
31781 * The hash chain is sorted on range, so that subranges can override.
31782 */
31783 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
31784 struct kobject *(*probe)(dev_t, int *, void *),
31785 int (*lock)(dev_t, void *), void *data)
31786 {
31787 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
31788 + if (range)
31789 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
31790 }
31791
31792 EXPORT_SYMBOL(blk_register_region);
31793
31794 +/* undo blk_register_region(), noop if @range is zero */
31795 void blk_unregister_region(dev_t devt, unsigned long range)
31796 {
31797 - kobj_unmap(bdev_map, devt, range);
31798 + if (range)
31799 + kobj_unmap(bdev_map, devt, range);
31800 }
31801
31802 EXPORT_SYMBOL(blk_unregister_region);
31803 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31804 index c85fc89..51e690b 100644
31805 --- a/block/partitions/efi.c
31806 +++ b/block/partitions/efi.c
31807 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31808 if (!gpt)
31809 return NULL;
31810
31811 + if (!le32_to_cpu(gpt->num_partition_entries))
31812 + return NULL;
31813 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31814 + if (!pte)
31815 + return NULL;
31816 +
31817 count = le32_to_cpu(gpt->num_partition_entries) *
31818 le32_to_cpu(gpt->sizeof_partition_entry);
31819 - if (!count)
31820 - return NULL;
31821 - pte = kmalloc(count, GFP_KERNEL);
31822 - if (!pte)
31823 - return NULL;
31824 -
31825 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31826 (u8 *) pte,
31827 count) < count) {
31828 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31829 index a5ffcc9..3cedc9c 100644
31830 --- a/block/scsi_ioctl.c
31831 +++ b/block/scsi_ioctl.c
31832 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
31833 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31834 struct sg_io_hdr *hdr, fmode_t mode)
31835 {
31836 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31837 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31838 + unsigned char *cmdptr;
31839 +
31840 + if (rq->cmd != rq->__cmd)
31841 + cmdptr = rq->cmd;
31842 + else
31843 + cmdptr = tmpcmd;
31844 +
31845 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31846 return -EFAULT;
31847 +
31848 + if (cmdptr != rq->cmd)
31849 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31850 +
31851 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31852 return -EPERM;
31853
31854 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31855 int err;
31856 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31857 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31858 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31859 + unsigned char *cmdptr;
31860
31861 if (!sic)
31862 return -EINVAL;
31863 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31864 */
31865 err = -EFAULT;
31866 rq->cmd_len = cmdlen;
31867 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31868 +
31869 + if (rq->cmd != rq->__cmd)
31870 + cmdptr = rq->cmd;
31871 + else
31872 + cmdptr = tmpcmd;
31873 +
31874 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31875 goto error;
31876
31877 + if (rq->cmd != cmdptr)
31878 + memcpy(rq->cmd, cmdptr, cmdlen);
31879 +
31880 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31881 goto error;
31882
31883 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31884 index 7bdd61b..afec999 100644
31885 --- a/crypto/cryptd.c
31886 +++ b/crypto/cryptd.c
31887 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31888
31889 struct cryptd_blkcipher_request_ctx {
31890 crypto_completion_t complete;
31891 -};
31892 +} __no_const;
31893
31894 struct cryptd_hash_ctx {
31895 struct crypto_shash *child;
31896 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31897
31898 struct cryptd_aead_request_ctx {
31899 crypto_completion_t complete;
31900 -};
31901 +} __no_const;
31902
31903 static void cryptd_queue_worker(struct work_struct *work);
31904
31905 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
31906 index b2c99dc..476c9fb 100644
31907 --- a/crypto/pcrypt.c
31908 +++ b/crypto/pcrypt.c
31909 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
31910 int ret;
31911
31912 pinst->kobj.kset = pcrypt_kset;
31913 - ret = kobject_add(&pinst->kobj, NULL, name);
31914 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
31915 if (!ret)
31916 kobject_uevent(&pinst->kobj, KOBJ_ADD);
31917
31918 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
31919
31920 get_online_cpus();
31921
31922 - pcrypt->wq = alloc_workqueue(name,
31923 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
31924 + pcrypt->wq = alloc_workqueue("%s",
31925 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
31926 if (!pcrypt->wq)
31927 goto err;
31928
31929 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31930 index f220d64..d359ad6 100644
31931 --- a/drivers/acpi/apei/apei-internal.h
31932 +++ b/drivers/acpi/apei/apei-internal.h
31933 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31934 struct apei_exec_ins_type {
31935 u32 flags;
31936 apei_exec_ins_func_t run;
31937 -};
31938 +} __do_const;
31939
31940 struct apei_exec_context {
31941 u32 ip;
31942 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31943 index 33dc6a0..4b24b47 100644
31944 --- a/drivers/acpi/apei/cper.c
31945 +++ b/drivers/acpi/apei/cper.c
31946 @@ -39,12 +39,12 @@
31947 */
31948 u64 cper_next_record_id(void)
31949 {
31950 - static atomic64_t seq;
31951 + static atomic64_unchecked_t seq;
31952
31953 - if (!atomic64_read(&seq))
31954 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31955 + if (!atomic64_read_unchecked(&seq))
31956 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31957
31958 - return atomic64_inc_return(&seq);
31959 + return atomic64_inc_return_unchecked(&seq);
31960 }
31961 EXPORT_SYMBOL_GPL(cper_next_record_id);
31962
31963 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31964 index be60399..778b33e8 100644
31965 --- a/drivers/acpi/bgrt.c
31966 +++ b/drivers/acpi/bgrt.c
31967 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31968 return -ENODEV;
31969
31970 sysfs_bin_attr_init(&image_attr);
31971 - image_attr.private = bgrt_image;
31972 - image_attr.size = bgrt_image_size;
31973 + pax_open_kernel();
31974 + *(void **)&image_attr.private = bgrt_image;
31975 + *(size_t *)&image_attr.size = bgrt_image_size;
31976 + pax_close_kernel();
31977
31978 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31979 if (!bgrt_kobj)
31980 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31981 index cb96296..b81293b 100644
31982 --- a/drivers/acpi/blacklist.c
31983 +++ b/drivers/acpi/blacklist.c
31984 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31985 u32 is_critical_error;
31986 };
31987
31988 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31989 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31990
31991 /*
31992 * POLICY: If *anything* doesn't work, put it on the blacklist.
31993 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31994 return 0;
31995 }
31996
31997 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31998 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31999 {
32000 .callback = dmi_disable_osi_vista,
32001 .ident = "Fujitsu Siemens",
32002 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32003 index 7586544..636a2f0 100644
32004 --- a/drivers/acpi/ec_sys.c
32005 +++ b/drivers/acpi/ec_sys.c
32006 @@ -12,6 +12,7 @@
32007 #include <linux/acpi.h>
32008 #include <linux/debugfs.h>
32009 #include <linux/module.h>
32010 +#include <linux/uaccess.h>
32011 #include "internal.h"
32012
32013 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32014 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32015 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32016 */
32017 unsigned int size = EC_SPACE_SIZE;
32018 - u8 *data = (u8 *) buf;
32019 + u8 data;
32020 loff_t init_off = *off;
32021 int err = 0;
32022
32023 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32024 size = count;
32025
32026 while (size) {
32027 - err = ec_read(*off, &data[*off - init_off]);
32028 + err = ec_read(*off, &data);
32029 if (err)
32030 return err;
32031 + if (put_user(data, &buf[*off - init_off]))
32032 + return -EFAULT;
32033 *off += 1;
32034 size--;
32035 }
32036 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32037
32038 unsigned int size = count;
32039 loff_t init_off = *off;
32040 - u8 *data = (u8 *) buf;
32041 int err = 0;
32042
32043 if (*off >= EC_SPACE_SIZE)
32044 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32045 }
32046
32047 while (size) {
32048 - u8 byte_write = data[*off - init_off];
32049 + u8 byte_write;
32050 + if (get_user(byte_write, &buf[*off - init_off]))
32051 + return -EFAULT;
32052 err = ec_write(*off, byte_write);
32053 if (err)
32054 return err;
32055 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32056 index eb133c7..f571552 100644
32057 --- a/drivers/acpi/processor_idle.c
32058 +++ b/drivers/acpi/processor_idle.c
32059 @@ -994,7 +994,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32060 {
32061 int i, count = CPUIDLE_DRIVER_STATE_START;
32062 struct acpi_processor_cx *cx;
32063 - struct cpuidle_state *state;
32064 + cpuidle_state_no_const *state;
32065 struct cpuidle_driver *drv = &acpi_idle_driver;
32066
32067 if (!pr->flags.power_setup_done)
32068 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32069 index fcae5fa..e9f71ea 100644
32070 --- a/drivers/acpi/sysfs.c
32071 +++ b/drivers/acpi/sysfs.c
32072 @@ -423,11 +423,11 @@ static u32 num_counters;
32073 static struct attribute **all_attrs;
32074 static u32 acpi_gpe_count;
32075
32076 -static struct attribute_group interrupt_stats_attr_group = {
32077 +static attribute_group_no_const interrupt_stats_attr_group = {
32078 .name = "interrupts",
32079 };
32080
32081 -static struct kobj_attribute *counter_attrs;
32082 +static kobj_attribute_no_const *counter_attrs;
32083
32084 static void delete_gpe_attr_array(void)
32085 {
32086 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32087 index 7b9bdd8..37638ca 100644
32088 --- a/drivers/ata/libahci.c
32089 +++ b/drivers/ata/libahci.c
32090 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32091 }
32092 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32093
32094 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32095 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32096 struct ata_taskfile *tf, int is_cmd, u16 flags,
32097 unsigned long timeout_msec)
32098 {
32099 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32100 index adf002a..39bb8f9 100644
32101 --- a/drivers/ata/libata-core.c
32102 +++ b/drivers/ata/libata-core.c
32103 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32104 struct ata_port *ap;
32105 unsigned int tag;
32106
32107 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32108 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32109 ap = qc->ap;
32110
32111 qc->flags = 0;
32112 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32113 struct ata_port *ap;
32114 struct ata_link *link;
32115
32116 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32117 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32118 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32119 ap = qc->ap;
32120 link = qc->dev->link;
32121 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32122 return;
32123
32124 spin_lock(&lock);
32125 + pax_open_kernel();
32126
32127 for (cur = ops->inherits; cur; cur = cur->inherits) {
32128 void **inherit = (void **)cur;
32129 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32130 if (IS_ERR(*pp))
32131 *pp = NULL;
32132
32133 - ops->inherits = NULL;
32134 + *(struct ata_port_operations **)&ops->inherits = NULL;
32135
32136 + pax_close_kernel();
32137 spin_unlock(&lock);
32138 }
32139
32140 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32141 index 7638121..357a965 100644
32142 --- a/drivers/ata/pata_arasan_cf.c
32143 +++ b/drivers/ata/pata_arasan_cf.c
32144 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32145 /* Handle platform specific quirks */
32146 if (quirk) {
32147 if (quirk & CF_BROKEN_PIO) {
32148 - ap->ops->set_piomode = NULL;
32149 + pax_open_kernel();
32150 + *(void **)&ap->ops->set_piomode = NULL;
32151 + pax_close_kernel();
32152 ap->pio_mask = 0;
32153 }
32154 if (quirk & CF_BROKEN_MWDMA)
32155 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32156 index f9b983a..887b9d8 100644
32157 --- a/drivers/atm/adummy.c
32158 +++ b/drivers/atm/adummy.c
32159 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32160 vcc->pop(vcc, skb);
32161 else
32162 dev_kfree_skb_any(skb);
32163 - atomic_inc(&vcc->stats->tx);
32164 + atomic_inc_unchecked(&vcc->stats->tx);
32165
32166 return 0;
32167 }
32168 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32169 index 77a7480d..05cde58 100644
32170 --- a/drivers/atm/ambassador.c
32171 +++ b/drivers/atm/ambassador.c
32172 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32173 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32174
32175 // VC layer stats
32176 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32177 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32178
32179 // free the descriptor
32180 kfree (tx_descr);
32181 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32182 dump_skb ("<<<", vc, skb);
32183
32184 // VC layer stats
32185 - atomic_inc(&atm_vcc->stats->rx);
32186 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32187 __net_timestamp(skb);
32188 // end of our responsibility
32189 atm_vcc->push (atm_vcc, skb);
32190 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32191 } else {
32192 PRINTK (KERN_INFO, "dropped over-size frame");
32193 // should we count this?
32194 - atomic_inc(&atm_vcc->stats->rx_drop);
32195 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32196 }
32197
32198 } else {
32199 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32200 }
32201
32202 if (check_area (skb->data, skb->len)) {
32203 - atomic_inc(&atm_vcc->stats->tx_err);
32204 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32205 return -ENOMEM; // ?
32206 }
32207
32208 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32209 index 0e3f8f9..765a7a5 100644
32210 --- a/drivers/atm/atmtcp.c
32211 +++ b/drivers/atm/atmtcp.c
32212 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32213 if (vcc->pop) vcc->pop(vcc,skb);
32214 else dev_kfree_skb(skb);
32215 if (dev_data) return 0;
32216 - atomic_inc(&vcc->stats->tx_err);
32217 + atomic_inc_unchecked(&vcc->stats->tx_err);
32218 return -ENOLINK;
32219 }
32220 size = skb->len+sizeof(struct atmtcp_hdr);
32221 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32222 if (!new_skb) {
32223 if (vcc->pop) vcc->pop(vcc,skb);
32224 else dev_kfree_skb(skb);
32225 - atomic_inc(&vcc->stats->tx_err);
32226 + atomic_inc_unchecked(&vcc->stats->tx_err);
32227 return -ENOBUFS;
32228 }
32229 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32230 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32231 if (vcc->pop) vcc->pop(vcc,skb);
32232 else dev_kfree_skb(skb);
32233 out_vcc->push(out_vcc,new_skb);
32234 - atomic_inc(&vcc->stats->tx);
32235 - atomic_inc(&out_vcc->stats->rx);
32236 + atomic_inc_unchecked(&vcc->stats->tx);
32237 + atomic_inc_unchecked(&out_vcc->stats->rx);
32238 return 0;
32239 }
32240
32241 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32242 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32243 read_unlock(&vcc_sklist_lock);
32244 if (!out_vcc) {
32245 - atomic_inc(&vcc->stats->tx_err);
32246 + atomic_inc_unchecked(&vcc->stats->tx_err);
32247 goto done;
32248 }
32249 skb_pull(skb,sizeof(struct atmtcp_hdr));
32250 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32251 __net_timestamp(new_skb);
32252 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32253 out_vcc->push(out_vcc,new_skb);
32254 - atomic_inc(&vcc->stats->tx);
32255 - atomic_inc(&out_vcc->stats->rx);
32256 + atomic_inc_unchecked(&vcc->stats->tx);
32257 + atomic_inc_unchecked(&out_vcc->stats->rx);
32258 done:
32259 if (vcc->pop) vcc->pop(vcc,skb);
32260 else dev_kfree_skb(skb);
32261 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32262 index b1955ba..b179940 100644
32263 --- a/drivers/atm/eni.c
32264 +++ b/drivers/atm/eni.c
32265 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32266 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32267 vcc->dev->number);
32268 length = 0;
32269 - atomic_inc(&vcc->stats->rx_err);
32270 + atomic_inc_unchecked(&vcc->stats->rx_err);
32271 }
32272 else {
32273 length = ATM_CELL_SIZE-1; /* no HEC */
32274 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32275 size);
32276 }
32277 eff = length = 0;
32278 - atomic_inc(&vcc->stats->rx_err);
32279 + atomic_inc_unchecked(&vcc->stats->rx_err);
32280 }
32281 else {
32282 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32283 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32284 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32285 vcc->dev->number,vcc->vci,length,size << 2,descr);
32286 length = eff = 0;
32287 - atomic_inc(&vcc->stats->rx_err);
32288 + atomic_inc_unchecked(&vcc->stats->rx_err);
32289 }
32290 }
32291 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32292 @@ -767,7 +767,7 @@ rx_dequeued++;
32293 vcc->push(vcc,skb);
32294 pushed++;
32295 }
32296 - atomic_inc(&vcc->stats->rx);
32297 + atomic_inc_unchecked(&vcc->stats->rx);
32298 }
32299 wake_up(&eni_dev->rx_wait);
32300 }
32301 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32302 PCI_DMA_TODEVICE);
32303 if (vcc->pop) vcc->pop(vcc,skb);
32304 else dev_kfree_skb_irq(skb);
32305 - atomic_inc(&vcc->stats->tx);
32306 + atomic_inc_unchecked(&vcc->stats->tx);
32307 wake_up(&eni_dev->tx_wait);
32308 dma_complete++;
32309 }
32310 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32311 index b41c948..a002b17 100644
32312 --- a/drivers/atm/firestream.c
32313 +++ b/drivers/atm/firestream.c
32314 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32315 }
32316 }
32317
32318 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32319 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32320
32321 fs_dprintk (FS_DEBUG_TXMEM, "i");
32322 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32323 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32324 #endif
32325 skb_put (skb, qe->p1 & 0xffff);
32326 ATM_SKB(skb)->vcc = atm_vcc;
32327 - atomic_inc(&atm_vcc->stats->rx);
32328 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32329 __net_timestamp(skb);
32330 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32331 atm_vcc->push (atm_vcc, skb);
32332 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32333 kfree (pe);
32334 }
32335 if (atm_vcc)
32336 - atomic_inc(&atm_vcc->stats->rx_drop);
32337 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32338 break;
32339 case 0x1f: /* Reassembly abort: no buffers. */
32340 /* Silently increment error counter. */
32341 if (atm_vcc)
32342 - atomic_inc(&atm_vcc->stats->rx_drop);
32343 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32344 break;
32345 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32346 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32347 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32348 index 204814e..cede831 100644
32349 --- a/drivers/atm/fore200e.c
32350 +++ b/drivers/atm/fore200e.c
32351 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32352 #endif
32353 /* check error condition */
32354 if (*entry->status & STATUS_ERROR)
32355 - atomic_inc(&vcc->stats->tx_err);
32356 + atomic_inc_unchecked(&vcc->stats->tx_err);
32357 else
32358 - atomic_inc(&vcc->stats->tx);
32359 + atomic_inc_unchecked(&vcc->stats->tx);
32360 }
32361 }
32362
32363 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32364 if (skb == NULL) {
32365 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32366
32367 - atomic_inc(&vcc->stats->rx_drop);
32368 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32369 return -ENOMEM;
32370 }
32371
32372 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32373
32374 dev_kfree_skb_any(skb);
32375
32376 - atomic_inc(&vcc->stats->rx_drop);
32377 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32378 return -ENOMEM;
32379 }
32380
32381 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32382
32383 vcc->push(vcc, skb);
32384 - atomic_inc(&vcc->stats->rx);
32385 + atomic_inc_unchecked(&vcc->stats->rx);
32386
32387 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32388
32389 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32390 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32391 fore200e->atm_dev->number,
32392 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32393 - atomic_inc(&vcc->stats->rx_err);
32394 + atomic_inc_unchecked(&vcc->stats->rx_err);
32395 }
32396 }
32397
32398 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32399 goto retry_here;
32400 }
32401
32402 - atomic_inc(&vcc->stats->tx_err);
32403 + atomic_inc_unchecked(&vcc->stats->tx_err);
32404
32405 fore200e->tx_sat++;
32406 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32407 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32408 index 507362a..a845e57 100644
32409 --- a/drivers/atm/he.c
32410 +++ b/drivers/atm/he.c
32411 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32412
32413 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32414 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32415 - atomic_inc(&vcc->stats->rx_drop);
32416 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32417 goto return_host_buffers;
32418 }
32419
32420 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32421 RBRQ_LEN_ERR(he_dev->rbrq_head)
32422 ? "LEN_ERR" : "",
32423 vcc->vpi, vcc->vci);
32424 - atomic_inc(&vcc->stats->rx_err);
32425 + atomic_inc_unchecked(&vcc->stats->rx_err);
32426 goto return_host_buffers;
32427 }
32428
32429 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32430 vcc->push(vcc, skb);
32431 spin_lock(&he_dev->global_lock);
32432
32433 - atomic_inc(&vcc->stats->rx);
32434 + atomic_inc_unchecked(&vcc->stats->rx);
32435
32436 return_host_buffers:
32437 ++pdus_assembled;
32438 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32439 tpd->vcc->pop(tpd->vcc, tpd->skb);
32440 else
32441 dev_kfree_skb_any(tpd->skb);
32442 - atomic_inc(&tpd->vcc->stats->tx_err);
32443 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32444 }
32445 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32446 return;
32447 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32448 vcc->pop(vcc, skb);
32449 else
32450 dev_kfree_skb_any(skb);
32451 - atomic_inc(&vcc->stats->tx_err);
32452 + atomic_inc_unchecked(&vcc->stats->tx_err);
32453 return -EINVAL;
32454 }
32455
32456 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32457 vcc->pop(vcc, skb);
32458 else
32459 dev_kfree_skb_any(skb);
32460 - atomic_inc(&vcc->stats->tx_err);
32461 + atomic_inc_unchecked(&vcc->stats->tx_err);
32462 return -EINVAL;
32463 }
32464 #endif
32465 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32466 vcc->pop(vcc, skb);
32467 else
32468 dev_kfree_skb_any(skb);
32469 - atomic_inc(&vcc->stats->tx_err);
32470 + atomic_inc_unchecked(&vcc->stats->tx_err);
32471 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32472 return -ENOMEM;
32473 }
32474 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32475 vcc->pop(vcc, skb);
32476 else
32477 dev_kfree_skb_any(skb);
32478 - atomic_inc(&vcc->stats->tx_err);
32479 + atomic_inc_unchecked(&vcc->stats->tx_err);
32480 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32481 return -ENOMEM;
32482 }
32483 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32484 __enqueue_tpd(he_dev, tpd, cid);
32485 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32486
32487 - atomic_inc(&vcc->stats->tx);
32488 + atomic_inc_unchecked(&vcc->stats->tx);
32489
32490 return 0;
32491 }
32492 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32493 index 1dc0519..1aadaf7 100644
32494 --- a/drivers/atm/horizon.c
32495 +++ b/drivers/atm/horizon.c
32496 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32497 {
32498 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32499 // VC layer stats
32500 - atomic_inc(&vcc->stats->rx);
32501 + atomic_inc_unchecked(&vcc->stats->rx);
32502 __net_timestamp(skb);
32503 // end of our responsibility
32504 vcc->push (vcc, skb);
32505 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32506 dev->tx_iovec = NULL;
32507
32508 // VC layer stats
32509 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32510 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32511
32512 // free the skb
32513 hrz_kfree_skb (skb);
32514 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32515 index 272f009..a18ba55 100644
32516 --- a/drivers/atm/idt77252.c
32517 +++ b/drivers/atm/idt77252.c
32518 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32519 else
32520 dev_kfree_skb(skb);
32521
32522 - atomic_inc(&vcc->stats->tx);
32523 + atomic_inc_unchecked(&vcc->stats->tx);
32524 }
32525
32526 atomic_dec(&scq->used);
32527 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32528 if ((sb = dev_alloc_skb(64)) == NULL) {
32529 printk("%s: Can't allocate buffers for aal0.\n",
32530 card->name);
32531 - atomic_add(i, &vcc->stats->rx_drop);
32532 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32533 break;
32534 }
32535 if (!atm_charge(vcc, sb->truesize)) {
32536 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32537 card->name);
32538 - atomic_add(i - 1, &vcc->stats->rx_drop);
32539 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32540 dev_kfree_skb(sb);
32541 break;
32542 }
32543 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32544 ATM_SKB(sb)->vcc = vcc;
32545 __net_timestamp(sb);
32546 vcc->push(vcc, sb);
32547 - atomic_inc(&vcc->stats->rx);
32548 + atomic_inc_unchecked(&vcc->stats->rx);
32549
32550 cell += ATM_CELL_PAYLOAD;
32551 }
32552 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32553 "(CDC: %08x)\n",
32554 card->name, len, rpp->len, readl(SAR_REG_CDC));
32555 recycle_rx_pool_skb(card, rpp);
32556 - atomic_inc(&vcc->stats->rx_err);
32557 + atomic_inc_unchecked(&vcc->stats->rx_err);
32558 return;
32559 }
32560 if (stat & SAR_RSQE_CRC) {
32561 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32562 recycle_rx_pool_skb(card, rpp);
32563 - atomic_inc(&vcc->stats->rx_err);
32564 + atomic_inc_unchecked(&vcc->stats->rx_err);
32565 return;
32566 }
32567 if (skb_queue_len(&rpp->queue) > 1) {
32568 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32569 RXPRINTK("%s: Can't alloc RX skb.\n",
32570 card->name);
32571 recycle_rx_pool_skb(card, rpp);
32572 - atomic_inc(&vcc->stats->rx_err);
32573 + atomic_inc_unchecked(&vcc->stats->rx_err);
32574 return;
32575 }
32576 if (!atm_charge(vcc, skb->truesize)) {
32577 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32578 __net_timestamp(skb);
32579
32580 vcc->push(vcc, skb);
32581 - atomic_inc(&vcc->stats->rx);
32582 + atomic_inc_unchecked(&vcc->stats->rx);
32583
32584 return;
32585 }
32586 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32587 __net_timestamp(skb);
32588
32589 vcc->push(vcc, skb);
32590 - atomic_inc(&vcc->stats->rx);
32591 + atomic_inc_unchecked(&vcc->stats->rx);
32592
32593 if (skb->truesize > SAR_FB_SIZE_3)
32594 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32595 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32596 if (vcc->qos.aal != ATM_AAL0) {
32597 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32598 card->name, vpi, vci);
32599 - atomic_inc(&vcc->stats->rx_drop);
32600 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32601 goto drop;
32602 }
32603
32604 if ((sb = dev_alloc_skb(64)) == NULL) {
32605 printk("%s: Can't allocate buffers for AAL0.\n",
32606 card->name);
32607 - atomic_inc(&vcc->stats->rx_err);
32608 + atomic_inc_unchecked(&vcc->stats->rx_err);
32609 goto drop;
32610 }
32611
32612 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32613 ATM_SKB(sb)->vcc = vcc;
32614 __net_timestamp(sb);
32615 vcc->push(vcc, sb);
32616 - atomic_inc(&vcc->stats->rx);
32617 + atomic_inc_unchecked(&vcc->stats->rx);
32618
32619 drop:
32620 skb_pull(queue, 64);
32621 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32622
32623 if (vc == NULL) {
32624 printk("%s: NULL connection in send().\n", card->name);
32625 - atomic_inc(&vcc->stats->tx_err);
32626 + atomic_inc_unchecked(&vcc->stats->tx_err);
32627 dev_kfree_skb(skb);
32628 return -EINVAL;
32629 }
32630 if (!test_bit(VCF_TX, &vc->flags)) {
32631 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32632 - atomic_inc(&vcc->stats->tx_err);
32633 + atomic_inc_unchecked(&vcc->stats->tx_err);
32634 dev_kfree_skb(skb);
32635 return -EINVAL;
32636 }
32637 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32638 break;
32639 default:
32640 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32641 - atomic_inc(&vcc->stats->tx_err);
32642 + atomic_inc_unchecked(&vcc->stats->tx_err);
32643 dev_kfree_skb(skb);
32644 return -EINVAL;
32645 }
32646
32647 if (skb_shinfo(skb)->nr_frags != 0) {
32648 printk("%s: No scatter-gather yet.\n", card->name);
32649 - atomic_inc(&vcc->stats->tx_err);
32650 + atomic_inc_unchecked(&vcc->stats->tx_err);
32651 dev_kfree_skb(skb);
32652 return -EINVAL;
32653 }
32654 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32655
32656 err = queue_skb(card, vc, skb, oam);
32657 if (err) {
32658 - atomic_inc(&vcc->stats->tx_err);
32659 + atomic_inc_unchecked(&vcc->stats->tx_err);
32660 dev_kfree_skb(skb);
32661 return err;
32662 }
32663 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32664 skb = dev_alloc_skb(64);
32665 if (!skb) {
32666 printk("%s: Out of memory in send_oam().\n", card->name);
32667 - atomic_inc(&vcc->stats->tx_err);
32668 + atomic_inc_unchecked(&vcc->stats->tx_err);
32669 return -ENOMEM;
32670 }
32671 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32672 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32673 index 4217f29..88f547a 100644
32674 --- a/drivers/atm/iphase.c
32675 +++ b/drivers/atm/iphase.c
32676 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32677 status = (u_short) (buf_desc_ptr->desc_mode);
32678 if (status & (RX_CER | RX_PTE | RX_OFL))
32679 {
32680 - atomic_inc(&vcc->stats->rx_err);
32681 + atomic_inc_unchecked(&vcc->stats->rx_err);
32682 IF_ERR(printk("IA: bad packet, dropping it");)
32683 if (status & RX_CER) {
32684 IF_ERR(printk(" cause: packet CRC error\n");)
32685 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32686 len = dma_addr - buf_addr;
32687 if (len > iadev->rx_buf_sz) {
32688 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32689 - atomic_inc(&vcc->stats->rx_err);
32690 + atomic_inc_unchecked(&vcc->stats->rx_err);
32691 goto out_free_desc;
32692 }
32693
32694 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32695 ia_vcc = INPH_IA_VCC(vcc);
32696 if (ia_vcc == NULL)
32697 {
32698 - atomic_inc(&vcc->stats->rx_err);
32699 + atomic_inc_unchecked(&vcc->stats->rx_err);
32700 atm_return(vcc, skb->truesize);
32701 dev_kfree_skb_any(skb);
32702 goto INCR_DLE;
32703 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32704 if ((length > iadev->rx_buf_sz) || (length >
32705 (skb->len - sizeof(struct cpcs_trailer))))
32706 {
32707 - atomic_inc(&vcc->stats->rx_err);
32708 + atomic_inc_unchecked(&vcc->stats->rx_err);
32709 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32710 length, skb->len);)
32711 atm_return(vcc, skb->truesize);
32712 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32713
32714 IF_RX(printk("rx_dle_intr: skb push");)
32715 vcc->push(vcc,skb);
32716 - atomic_inc(&vcc->stats->rx);
32717 + atomic_inc_unchecked(&vcc->stats->rx);
32718 iadev->rx_pkt_cnt++;
32719 }
32720 INCR_DLE:
32721 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32722 {
32723 struct k_sonet_stats *stats;
32724 stats = &PRIV(_ia_dev[board])->sonet_stats;
32725 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32726 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32727 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32728 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32729 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32730 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32731 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32732 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32733 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32734 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32735 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32736 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32737 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32738 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32739 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32740 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32741 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32742 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32743 }
32744 ia_cmds.status = 0;
32745 break;
32746 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32747 if ((desc == 0) || (desc > iadev->num_tx_desc))
32748 {
32749 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32750 - atomic_inc(&vcc->stats->tx);
32751 + atomic_inc_unchecked(&vcc->stats->tx);
32752 if (vcc->pop)
32753 vcc->pop(vcc, skb);
32754 else
32755 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32756 ATM_DESC(skb) = vcc->vci;
32757 skb_queue_tail(&iadev->tx_dma_q, skb);
32758
32759 - atomic_inc(&vcc->stats->tx);
32760 + atomic_inc_unchecked(&vcc->stats->tx);
32761 iadev->tx_pkt_cnt++;
32762 /* Increment transaction counter */
32763 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32764
32765 #if 0
32766 /* add flow control logic */
32767 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32768 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32769 if (iavcc->vc_desc_cnt > 10) {
32770 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32771 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32772 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32773 index fa7d701..1e404c7 100644
32774 --- a/drivers/atm/lanai.c
32775 +++ b/drivers/atm/lanai.c
32776 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32777 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32778 lanai_endtx(lanai, lvcc);
32779 lanai_free_skb(lvcc->tx.atmvcc, skb);
32780 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32781 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32782 }
32783
32784 /* Try to fill the buffer - don't call unless there is backlog */
32785 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32786 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32787 __net_timestamp(skb);
32788 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32789 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32790 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32791 out:
32792 lvcc->rx.buf.ptr = end;
32793 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32794 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32795 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32796 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32797 lanai->stats.service_rxnotaal5++;
32798 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32799 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32800 return 0;
32801 }
32802 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32803 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32804 int bytes;
32805 read_unlock(&vcc_sklist_lock);
32806 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32807 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32808 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32809 lvcc->stats.x.aal5.service_trash++;
32810 bytes = (SERVICE_GET_END(s) * 16) -
32811 (((unsigned long) lvcc->rx.buf.ptr) -
32812 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32813 }
32814 if (s & SERVICE_STREAM) {
32815 read_unlock(&vcc_sklist_lock);
32816 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32817 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32818 lvcc->stats.x.aal5.service_stream++;
32819 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32820 "PDU on VCI %d!\n", lanai->number, vci);
32821 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32822 return 0;
32823 }
32824 DPRINTK("got rx crc error on vci %d\n", vci);
32825 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32826 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32827 lvcc->stats.x.aal5.service_rxcrc++;
32828 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32829 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32830 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32831 index 6587dc2..149833d 100644
32832 --- a/drivers/atm/nicstar.c
32833 +++ b/drivers/atm/nicstar.c
32834 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32835 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32836 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32837 card->index);
32838 - atomic_inc(&vcc->stats->tx_err);
32839 + atomic_inc_unchecked(&vcc->stats->tx_err);
32840 dev_kfree_skb_any(skb);
32841 return -EINVAL;
32842 }
32843 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32844 if (!vc->tx) {
32845 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32846 card->index);
32847 - atomic_inc(&vcc->stats->tx_err);
32848 + atomic_inc_unchecked(&vcc->stats->tx_err);
32849 dev_kfree_skb_any(skb);
32850 return -EINVAL;
32851 }
32852 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32853 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32854 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32855 card->index);
32856 - atomic_inc(&vcc->stats->tx_err);
32857 + atomic_inc_unchecked(&vcc->stats->tx_err);
32858 dev_kfree_skb_any(skb);
32859 return -EINVAL;
32860 }
32861
32862 if (skb_shinfo(skb)->nr_frags != 0) {
32863 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32864 - atomic_inc(&vcc->stats->tx_err);
32865 + atomic_inc_unchecked(&vcc->stats->tx_err);
32866 dev_kfree_skb_any(skb);
32867 return -EINVAL;
32868 }
32869 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32870 }
32871
32872 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32873 - atomic_inc(&vcc->stats->tx_err);
32874 + atomic_inc_unchecked(&vcc->stats->tx_err);
32875 dev_kfree_skb_any(skb);
32876 return -EIO;
32877 }
32878 - atomic_inc(&vcc->stats->tx);
32879 + atomic_inc_unchecked(&vcc->stats->tx);
32880
32881 return 0;
32882 }
32883 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32884 printk
32885 ("nicstar%d: Can't allocate buffers for aal0.\n",
32886 card->index);
32887 - atomic_add(i, &vcc->stats->rx_drop);
32888 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32889 break;
32890 }
32891 if (!atm_charge(vcc, sb->truesize)) {
32892 RXPRINTK
32893 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32894 card->index);
32895 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32896 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32897 dev_kfree_skb_any(sb);
32898 break;
32899 }
32900 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32901 ATM_SKB(sb)->vcc = vcc;
32902 __net_timestamp(sb);
32903 vcc->push(vcc, sb);
32904 - atomic_inc(&vcc->stats->rx);
32905 + atomic_inc_unchecked(&vcc->stats->rx);
32906 cell += ATM_CELL_PAYLOAD;
32907 }
32908
32909 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32910 if (iovb == NULL) {
32911 printk("nicstar%d: Out of iovec buffers.\n",
32912 card->index);
32913 - atomic_inc(&vcc->stats->rx_drop);
32914 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32915 recycle_rx_buf(card, skb);
32916 return;
32917 }
32918 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32919 small or large buffer itself. */
32920 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32921 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32922 - atomic_inc(&vcc->stats->rx_err);
32923 + atomic_inc_unchecked(&vcc->stats->rx_err);
32924 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32925 NS_MAX_IOVECS);
32926 NS_PRV_IOVCNT(iovb) = 0;
32927 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32928 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32929 card->index);
32930 which_list(card, skb);
32931 - atomic_inc(&vcc->stats->rx_err);
32932 + atomic_inc_unchecked(&vcc->stats->rx_err);
32933 recycle_rx_buf(card, skb);
32934 vc->rx_iov = NULL;
32935 recycle_iov_buf(card, iovb);
32936 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32937 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32938 card->index);
32939 which_list(card, skb);
32940 - atomic_inc(&vcc->stats->rx_err);
32941 + atomic_inc_unchecked(&vcc->stats->rx_err);
32942 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32943 NS_PRV_IOVCNT(iovb));
32944 vc->rx_iov = NULL;
32945 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32946 printk(" - PDU size mismatch.\n");
32947 else
32948 printk(".\n");
32949 - atomic_inc(&vcc->stats->rx_err);
32950 + atomic_inc_unchecked(&vcc->stats->rx_err);
32951 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32952 NS_PRV_IOVCNT(iovb));
32953 vc->rx_iov = NULL;
32954 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32955 /* skb points to a small buffer */
32956 if (!atm_charge(vcc, skb->truesize)) {
32957 push_rxbufs(card, skb);
32958 - atomic_inc(&vcc->stats->rx_drop);
32959 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32960 } else {
32961 skb_put(skb, len);
32962 dequeue_sm_buf(card, skb);
32963 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32964 ATM_SKB(skb)->vcc = vcc;
32965 __net_timestamp(skb);
32966 vcc->push(vcc, skb);
32967 - atomic_inc(&vcc->stats->rx);
32968 + atomic_inc_unchecked(&vcc->stats->rx);
32969 }
32970 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32971 struct sk_buff *sb;
32972 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32973 if (len <= NS_SMBUFSIZE) {
32974 if (!atm_charge(vcc, sb->truesize)) {
32975 push_rxbufs(card, sb);
32976 - atomic_inc(&vcc->stats->rx_drop);
32977 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32978 } else {
32979 skb_put(sb, len);
32980 dequeue_sm_buf(card, sb);
32981 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32982 ATM_SKB(sb)->vcc = vcc;
32983 __net_timestamp(sb);
32984 vcc->push(vcc, sb);
32985 - atomic_inc(&vcc->stats->rx);
32986 + atomic_inc_unchecked(&vcc->stats->rx);
32987 }
32988
32989 push_rxbufs(card, skb);
32990 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32991
32992 if (!atm_charge(vcc, skb->truesize)) {
32993 push_rxbufs(card, skb);
32994 - atomic_inc(&vcc->stats->rx_drop);
32995 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32996 } else {
32997 dequeue_lg_buf(card, skb);
32998 #ifdef NS_USE_DESTRUCTORS
32999 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33000 ATM_SKB(skb)->vcc = vcc;
33001 __net_timestamp(skb);
33002 vcc->push(vcc, skb);
33003 - atomic_inc(&vcc->stats->rx);
33004 + atomic_inc_unchecked(&vcc->stats->rx);
33005 }
33006
33007 push_rxbufs(card, sb);
33008 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33009 printk
33010 ("nicstar%d: Out of huge buffers.\n",
33011 card->index);
33012 - atomic_inc(&vcc->stats->rx_drop);
33013 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33014 recycle_iovec_rx_bufs(card,
33015 (struct iovec *)
33016 iovb->data,
33017 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33018 card->hbpool.count++;
33019 } else
33020 dev_kfree_skb_any(hb);
33021 - atomic_inc(&vcc->stats->rx_drop);
33022 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33023 } else {
33024 /* Copy the small buffer to the huge buffer */
33025 sb = (struct sk_buff *)iov->iov_base;
33026 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33027 #endif /* NS_USE_DESTRUCTORS */
33028 __net_timestamp(hb);
33029 vcc->push(vcc, hb);
33030 - atomic_inc(&vcc->stats->rx);
33031 + atomic_inc_unchecked(&vcc->stats->rx);
33032 }
33033 }
33034
33035 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33036 index 32784d1..4a8434a 100644
33037 --- a/drivers/atm/solos-pci.c
33038 +++ b/drivers/atm/solos-pci.c
33039 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33040 }
33041 atm_charge(vcc, skb->truesize);
33042 vcc->push(vcc, skb);
33043 - atomic_inc(&vcc->stats->rx);
33044 + atomic_inc_unchecked(&vcc->stats->rx);
33045 break;
33046
33047 case PKT_STATUS:
33048 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33049 vcc = SKB_CB(oldskb)->vcc;
33050
33051 if (vcc) {
33052 - atomic_inc(&vcc->stats->tx);
33053 + atomic_inc_unchecked(&vcc->stats->tx);
33054 solos_pop(vcc, oldskb);
33055 } else {
33056 dev_kfree_skb_irq(oldskb);
33057 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33058 index 0215934..ce9f5b1 100644
33059 --- a/drivers/atm/suni.c
33060 +++ b/drivers/atm/suni.c
33061 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33062
33063
33064 #define ADD_LIMITED(s,v) \
33065 - atomic_add((v),&stats->s); \
33066 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33067 + atomic_add_unchecked((v),&stats->s); \
33068 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33069
33070
33071 static void suni_hz(unsigned long from_timer)
33072 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33073 index 5120a96..e2572bd 100644
33074 --- a/drivers/atm/uPD98402.c
33075 +++ b/drivers/atm/uPD98402.c
33076 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33077 struct sonet_stats tmp;
33078 int error = 0;
33079
33080 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33081 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33082 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33083 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33084 if (zero && !error) {
33085 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33086
33087
33088 #define ADD_LIMITED(s,v) \
33089 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33090 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33091 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33092 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33093 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33094 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33095
33096
33097 static void stat_event(struct atm_dev *dev)
33098 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33099 if (reason & uPD98402_INT_PFM) stat_event(dev);
33100 if (reason & uPD98402_INT_PCO) {
33101 (void) GET(PCOCR); /* clear interrupt cause */
33102 - atomic_add(GET(HECCT),
33103 + atomic_add_unchecked(GET(HECCT),
33104 &PRIV(dev)->sonet_stats.uncorr_hcs);
33105 }
33106 if ((reason & uPD98402_INT_RFO) &&
33107 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33108 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33109 uPD98402_INT_LOS),PIMR); /* enable them */
33110 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33111 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33112 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33113 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33114 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33115 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33116 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33117 return 0;
33118 }
33119
33120 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33121 index 969c3c2..9b72956 100644
33122 --- a/drivers/atm/zatm.c
33123 +++ b/drivers/atm/zatm.c
33124 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33125 }
33126 if (!size) {
33127 dev_kfree_skb_irq(skb);
33128 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33129 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33130 continue;
33131 }
33132 if (!atm_charge(vcc,skb->truesize)) {
33133 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33134 skb->len = size;
33135 ATM_SKB(skb)->vcc = vcc;
33136 vcc->push(vcc,skb);
33137 - atomic_inc(&vcc->stats->rx);
33138 + atomic_inc_unchecked(&vcc->stats->rx);
33139 }
33140 zout(pos & 0xffff,MTA(mbx));
33141 #if 0 /* probably a stupid idea */
33142 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33143 skb_queue_head(&zatm_vcc->backlog,skb);
33144 break;
33145 }
33146 - atomic_inc(&vcc->stats->tx);
33147 + atomic_inc_unchecked(&vcc->stats->tx);
33148 wake_up(&zatm_vcc->tx_wait);
33149 }
33150
33151 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
33152 index d78b204..ecc1929 100644
33153 --- a/drivers/base/attribute_container.c
33154 +++ b/drivers/base/attribute_container.c
33155 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
33156 ic->classdev.parent = get_device(dev);
33157 ic->classdev.class = cont->class;
33158 cont->class->dev_release = attribute_container_release;
33159 - dev_set_name(&ic->classdev, dev_name(dev));
33160 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
33161 if (fn)
33162 fn(cont, dev, &ic->classdev);
33163 else
33164 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33165 index d414331..b4dd4ba 100644
33166 --- a/drivers/base/bus.c
33167 +++ b/drivers/base/bus.c
33168 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33169 return -EINVAL;
33170
33171 mutex_lock(&subsys->p->mutex);
33172 - list_add_tail(&sif->node, &subsys->p->interfaces);
33173 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33174 if (sif->add_dev) {
33175 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33176 while ((dev = subsys_dev_iter_next(&iter)))
33177 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33178 subsys = sif->subsys;
33179
33180 mutex_lock(&subsys->p->mutex);
33181 - list_del_init(&sif->node);
33182 + pax_list_del_init((struct list_head *)&sif->node);
33183 if (sif->remove_dev) {
33184 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33185 while ((dev = subsys_dev_iter_next(&iter)))
33186 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33187 index 7413d06..79155fa 100644
33188 --- a/drivers/base/devtmpfs.c
33189 +++ b/drivers/base/devtmpfs.c
33190 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
33191 if (!thread)
33192 return 0;
33193
33194 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33195 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33196 if (err)
33197 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33198 else
33199 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
33200 *err = sys_unshare(CLONE_NEWNS);
33201 if (*err)
33202 goto out;
33203 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33204 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33205 if (*err)
33206 goto out;
33207 - sys_chdir("/.."); /* will traverse into overmounted root */
33208 - sys_chroot(".");
33209 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33210 + sys_chroot((char __force_user *)".");
33211 complete(&setup_done);
33212 while (1) {
33213 spin_lock(&req_lock);
33214 diff --git a/drivers/base/node.c b/drivers/base/node.c
33215 index 7616a77c..8f57f51 100644
33216 --- a/drivers/base/node.c
33217 +++ b/drivers/base/node.c
33218 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33219 struct node_attr {
33220 struct device_attribute attr;
33221 enum node_states state;
33222 -};
33223 +} __do_const;
33224
33225 static ssize_t show_node_state(struct device *dev,
33226 struct device_attribute *attr, char *buf)
33227 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33228 index 7072404..76dcebd 100644
33229 --- a/drivers/base/power/domain.c
33230 +++ b/drivers/base/power/domain.c
33231 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33232 {
33233 struct cpuidle_driver *cpuidle_drv;
33234 struct gpd_cpu_data *cpu_data;
33235 - struct cpuidle_state *idle_state;
33236 + cpuidle_state_no_const *idle_state;
33237 int ret = 0;
33238
33239 if (IS_ERR_OR_NULL(genpd) || state < 0)
33240 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33241 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33242 {
33243 struct gpd_cpu_data *cpu_data;
33244 - struct cpuidle_state *idle_state;
33245 + cpuidle_state_no_const *idle_state;
33246 int ret = 0;
33247
33248 if (IS_ERR_OR_NULL(genpd))
33249 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
33250 index a53ebd2..8f73eeb 100644
33251 --- a/drivers/base/power/sysfs.c
33252 +++ b/drivers/base/power/sysfs.c
33253 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
33254 return -EIO;
33255 }
33256 }
33257 - return sprintf(buf, p);
33258 + return sprintf(buf, "%s", p);
33259 }
33260
33261 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
33262 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33263 index 79715e7..df06b3b 100644
33264 --- a/drivers/base/power/wakeup.c
33265 +++ b/drivers/base/power/wakeup.c
33266 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33267 * They need to be modified together atomically, so it's better to use one
33268 * atomic variable to hold them both.
33269 */
33270 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33271 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33272
33273 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33274 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33275
33276 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33277 {
33278 - unsigned int comb = atomic_read(&combined_event_count);
33279 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33280
33281 *cnt = (comb >> IN_PROGRESS_BITS);
33282 *inpr = comb & MAX_IN_PROGRESS;
33283 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33284 ws->start_prevent_time = ws->last_time;
33285
33286 /* Increment the counter of events in progress. */
33287 - cec = atomic_inc_return(&combined_event_count);
33288 + cec = atomic_inc_return_unchecked(&combined_event_count);
33289
33290 trace_wakeup_source_activate(ws->name, cec);
33291 }
33292 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33293 * Increment the counter of registered wakeup events and decrement the
33294 * couter of wakeup events in progress simultaneously.
33295 */
33296 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33297 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33298 trace_wakeup_source_deactivate(ws->name, cec);
33299
33300 split_counters(&cnt, &inpr);
33301 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33302 index e8d11b6..7b1b36f 100644
33303 --- a/drivers/base/syscore.c
33304 +++ b/drivers/base/syscore.c
33305 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33306 void register_syscore_ops(struct syscore_ops *ops)
33307 {
33308 mutex_lock(&syscore_ops_lock);
33309 - list_add_tail(&ops->node, &syscore_ops_list);
33310 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33311 mutex_unlock(&syscore_ops_lock);
33312 }
33313 EXPORT_SYMBOL_GPL(register_syscore_ops);
33314 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33315 void unregister_syscore_ops(struct syscore_ops *ops)
33316 {
33317 mutex_lock(&syscore_ops_lock);
33318 - list_del(&ops->node);
33319 + pax_list_del((struct list_head *)&ops->node);
33320 mutex_unlock(&syscore_ops_lock);
33321 }
33322 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33323 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33324 index 62b6c2c..4a11354 100644
33325 --- a/drivers/block/cciss.c
33326 +++ b/drivers/block/cciss.c
33327 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33328 int err;
33329 u32 cp;
33330
33331 + memset(&arg64, 0, sizeof(arg64));
33332 +
33333 err = 0;
33334 err |=
33335 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33336 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
33337 while (!list_empty(&h->reqQ)) {
33338 c = list_entry(h->reqQ.next, CommandList_struct, list);
33339 /* can't do anything if fifo is full */
33340 - if ((h->access.fifo_full(h))) {
33341 + if ((h->access->fifo_full(h))) {
33342 dev_warn(&h->pdev->dev, "fifo full\n");
33343 break;
33344 }
33345 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
33346 h->Qdepth--;
33347
33348 /* Tell the controller execute command */
33349 - h->access.submit_command(h, c);
33350 + h->access->submit_command(h, c);
33351
33352 /* Put job onto the completed Q */
33353 addQ(&h->cmpQ, c);
33354 @@ -3446,17 +3448,17 @@ startio:
33355
33356 static inline unsigned long get_next_completion(ctlr_info_t *h)
33357 {
33358 - return h->access.command_completed(h);
33359 + return h->access->command_completed(h);
33360 }
33361
33362 static inline int interrupt_pending(ctlr_info_t *h)
33363 {
33364 - return h->access.intr_pending(h);
33365 + return h->access->intr_pending(h);
33366 }
33367
33368 static inline long interrupt_not_for_us(ctlr_info_t *h)
33369 {
33370 - return ((h->access.intr_pending(h) == 0) ||
33371 + return ((h->access->intr_pending(h) == 0) ||
33372 (h->interrupts_enabled == 0));
33373 }
33374
33375 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
33376 u32 a;
33377
33378 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33379 - return h->access.command_completed(h);
33380 + return h->access->command_completed(h);
33381
33382 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33383 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33384 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33385 trans_support & CFGTBL_Trans_use_short_tags);
33386
33387 /* Change the access methods to the performant access methods */
33388 - h->access = SA5_performant_access;
33389 + h->access = &SA5_performant_access;
33390 h->transMethod = CFGTBL_Trans_Performant;
33391
33392 return;
33393 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33394 if (prod_index < 0)
33395 return -ENODEV;
33396 h->product_name = products[prod_index].product_name;
33397 - h->access = *(products[prod_index].access);
33398 + h->access = products[prod_index].access;
33399
33400 if (cciss_board_disabled(h)) {
33401 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33402 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
33403 }
33404
33405 /* make sure the board interrupts are off */
33406 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33407 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33408 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33409 if (rc)
33410 goto clean2;
33411 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
33412 * fake ones to scoop up any residual completions.
33413 */
33414 spin_lock_irqsave(&h->lock, flags);
33415 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33416 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33417 spin_unlock_irqrestore(&h->lock, flags);
33418 free_irq(h->intr[h->intr_mode], h);
33419 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33420 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
33421 dev_info(&h->pdev->dev, "Board READY.\n");
33422 dev_info(&h->pdev->dev,
33423 "Waiting for stale completions to drain.\n");
33424 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33425 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33426 msleep(10000);
33427 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33428 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33429
33430 rc = controller_reset_failed(h->cfgtable);
33431 if (rc)
33432 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
33433 cciss_scsi_setup(h);
33434
33435 /* Turn the interrupts on so we can service requests */
33436 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33437 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33438
33439 /* Get the firmware version */
33440 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33441 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33442 kfree(flush_buf);
33443 if (return_code != IO_OK)
33444 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33445 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33446 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33447 free_irq(h->intr[h->intr_mode], h);
33448 }
33449
33450 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33451 index 7fda30e..eb5dfe0 100644
33452 --- a/drivers/block/cciss.h
33453 +++ b/drivers/block/cciss.h
33454 @@ -101,7 +101,7 @@ struct ctlr_info
33455 /* information about each logical volume */
33456 drive_info_struct *drv[CISS_MAX_LUN];
33457
33458 - struct access_method access;
33459 + struct access_method *access;
33460
33461 /* queue and queue Info */
33462 struct list_head reqQ;
33463 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33464 index 639d26b..fd6ad1f 100644
33465 --- a/drivers/block/cpqarray.c
33466 +++ b/drivers/block/cpqarray.c
33467 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33468 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33469 goto Enomem4;
33470 }
33471 - hba[i]->access.set_intr_mask(hba[i], 0);
33472 + hba[i]->access->set_intr_mask(hba[i], 0);
33473 if (request_irq(hba[i]->intr, do_ida_intr,
33474 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33475 {
33476 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33477 add_timer(&hba[i]->timer);
33478
33479 /* Enable IRQ now that spinlock and rate limit timer are set up */
33480 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33481 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33482
33483 for(j=0; j<NWD; j++) {
33484 struct gendisk *disk = ida_gendisk[i][j];
33485 @@ -694,7 +694,7 @@ DBGINFO(
33486 for(i=0; i<NR_PRODUCTS; i++) {
33487 if (board_id == products[i].board_id) {
33488 c->product_name = products[i].product_name;
33489 - c->access = *(products[i].access);
33490 + c->access = products[i].access;
33491 break;
33492 }
33493 }
33494 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33495 hba[ctlr]->intr = intr;
33496 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33497 hba[ctlr]->product_name = products[j].product_name;
33498 - hba[ctlr]->access = *(products[j].access);
33499 + hba[ctlr]->access = products[j].access;
33500 hba[ctlr]->ctlr = ctlr;
33501 hba[ctlr]->board_id = board_id;
33502 hba[ctlr]->pci_dev = NULL; /* not PCI */
33503 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
33504
33505 while((c = h->reqQ) != NULL) {
33506 /* Can't do anything if we're busy */
33507 - if (h->access.fifo_full(h) == 0)
33508 + if (h->access->fifo_full(h) == 0)
33509 return;
33510
33511 /* Get the first entry from the request Q */
33512 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
33513 h->Qdepth--;
33514
33515 /* Tell the controller to do our bidding */
33516 - h->access.submit_command(h, c);
33517 + h->access->submit_command(h, c);
33518
33519 /* Get onto the completion Q */
33520 addQ(&h->cmpQ, c);
33521 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33522 unsigned long flags;
33523 __u32 a,a1;
33524
33525 - istat = h->access.intr_pending(h);
33526 + istat = h->access->intr_pending(h);
33527 /* Is this interrupt for us? */
33528 if (istat == 0)
33529 return IRQ_NONE;
33530 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33531 */
33532 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33533 if (istat & FIFO_NOT_EMPTY) {
33534 - while((a = h->access.command_completed(h))) {
33535 + while((a = h->access->command_completed(h))) {
33536 a1 = a; a &= ~3;
33537 if ((c = h->cmpQ) == NULL)
33538 {
33539 @@ -1193,6 +1193,7 @@ out_passthru:
33540 ida_pci_info_struct pciinfo;
33541
33542 if (!arg) return -EINVAL;
33543 + memset(&pciinfo, 0, sizeof(pciinfo));
33544 pciinfo.bus = host->pci_dev->bus->number;
33545 pciinfo.dev_fn = host->pci_dev->devfn;
33546 pciinfo.board_id = host->board_id;
33547 @@ -1447,11 +1448,11 @@ static int sendcmd(
33548 /*
33549 * Disable interrupt
33550 */
33551 - info_p->access.set_intr_mask(info_p, 0);
33552 + info_p->access->set_intr_mask(info_p, 0);
33553 /* Make sure there is room in the command FIFO */
33554 /* Actually it should be completely empty at this time. */
33555 for (i = 200000; i > 0; i--) {
33556 - temp = info_p->access.fifo_full(info_p);
33557 + temp = info_p->access->fifo_full(info_p);
33558 if (temp != 0) {
33559 break;
33560 }
33561 @@ -1464,7 +1465,7 @@ DBG(
33562 /*
33563 * Send the cmd
33564 */
33565 - info_p->access.submit_command(info_p, c);
33566 + info_p->access->submit_command(info_p, c);
33567 complete = pollcomplete(ctlr);
33568
33569 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33570 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33571 * we check the new geometry. Then turn interrupts back on when
33572 * we're done.
33573 */
33574 - host->access.set_intr_mask(host, 0);
33575 + host->access->set_intr_mask(host, 0);
33576 getgeometry(ctlr);
33577 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33578 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33579
33580 for(i=0; i<NWD; i++) {
33581 struct gendisk *disk = ida_gendisk[ctlr][i];
33582 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
33583 /* Wait (up to 2 seconds) for a command to complete */
33584
33585 for (i = 200000; i > 0; i--) {
33586 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33587 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33588 if (done == 0) {
33589 udelay(10); /* a short fixed delay */
33590 } else
33591 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33592 index be73e9d..7fbf140 100644
33593 --- a/drivers/block/cpqarray.h
33594 +++ b/drivers/block/cpqarray.h
33595 @@ -99,7 +99,7 @@ struct ctlr_info {
33596 drv_info_t drv[NWD];
33597 struct proc_dir_entry *proc;
33598
33599 - struct access_method access;
33600 + struct access_method *access;
33601
33602 cmdlist_t *reqQ;
33603 cmdlist_t *cmpQ;
33604 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33605 index f943aac..99bfd19 100644
33606 --- a/drivers/block/drbd/drbd_int.h
33607 +++ b/drivers/block/drbd/drbd_int.h
33608 @@ -582,7 +582,7 @@ struct drbd_epoch {
33609 struct drbd_tconn *tconn;
33610 struct list_head list;
33611 unsigned int barrier_nr;
33612 - atomic_t epoch_size; /* increased on every request added. */
33613 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33614 atomic_t active; /* increased on every req. added, and dec on every finished. */
33615 unsigned long flags;
33616 };
33617 @@ -1021,7 +1021,7 @@ struct drbd_conf {
33618 unsigned int al_tr_number;
33619 int al_tr_cycle;
33620 wait_queue_head_t seq_wait;
33621 - atomic_t packet_seq;
33622 + atomic_unchecked_t packet_seq;
33623 unsigned int peer_seq;
33624 spinlock_t peer_seq_lock;
33625 unsigned int minor;
33626 @@ -1562,7 +1562,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33627 char __user *uoptval;
33628 int err;
33629
33630 - uoptval = (char __user __force *)optval;
33631 + uoptval = (char __force_user *)optval;
33632
33633 set_fs(KERNEL_DS);
33634 if (level == SOL_SOCKET)
33635 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33636 index a5dca6a..bb27967 100644
33637 --- a/drivers/block/drbd/drbd_main.c
33638 +++ b/drivers/block/drbd/drbd_main.c
33639 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33640 p->sector = sector;
33641 p->block_id = block_id;
33642 p->blksize = blksize;
33643 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33644 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33645 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33646 }
33647
33648 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33649 return -EIO;
33650 p->sector = cpu_to_be64(req->i.sector);
33651 p->block_id = (unsigned long)req;
33652 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33653 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33654 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33655 if (mdev->state.conn >= C_SYNC_SOURCE &&
33656 mdev->state.conn <= C_PAUSED_SYNC_T)
33657 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33658 {
33659 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33660
33661 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33662 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33663 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33664 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33665 kfree(tconn->current_epoch);
33666
33667 idr_destroy(&tconn->volumes);
33668 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33669 index 4222aff..1f79506 100644
33670 --- a/drivers/block/drbd/drbd_receiver.c
33671 +++ b/drivers/block/drbd/drbd_receiver.c
33672 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
33673 {
33674 int err;
33675
33676 - atomic_set(&mdev->packet_seq, 0);
33677 + atomic_set_unchecked(&mdev->packet_seq, 0);
33678 mdev->peer_seq = 0;
33679
33680 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33681 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33682 do {
33683 next_epoch = NULL;
33684
33685 - epoch_size = atomic_read(&epoch->epoch_size);
33686 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33687
33688 switch (ev & ~EV_CLEANUP) {
33689 case EV_PUT:
33690 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33691 rv = FE_DESTROYED;
33692 } else {
33693 epoch->flags = 0;
33694 - atomic_set(&epoch->epoch_size, 0);
33695 + atomic_set_unchecked(&epoch->epoch_size, 0);
33696 /* atomic_set(&epoch->active, 0); is already zero */
33697 if (rv == FE_STILL_LIVE)
33698 rv = FE_RECYCLED;
33699 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33700 conn_wait_active_ee_empty(tconn);
33701 drbd_flush(tconn);
33702
33703 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33704 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33705 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33706 if (epoch)
33707 break;
33708 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33709 }
33710
33711 epoch->flags = 0;
33712 - atomic_set(&epoch->epoch_size, 0);
33713 + atomic_set_unchecked(&epoch->epoch_size, 0);
33714 atomic_set(&epoch->active, 0);
33715
33716 spin_lock(&tconn->epoch_lock);
33717 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33718 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33719 list_add(&epoch->list, &tconn->current_epoch->list);
33720 tconn->current_epoch = epoch;
33721 tconn->epochs++;
33722 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33723
33724 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33725 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33726 - atomic_inc(&tconn->current_epoch->epoch_size);
33727 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33728 err2 = drbd_drain_block(mdev, pi->size);
33729 if (!err)
33730 err = err2;
33731 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33732
33733 spin_lock(&tconn->epoch_lock);
33734 peer_req->epoch = tconn->current_epoch;
33735 - atomic_inc(&peer_req->epoch->epoch_size);
33736 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33737 atomic_inc(&peer_req->epoch->active);
33738 spin_unlock(&tconn->epoch_lock);
33739
33740 @@ -4347,7 +4347,7 @@ struct data_cmd {
33741 int expect_payload;
33742 size_t pkt_size;
33743 int (*fn)(struct drbd_tconn *, struct packet_info *);
33744 -};
33745 +} __do_const;
33746
33747 static struct data_cmd drbd_cmd_handler[] = {
33748 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33749 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33750 if (!list_empty(&tconn->current_epoch->list))
33751 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33752 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33753 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33754 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33755 tconn->send.seen_any_write_yet = false;
33756
33757 conn_info(tconn, "Connection closed\n");
33758 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33759 struct asender_cmd {
33760 size_t pkt_size;
33761 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33762 -};
33763 +} __do_const;
33764
33765 static struct asender_cmd asender_tbl[] = {
33766 [P_PING] = { 0, got_Ping },
33767 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33768 index d92d50f..a7e9d97 100644
33769 --- a/drivers/block/loop.c
33770 +++ b/drivers/block/loop.c
33771 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
33772
33773 file_start_write(file);
33774 set_fs(get_ds());
33775 - bw = file->f_op->write(file, buf, len, &pos);
33776 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33777 set_fs(old_fs);
33778 file_end_write(file);
33779 if (likely(bw == len))
33780 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33781 index f5d0ea1..c62380a 100644
33782 --- a/drivers/block/pktcdvd.c
33783 +++ b/drivers/block/pktcdvd.c
33784 @@ -84,7 +84,7 @@
33785 #define MAX_SPEED 0xffff
33786
33787 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
33788 - ~(sector_t)((pd)->settings.size - 1))
33789 + ~(sector_t)((pd)->settings.size - 1UL))
33790
33791 static DEFINE_MUTEX(pktcdvd_mutex);
33792 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33793 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33794 index 8a3aff7..d7538c2 100644
33795 --- a/drivers/cdrom/cdrom.c
33796 +++ b/drivers/cdrom/cdrom.c
33797 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33798 ENSURE(reset, CDC_RESET);
33799 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33800 cdi->mc_flags = 0;
33801 - cdo->n_minors = 0;
33802 cdi->options = CDO_USE_FFLAGS;
33803
33804 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33805 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33806 else
33807 cdi->cdda_method = CDDA_OLD;
33808
33809 - if (!cdo->generic_packet)
33810 - cdo->generic_packet = cdrom_dummy_generic_packet;
33811 + if (!cdo->generic_packet) {
33812 + pax_open_kernel();
33813 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33814 + pax_close_kernel();
33815 + }
33816
33817 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33818 mutex_lock(&cdrom_mutex);
33819 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33820 if (cdi->exit)
33821 cdi->exit(cdi);
33822
33823 - cdi->ops->n_minors--;
33824 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33825 }
33826
33827 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
33828 */
33829 nr = nframes;
33830 do {
33831 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33832 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33833 if (cgc.buffer)
33834 break;
33835
33836 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
33837 struct cdrom_device_info *cdi;
33838 int ret;
33839
33840 - ret = scnprintf(info + *pos, max_size - *pos, header);
33841 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
33842 if (!ret)
33843 return 1;
33844
33845 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33846 index 4afcb65..a68a32d 100644
33847 --- a/drivers/cdrom/gdrom.c
33848 +++ b/drivers/cdrom/gdrom.c
33849 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33850 .audio_ioctl = gdrom_audio_ioctl,
33851 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33852 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33853 - .n_minors = 1,
33854 };
33855
33856 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33857 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33858 index 3bb6fa3..34013fb 100644
33859 --- a/drivers/char/Kconfig
33860 +++ b/drivers/char/Kconfig
33861 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33862
33863 config DEVKMEM
33864 bool "/dev/kmem virtual device support"
33865 - default y
33866 + default n
33867 + depends on !GRKERNSEC_KMEM
33868 help
33869 Say Y here if you want to support the /dev/kmem device. The
33870 /dev/kmem device is rarely used, but can be used for certain
33871 @@ -582,6 +583,7 @@ config DEVPORT
33872 bool
33873 depends on !M68K
33874 depends on ISA || PCI
33875 + depends on !GRKERNSEC_KMEM
33876 default y
33877
33878 source "drivers/s390/char/Kconfig"
33879 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33880 index a48e05b..6bac831 100644
33881 --- a/drivers/char/agp/compat_ioctl.c
33882 +++ b/drivers/char/agp/compat_ioctl.c
33883 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33884 return -ENOMEM;
33885 }
33886
33887 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33888 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33889 sizeof(*usegment) * ureserve.seg_count)) {
33890 kfree(usegment);
33891 kfree(ksegment);
33892 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33893 index 2e04433..771f2cc 100644
33894 --- a/drivers/char/agp/frontend.c
33895 +++ b/drivers/char/agp/frontend.c
33896 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33897 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33898 return -EFAULT;
33899
33900 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33901 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33902 return -EFAULT;
33903
33904 client = agp_find_client_by_pid(reserve.pid);
33905 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33906 if (segment == NULL)
33907 return -ENOMEM;
33908
33909 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33910 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33911 sizeof(struct agp_segment) * reserve.seg_count)) {
33912 kfree(segment);
33913 return -EFAULT;
33914 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33915 index 4f94375..413694e 100644
33916 --- a/drivers/char/genrtc.c
33917 +++ b/drivers/char/genrtc.c
33918 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
33919 switch (cmd) {
33920
33921 case RTC_PLL_GET:
33922 + memset(&pll, 0, sizeof(pll));
33923 if (get_rtc_pll(&pll))
33924 return -EINVAL;
33925 else
33926 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33927 index d784650..e8bfd69 100644
33928 --- a/drivers/char/hpet.c
33929 +++ b/drivers/char/hpet.c
33930 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33931 }
33932
33933 static int
33934 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33935 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33936 struct hpet_info *info)
33937 {
33938 struct hpet_timer __iomem *timer;
33939 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
33940 index 86fe45c..c0ea948 100644
33941 --- a/drivers/char/hw_random/intel-rng.c
33942 +++ b/drivers/char/hw_random/intel-rng.c
33943 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
33944
33945 if (no_fwh_detect)
33946 return -ENODEV;
33947 - printk(warning);
33948 + printk("%s", warning);
33949 return -EBUSY;
33950 }
33951
33952 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33953 index 4445fa1..7c6de37 100644
33954 --- a/drivers/char/ipmi/ipmi_msghandler.c
33955 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33956 @@ -420,7 +420,7 @@ struct ipmi_smi {
33957 struct proc_dir_entry *proc_dir;
33958 char proc_dir_name[10];
33959
33960 - atomic_t stats[IPMI_NUM_STATS];
33961 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33962
33963 /*
33964 * run_to_completion duplicate of smb_info, smi_info
33965 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33966
33967
33968 #define ipmi_inc_stat(intf, stat) \
33969 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33970 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33971 #define ipmi_get_stat(intf, stat) \
33972 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33973 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33974
33975 static int is_lan_addr(struct ipmi_addr *addr)
33976 {
33977 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33978 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33979 init_waitqueue_head(&intf->waitq);
33980 for (i = 0; i < IPMI_NUM_STATS; i++)
33981 - atomic_set(&intf->stats[i], 0);
33982 + atomic_set_unchecked(&intf->stats[i], 0);
33983
33984 intf->proc_dir = NULL;
33985
33986 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33987 index af4b23f..79806fc 100644
33988 --- a/drivers/char/ipmi/ipmi_si_intf.c
33989 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33990 @@ -275,7 +275,7 @@ struct smi_info {
33991 unsigned char slave_addr;
33992
33993 /* Counters and things for the proc filesystem. */
33994 - atomic_t stats[SI_NUM_STATS];
33995 + atomic_unchecked_t stats[SI_NUM_STATS];
33996
33997 struct task_struct *thread;
33998
33999 @@ -284,9 +284,9 @@ struct smi_info {
34000 };
34001
34002 #define smi_inc_stat(smi, stat) \
34003 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34004 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34005 #define smi_get_stat(smi, stat) \
34006 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34007 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34008
34009 #define SI_MAX_PARMS 4
34010
34011 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
34012 atomic_set(&new_smi->req_events, 0);
34013 new_smi->run_to_completion = 0;
34014 for (i = 0; i < SI_NUM_STATS; i++)
34015 - atomic_set(&new_smi->stats[i], 0);
34016 + atomic_set_unchecked(&new_smi->stats[i], 0);
34017
34018 new_smi->interrupt_disabled = 1;
34019 atomic_set(&new_smi->stop_operation, 0);
34020 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34021 index 1ccbe94..6ad651a 100644
34022 --- a/drivers/char/mem.c
34023 +++ b/drivers/char/mem.c
34024 @@ -18,6 +18,7 @@
34025 #include <linux/raw.h>
34026 #include <linux/tty.h>
34027 #include <linux/capability.h>
34028 +#include <linux/security.h>
34029 #include <linux/ptrace.h>
34030 #include <linux/device.h>
34031 #include <linux/highmem.h>
34032 @@ -38,6 +39,10 @@
34033
34034 #define DEVPORT_MINOR 4
34035
34036 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34037 +extern const struct file_operations grsec_fops;
34038 +#endif
34039 +
34040 static inline unsigned long size_inside_page(unsigned long start,
34041 unsigned long size)
34042 {
34043 @@ -69,9 +74,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34044
34045 while (cursor < to) {
34046 if (!devmem_is_allowed(pfn)) {
34047 +#ifdef CONFIG_GRKERNSEC_KMEM
34048 + gr_handle_mem_readwrite(from, to);
34049 +#else
34050 printk(KERN_INFO
34051 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34052 current->comm, from, to);
34053 +#endif
34054 return 0;
34055 }
34056 cursor += PAGE_SIZE;
34057 @@ -79,6 +88,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34058 }
34059 return 1;
34060 }
34061 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34062 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34063 +{
34064 + return 0;
34065 +}
34066 #else
34067 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34068 {
34069 @@ -121,6 +135,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34070
34071 while (count > 0) {
34072 unsigned long remaining;
34073 + char *temp;
34074
34075 sz = size_inside_page(p, count);
34076
34077 @@ -136,7 +151,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34078 if (!ptr)
34079 return -EFAULT;
34080
34081 - remaining = copy_to_user(buf, ptr, sz);
34082 +#ifdef CONFIG_PAX_USERCOPY
34083 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34084 + if (!temp) {
34085 + unxlate_dev_mem_ptr(p, ptr);
34086 + return -ENOMEM;
34087 + }
34088 + memcpy(temp, ptr, sz);
34089 +#else
34090 + temp = ptr;
34091 +#endif
34092 +
34093 + remaining = copy_to_user(buf, temp, sz);
34094 +
34095 +#ifdef CONFIG_PAX_USERCOPY
34096 + kfree(temp);
34097 +#endif
34098 +
34099 unxlate_dev_mem_ptr(p, ptr);
34100 if (remaining)
34101 return -EFAULT;
34102 @@ -379,7 +410,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
34103 else
34104 csize = count;
34105
34106 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
34107 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
34108 if (rc < 0)
34109 return rc;
34110 buf += csize;
34111 @@ -399,9 +430,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34112 size_t count, loff_t *ppos)
34113 {
34114 unsigned long p = *ppos;
34115 - ssize_t low_count, read, sz;
34116 + ssize_t low_count, read, sz, err = 0;
34117 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34118 - int err = 0;
34119
34120 read = 0;
34121 if (p < (unsigned long) high_memory) {
34122 @@ -423,6 +453,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34123 }
34124 #endif
34125 while (low_count > 0) {
34126 + char *temp;
34127 +
34128 sz = size_inside_page(p, low_count);
34129
34130 /*
34131 @@ -432,7 +464,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34132 */
34133 kbuf = xlate_dev_kmem_ptr((char *)p);
34134
34135 - if (copy_to_user(buf, kbuf, sz))
34136 +#ifdef CONFIG_PAX_USERCOPY
34137 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34138 + if (!temp)
34139 + return -ENOMEM;
34140 + memcpy(temp, kbuf, sz);
34141 +#else
34142 + temp = kbuf;
34143 +#endif
34144 +
34145 + err = copy_to_user(buf, temp, sz);
34146 +
34147 +#ifdef CONFIG_PAX_USERCOPY
34148 + kfree(temp);
34149 +#endif
34150 +
34151 + if (err)
34152 return -EFAULT;
34153 buf += sz;
34154 p += sz;
34155 @@ -869,6 +916,9 @@ static const struct memdev {
34156 #ifdef CONFIG_CRASH_DUMP
34157 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34158 #endif
34159 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34160 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34161 +#endif
34162 };
34163
34164 static int memory_open(struct inode *inode, struct file *filp)
34165 @@ -940,7 +990,7 @@ static int __init chr_dev_init(void)
34166 continue;
34167
34168 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
34169 - NULL, devlist[minor].name);
34170 + NULL, "%s", devlist[minor].name);
34171 }
34172
34173 return tty_init();
34174 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
34175 index c689697..04e6d6a2 100644
34176 --- a/drivers/char/mwave/tp3780i.c
34177 +++ b/drivers/char/mwave/tp3780i.c
34178 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
34179 PRINTK_2(TRACE_TP3780I,
34180 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
34181
34182 + memset(pAbilities, 0, sizeof(*pAbilities));
34183 /* fill out standard constant fields */
34184 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
34185 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
34186 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34187 index 9df78e2..01ba9ae 100644
34188 --- a/drivers/char/nvram.c
34189 +++ b/drivers/char/nvram.c
34190 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34191
34192 spin_unlock_irq(&rtc_lock);
34193
34194 - if (copy_to_user(buf, contents, tmp - contents))
34195 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34196 return -EFAULT;
34197
34198 *ppos = i;
34199 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34200 index 5c5cc00..ac9edb7 100644
34201 --- a/drivers/char/pcmcia/synclink_cs.c
34202 +++ b/drivers/char/pcmcia/synclink_cs.c
34203 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34204
34205 if (debug_level >= DEBUG_LEVEL_INFO)
34206 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34207 - __FILE__, __LINE__, info->device_name, port->count);
34208 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
34209
34210 - WARN_ON(!port->count);
34211 + WARN_ON(!atomic_read(&port->count));
34212
34213 if (tty_port_close_start(port, tty, filp) == 0)
34214 goto cleanup;
34215 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34216 cleanup:
34217 if (debug_level >= DEBUG_LEVEL_INFO)
34218 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
34219 - tty->driver->name, port->count);
34220 + tty->driver->name, atomic_read(&port->count));
34221 }
34222
34223 /* Wait until the transmitter is empty.
34224 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34225
34226 if (debug_level >= DEBUG_LEVEL_INFO)
34227 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34228 - __FILE__, __LINE__, tty->driver->name, port->count);
34229 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
34230
34231 /* If port is closing, signal caller to try again */
34232 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34233 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34234 goto cleanup;
34235 }
34236 spin_lock(&port->lock);
34237 - port->count++;
34238 + atomic_inc(&port->count);
34239 spin_unlock(&port->lock);
34240 spin_unlock_irqrestore(&info->netlock, flags);
34241
34242 - if (port->count == 1) {
34243 + if (atomic_read(&port->count) == 1) {
34244 /* 1st open on this device, init hardware */
34245 retval = startup(info, tty);
34246 if (retval < 0)
34247 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34248 unsigned short new_crctype;
34249
34250 /* return error if TTY interface open */
34251 - if (info->port.count)
34252 + if (atomic_read(&info->port.count))
34253 return -EBUSY;
34254
34255 switch (encoding)
34256 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
34257
34258 /* arbitrate between network and tty opens */
34259 spin_lock_irqsave(&info->netlock, flags);
34260 - if (info->port.count != 0 || info->netcount != 0) {
34261 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34262 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34263 spin_unlock_irqrestore(&info->netlock, flags);
34264 return -EBUSY;
34265 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34266 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
34267
34268 /* return error if TTY interface open */
34269 - if (info->port.count)
34270 + if (atomic_read(&info->port.count))
34271 return -EBUSY;
34272
34273 if (cmd != SIOCWANDEV)
34274 diff --git a/drivers/char/random.c b/drivers/char/random.c
34275 index 35487e8..dac8bd1 100644
34276 --- a/drivers/char/random.c
34277 +++ b/drivers/char/random.c
34278 @@ -272,8 +272,13 @@
34279 /*
34280 * Configuration information
34281 */
34282 +#ifdef CONFIG_GRKERNSEC_RANDNET
34283 +#define INPUT_POOL_WORDS 512
34284 +#define OUTPUT_POOL_WORDS 128
34285 +#else
34286 #define INPUT_POOL_WORDS 128
34287 #define OUTPUT_POOL_WORDS 32
34288 +#endif
34289 #define SEC_XFER_SIZE 512
34290 #define EXTRACT_SIZE 10
34291
34292 @@ -313,10 +318,17 @@ static struct poolinfo {
34293 int poolwords;
34294 int tap1, tap2, tap3, tap4, tap5;
34295 } poolinfo_table[] = {
34296 +#ifdef CONFIG_GRKERNSEC_RANDNET
34297 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34298 + { 512, 411, 308, 208, 104, 1 },
34299 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34300 + { 128, 103, 76, 51, 25, 1 },
34301 +#else
34302 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34303 { 128, 103, 76, 51, 25, 1 },
34304 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34305 { 32, 26, 20, 14, 7, 1 },
34306 +#endif
34307 #if 0
34308 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34309 { 2048, 1638, 1231, 819, 411, 1 },
34310 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34311 input_rotate += i ? 7 : 14;
34312 }
34313
34314 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34315 - ACCESS_ONCE(r->add_ptr) = i;
34316 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34317 + ACCESS_ONCE_RW(r->add_ptr) = i;
34318 smp_wmb();
34319
34320 if (out)
34321 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34322
34323 extract_buf(r, tmp);
34324 i = min_t(int, nbytes, EXTRACT_SIZE);
34325 - if (copy_to_user(buf, tmp, i)) {
34326 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34327 ret = -EFAULT;
34328 break;
34329 }
34330 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34331 #include <linux/sysctl.h>
34332
34333 static int min_read_thresh = 8, min_write_thresh;
34334 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34335 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34336 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34337 static char sysctl_bootid[16];
34338
34339 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
34340 static int proc_do_uuid(ctl_table *table, int write,
34341 void __user *buffer, size_t *lenp, loff_t *ppos)
34342 {
34343 - ctl_table fake_table;
34344 + ctl_table_no_const fake_table;
34345 unsigned char buf[64], tmp_uuid[16], *uuid;
34346
34347 uuid = table->data;
34348 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34349 index bf2349db..5456d53 100644
34350 --- a/drivers/char/sonypi.c
34351 +++ b/drivers/char/sonypi.c
34352 @@ -54,6 +54,7 @@
34353
34354 #include <asm/uaccess.h>
34355 #include <asm/io.h>
34356 +#include <asm/local.h>
34357
34358 #include <linux/sonypi.h>
34359
34360 @@ -490,7 +491,7 @@ static struct sonypi_device {
34361 spinlock_t fifo_lock;
34362 wait_queue_head_t fifo_proc_list;
34363 struct fasync_struct *fifo_async;
34364 - int open_count;
34365 + local_t open_count;
34366 int model;
34367 struct input_dev *input_jog_dev;
34368 struct input_dev *input_key_dev;
34369 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34370 static int sonypi_misc_release(struct inode *inode, struct file *file)
34371 {
34372 mutex_lock(&sonypi_device.lock);
34373 - sonypi_device.open_count--;
34374 + local_dec(&sonypi_device.open_count);
34375 mutex_unlock(&sonypi_device.lock);
34376 return 0;
34377 }
34378 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34379 {
34380 mutex_lock(&sonypi_device.lock);
34381 /* Flush input queue on first open */
34382 - if (!sonypi_device.open_count)
34383 + if (!local_read(&sonypi_device.open_count))
34384 kfifo_reset(&sonypi_device.fifo);
34385 - sonypi_device.open_count++;
34386 + local_inc(&sonypi_device.open_count);
34387 mutex_unlock(&sonypi_device.lock);
34388
34389 return 0;
34390 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34391 index 64420b3..5c40b56 100644
34392 --- a/drivers/char/tpm/tpm_acpi.c
34393 +++ b/drivers/char/tpm/tpm_acpi.c
34394 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34395 virt = acpi_os_map_memory(start, len);
34396 if (!virt) {
34397 kfree(log->bios_event_log);
34398 + log->bios_event_log = NULL;
34399 printk("%s: ERROR - Unable to map memory\n", __func__);
34400 return -EIO;
34401 }
34402
34403 - memcpy_fromio(log->bios_event_log, virt, len);
34404 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34405
34406 acpi_os_unmap_memory(virt, len);
34407 return 0;
34408 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34409 index 84ddc55..1d32f1e 100644
34410 --- a/drivers/char/tpm/tpm_eventlog.c
34411 +++ b/drivers/char/tpm/tpm_eventlog.c
34412 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34413 event = addr;
34414
34415 if ((event->event_type == 0 && event->event_size == 0) ||
34416 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34417 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34418 return NULL;
34419
34420 return addr;
34421 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34422 return NULL;
34423
34424 if ((event->event_type == 0 && event->event_size == 0) ||
34425 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34426 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34427 return NULL;
34428
34429 (*pos)++;
34430 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34431 int i;
34432
34433 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34434 - seq_putc(m, data[i]);
34435 + if (!seq_putc(m, data[i]))
34436 + return -EFAULT;
34437
34438 return 0;
34439 }
34440 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34441 index 1b456fe..2510242 100644
34442 --- a/drivers/char/virtio_console.c
34443 +++ b/drivers/char/virtio_console.c
34444 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34445 if (to_user) {
34446 ssize_t ret;
34447
34448 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34449 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34450 if (ret)
34451 return -EFAULT;
34452 } else {
34453 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34454 if (!port_has_data(port) && !port->host_connected)
34455 return 0;
34456
34457 - return fill_readbuf(port, ubuf, count, true);
34458 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34459 }
34460
34461 static int wait_port_writable(struct port *port, bool nonblock)
34462 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
34463 index a33f46f..a720eed 100644
34464 --- a/drivers/clk/clk-composite.c
34465 +++ b/drivers/clk/clk-composite.c
34466 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
34467 struct clk *clk;
34468 struct clk_init_data init;
34469 struct clk_composite *composite;
34470 - struct clk_ops *clk_composite_ops;
34471 + clk_ops_no_const *clk_composite_ops;
34472
34473 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
34474 if (!composite) {
34475 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
34476 index bd11315..7f87098 100644
34477 --- a/drivers/clk/socfpga/clk.c
34478 +++ b/drivers/clk/socfpga/clk.c
34479 @@ -22,6 +22,7 @@
34480 #include <linux/clk-provider.h>
34481 #include <linux/io.h>
34482 #include <linux/of.h>
34483 +#include <asm/pgtable.h>
34484
34485 /* Clock Manager offsets */
34486 #define CLKMGR_CTRL 0x0
34487 @@ -135,8 +136,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
34488 if (strcmp(clk_name, "main_pll") || strcmp(clk_name, "periph_pll") ||
34489 strcmp(clk_name, "sdram_pll")) {
34490 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
34491 - clk_pll_ops.enable = clk_gate_ops.enable;
34492 - clk_pll_ops.disable = clk_gate_ops.disable;
34493 + pax_open_kernel();
34494 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
34495 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
34496 + pax_close_kernel();
34497 }
34498
34499 clk = clk_register(NULL, &socfpga_clk->hw.hw);
34500 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34501 index a2b2541..bc1e7ff 100644
34502 --- a/drivers/clocksource/arm_arch_timer.c
34503 +++ b/drivers/clocksource/arm_arch_timer.c
34504 @@ -264,7 +264,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34505 return NOTIFY_OK;
34506 }
34507
34508 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34509 +static struct notifier_block arch_timer_cpu_nb = {
34510 .notifier_call = arch_timer_cpu_notify,
34511 };
34512
34513 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34514 index ade7513..069445f 100644
34515 --- a/drivers/clocksource/metag_generic.c
34516 +++ b/drivers/clocksource/metag_generic.c
34517 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34518 return NOTIFY_OK;
34519 }
34520
34521 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34522 +static struct notifier_block arch_timer_cpu_nb = {
34523 .notifier_call = arch_timer_cpu_notify,
34524 };
34525
34526 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34527 index edc089e..bc7c0bc 100644
34528 --- a/drivers/cpufreq/acpi-cpufreq.c
34529 +++ b/drivers/cpufreq/acpi-cpufreq.c
34530 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34531 return sprintf(buf, "%u\n", boost_enabled);
34532 }
34533
34534 -static struct global_attr global_boost = __ATTR(boost, 0644,
34535 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34536 show_global_boost,
34537 store_global_boost);
34538
34539 @@ -705,8 +705,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34540 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34541 per_cpu(acfreq_data, cpu) = data;
34542
34543 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34544 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34545 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34546 + pax_open_kernel();
34547 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34548 + pax_close_kernel();
34549 + }
34550
34551 result = acpi_processor_register_performance(data->acpi_data, cpu);
34552 if (result)
34553 @@ -832,7 +835,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34554 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34555 break;
34556 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34557 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34558 + pax_open_kernel();
34559 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34560 + pax_close_kernel();
34561 policy->cur = get_cur_freq_on_cpu(cpu);
34562 break;
34563 default:
34564 @@ -843,8 +848,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34565 acpi_processor_notify_smm(THIS_MODULE);
34566
34567 /* Check for APERF/MPERF support in hardware */
34568 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34569 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34570 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34571 + pax_open_kernel();
34572 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34573 + pax_close_kernel();
34574 + }
34575
34576 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34577 for (i = 0; i < perf->state_count; i++)
34578 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34579 index 178fe7a..5ee8501 100644
34580 --- a/drivers/cpufreq/cpufreq.c
34581 +++ b/drivers/cpufreq/cpufreq.c
34582 @@ -1853,7 +1853,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34583 return NOTIFY_OK;
34584 }
34585
34586 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34587 +static struct notifier_block cpufreq_cpu_notifier = {
34588 .notifier_call = cpufreq_cpu_callback,
34589 };
34590
34591 @@ -1885,8 +1885,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34592
34593 pr_debug("trying to register driver %s\n", driver_data->name);
34594
34595 - if (driver_data->setpolicy)
34596 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34597 + if (driver_data->setpolicy) {
34598 + pax_open_kernel();
34599 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34600 + pax_close_kernel();
34601 + }
34602
34603 write_lock_irqsave(&cpufreq_driver_lock, flags);
34604 if (cpufreq_driver) {
34605 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34606 index 5af40ad..ddf907b 100644
34607 --- a/drivers/cpufreq/cpufreq_governor.c
34608 +++ b/drivers/cpufreq/cpufreq_governor.c
34609 @@ -235,7 +235,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34610 struct dbs_data *dbs_data;
34611 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34612 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34613 - struct od_ops *od_ops = NULL;
34614 + const struct od_ops *od_ops = NULL;
34615 struct od_dbs_tuners *od_tuners = NULL;
34616 struct cs_dbs_tuners *cs_tuners = NULL;
34617 struct cpu_dbs_common_info *cpu_cdbs;
34618 @@ -298,7 +298,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34619
34620 if ((cdata->governor == GOV_CONSERVATIVE) &&
34621 (!policy->governor->initialized)) {
34622 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34623 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34624
34625 cpufreq_register_notifier(cs_ops->notifier_block,
34626 CPUFREQ_TRANSITION_NOTIFIER);
34627 @@ -315,7 +315,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34628
34629 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
34630 (policy->governor->initialized == 1)) {
34631 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34632 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34633
34634 cpufreq_unregister_notifier(cs_ops->notifier_block,
34635 CPUFREQ_TRANSITION_NOTIFIER);
34636 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34637 index e16a961..0e68927 100644
34638 --- a/drivers/cpufreq/cpufreq_governor.h
34639 +++ b/drivers/cpufreq/cpufreq_governor.h
34640 @@ -204,7 +204,7 @@ struct common_dbs_data {
34641 void (*exit)(struct dbs_data *dbs_data);
34642
34643 /* Governor specific ops, see below */
34644 - void *gov_ops;
34645 + const void *gov_ops;
34646 };
34647
34648 /* Governer Per policy data */
34649 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
34650 index 93eb5cb..f8ab572 100644
34651 --- a/drivers/cpufreq/cpufreq_ondemand.c
34652 +++ b/drivers/cpufreq/cpufreq_ondemand.c
34653 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
34654 (struct cpufreq_policy *, unsigned int, unsigned int),
34655 unsigned int powersave_bias)
34656 {
34657 - od_ops.powersave_bias_target = f;
34658 + pax_open_kernel();
34659 + *(void **)&od_ops.powersave_bias_target = f;
34660 + pax_close_kernel();
34661 od_set_powersave_bias(powersave_bias);
34662 }
34663 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
34664
34665 void od_unregister_powersave_bias_handler(void)
34666 {
34667 - od_ops.powersave_bias_target = generic_powersave_bias_target;
34668 + pax_open_kernel();
34669 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
34670 + pax_close_kernel();
34671 od_set_powersave_bias(0);
34672 }
34673 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
34674 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34675 index bfd6273..e39dd63 100644
34676 --- a/drivers/cpufreq/cpufreq_stats.c
34677 +++ b/drivers/cpufreq/cpufreq_stats.c
34678 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34679 }
34680
34681 /* priority=1 so this will get called before cpufreq_remove_dev */
34682 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34683 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34684 .notifier_call = cpufreq_stat_cpu_callback,
34685 .priority = 1,
34686 };
34687 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34688 index 421ef37..e708530c 100644
34689 --- a/drivers/cpufreq/p4-clockmod.c
34690 +++ b/drivers/cpufreq/p4-clockmod.c
34691 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34692 case 0x0F: /* Core Duo */
34693 case 0x16: /* Celeron Core */
34694 case 0x1C: /* Atom */
34695 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34696 + pax_open_kernel();
34697 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34698 + pax_close_kernel();
34699 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34700 case 0x0D: /* Pentium M (Dothan) */
34701 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34702 + pax_open_kernel();
34703 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34704 + pax_close_kernel();
34705 /* fall through */
34706 case 0x09: /* Pentium M (Banias) */
34707 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34708 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34709
34710 /* on P-4s, the TSC runs with constant frequency independent whether
34711 * throttling is active or not. */
34712 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34713 + pax_open_kernel();
34714 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34715 + pax_close_kernel();
34716
34717 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34718 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34719 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
34720 index c71ee14..7c2e183 100644
34721 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
34722 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
34723 @@ -18,14 +18,12 @@
34724 #include <asm/head.h>
34725 #include <asm/timer.h>
34726
34727 -static struct cpufreq_driver *cpufreq_us3_driver;
34728 -
34729 struct us3_freq_percpu_info {
34730 struct cpufreq_frequency_table table[4];
34731 };
34732
34733 /* Indexed by cpu number. */
34734 -static struct us3_freq_percpu_info *us3_freq_table;
34735 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
34736
34737 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
34738 * in the Safari config register.
34739 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
34740
34741 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
34742 {
34743 - if (cpufreq_us3_driver)
34744 - us3_set_cpu_divider_index(policy, 0);
34745 + us3_set_cpu_divider_index(policy->cpu, 0);
34746
34747 return 0;
34748 }
34749
34750 +static int __init us3_freq_init(void);
34751 +static void __exit us3_freq_exit(void);
34752 +
34753 +static struct cpufreq_driver cpufreq_us3_driver = {
34754 + .init = us3_freq_cpu_init,
34755 + .verify = us3_freq_verify,
34756 + .target = us3_freq_target,
34757 + .get = us3_freq_get,
34758 + .exit = us3_freq_cpu_exit,
34759 + .owner = THIS_MODULE,
34760 + .name = "UltraSPARC-III",
34761 +
34762 +};
34763 +
34764 static int __init us3_freq_init(void)
34765 {
34766 unsigned long manuf, impl, ver;
34767 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
34768 (impl == CHEETAH_IMPL ||
34769 impl == CHEETAH_PLUS_IMPL ||
34770 impl == JAGUAR_IMPL ||
34771 - impl == PANTHER_IMPL)) {
34772 - struct cpufreq_driver *driver;
34773 -
34774 - ret = -ENOMEM;
34775 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
34776 - if (!driver)
34777 - goto err_out;
34778 -
34779 - us3_freq_table = kzalloc(
34780 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
34781 - GFP_KERNEL);
34782 - if (!us3_freq_table)
34783 - goto err_out;
34784 -
34785 - driver->init = us3_freq_cpu_init;
34786 - driver->verify = us3_freq_verify;
34787 - driver->target = us3_freq_target;
34788 - driver->get = us3_freq_get;
34789 - driver->exit = us3_freq_cpu_exit;
34790 - driver->owner = THIS_MODULE,
34791 - strcpy(driver->name, "UltraSPARC-III");
34792 -
34793 - cpufreq_us3_driver = driver;
34794 - ret = cpufreq_register_driver(driver);
34795 - if (ret)
34796 - goto err_out;
34797 -
34798 - return 0;
34799 -
34800 -err_out:
34801 - if (driver) {
34802 - kfree(driver);
34803 - cpufreq_us3_driver = NULL;
34804 - }
34805 - kfree(us3_freq_table);
34806 - us3_freq_table = NULL;
34807 - return ret;
34808 - }
34809 + impl == PANTHER_IMPL))
34810 + return cpufreq_register_driver(&cpufreq_us3_driver);
34811
34812 return -ENODEV;
34813 }
34814
34815 static void __exit us3_freq_exit(void)
34816 {
34817 - if (cpufreq_us3_driver) {
34818 - cpufreq_unregister_driver(cpufreq_us3_driver);
34819 - kfree(cpufreq_us3_driver);
34820 - cpufreq_us3_driver = NULL;
34821 - kfree(us3_freq_table);
34822 - us3_freq_table = NULL;
34823 - }
34824 + cpufreq_unregister_driver(&cpufreq_us3_driver);
34825 }
34826
34827 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
34828 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34829 index 618e6f4..e89d915 100644
34830 --- a/drivers/cpufreq/speedstep-centrino.c
34831 +++ b/drivers/cpufreq/speedstep-centrino.c
34832 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34833 !cpu_has(cpu, X86_FEATURE_EST))
34834 return -ENODEV;
34835
34836 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34837 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34838 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34839 + pax_open_kernel();
34840 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34841 + pax_close_kernel();
34842 + }
34843
34844 if (policy->cpu != 0)
34845 return -ENODEV;
34846 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34847 index c3a93fe..e808f24 100644
34848 --- a/drivers/cpuidle/cpuidle.c
34849 +++ b/drivers/cpuidle/cpuidle.c
34850 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
34851
34852 static void poll_idle_init(struct cpuidle_driver *drv)
34853 {
34854 - struct cpuidle_state *state = &drv->states[0];
34855 + cpuidle_state_no_const *state = &drv->states[0];
34856
34857 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34858 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34859 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34860 index ea2f8e7..70ac501 100644
34861 --- a/drivers/cpuidle/governor.c
34862 +++ b/drivers/cpuidle/governor.c
34863 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34864 mutex_lock(&cpuidle_lock);
34865 if (__cpuidle_find_governor(gov->name) == NULL) {
34866 ret = 0;
34867 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34868 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34869 if (!cpuidle_curr_governor ||
34870 cpuidle_curr_governor->rating < gov->rating)
34871 cpuidle_switch_governor(gov);
34872 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34873 new_gov = cpuidle_replace_governor(gov->rating);
34874 cpuidle_switch_governor(new_gov);
34875 }
34876 - list_del(&gov->governor_list);
34877 + pax_list_del((struct list_head *)&gov->governor_list);
34878 mutex_unlock(&cpuidle_lock);
34879 }
34880
34881 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34882 index 428754a..8bdf9cc 100644
34883 --- a/drivers/cpuidle/sysfs.c
34884 +++ b/drivers/cpuidle/sysfs.c
34885 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34886 NULL
34887 };
34888
34889 -static struct attribute_group cpuidle_attr_group = {
34890 +static attribute_group_no_const cpuidle_attr_group = {
34891 .attrs = cpuidle_default_attrs,
34892 .name = "cpuidle",
34893 };
34894 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34895 index 3b36797..db0b0c0 100644
34896 --- a/drivers/devfreq/devfreq.c
34897 +++ b/drivers/devfreq/devfreq.c
34898 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
34899 GFP_KERNEL);
34900 devfreq->last_stat_updated = jiffies;
34901
34902 - dev_set_name(&devfreq->dev, dev_name(dev));
34903 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
34904 err = device_register(&devfreq->dev);
34905 if (err) {
34906 put_device(&devfreq->dev);
34907 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34908 goto err_out;
34909 }
34910
34911 - list_add(&governor->node, &devfreq_governor_list);
34912 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34913
34914 list_for_each_entry(devfreq, &devfreq_list, node) {
34915 int ret = 0;
34916 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34917 }
34918 }
34919
34920 - list_del(&governor->node);
34921 + pax_list_del((struct list_head *)&governor->node);
34922 err_out:
34923 mutex_unlock(&devfreq_list_lock);
34924
34925 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34926 index b70709b..1d8d02a 100644
34927 --- a/drivers/dma/sh/shdma.c
34928 +++ b/drivers/dma/sh/shdma.c
34929 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34930 return ret;
34931 }
34932
34933 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34934 +static struct notifier_block sh_dmae_nmi_notifier = {
34935 .notifier_call = sh_dmae_nmi_handler,
34936
34937 /* Run before NMI debug handler and KGDB */
34938 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34939 index c4d700a..0b57abd 100644
34940 --- a/drivers/edac/edac_mc_sysfs.c
34941 +++ b/drivers/edac/edac_mc_sysfs.c
34942 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
34943 struct dev_ch_attribute {
34944 struct device_attribute attr;
34945 int channel;
34946 -};
34947 +} __do_const;
34948
34949 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34950 struct dev_ch_attribute dev_attr_legacy_##_name = \
34951 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34952 }
34953
34954 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34955 + pax_open_kernel();
34956 if (mci->get_sdram_scrub_rate) {
34957 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34958 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34959 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34960 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34961 }
34962 if (mci->set_sdram_scrub_rate) {
34963 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34964 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34965 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34966 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34967 }
34968 + pax_close_kernel();
34969 err = device_create_file(&mci->dev,
34970 &dev_attr_sdram_scrub_rate);
34971 if (err) {
34972 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34973 index e8658e4..22746d6 100644
34974 --- a/drivers/edac/edac_pci_sysfs.c
34975 +++ b/drivers/edac/edac_pci_sysfs.c
34976 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34977 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34978 static int edac_pci_poll_msec = 1000; /* one second workq period */
34979
34980 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34981 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34982 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34983 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34984
34985 static struct kobject *edac_pci_top_main_kobj;
34986 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34987 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34988 void *value;
34989 ssize_t(*show) (void *, char *);
34990 ssize_t(*store) (void *, const char *, size_t);
34991 -};
34992 +} __do_const;
34993
34994 /* Set of show/store abstract level functions for PCI Parity object */
34995 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34996 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34997 edac_printk(KERN_CRIT, EDAC_PCI,
34998 "Signaled System Error on %s\n",
34999 pci_name(dev));
35000 - atomic_inc(&pci_nonparity_count);
35001 + atomic_inc_unchecked(&pci_nonparity_count);
35002 }
35003
35004 if (status & (PCI_STATUS_PARITY)) {
35005 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35006 "Master Data Parity Error on %s\n",
35007 pci_name(dev));
35008
35009 - atomic_inc(&pci_parity_count);
35010 + atomic_inc_unchecked(&pci_parity_count);
35011 }
35012
35013 if (status & (PCI_STATUS_DETECTED_PARITY)) {
35014 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35015 "Detected Parity Error on %s\n",
35016 pci_name(dev));
35017
35018 - atomic_inc(&pci_parity_count);
35019 + atomic_inc_unchecked(&pci_parity_count);
35020 }
35021 }
35022
35023 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35024 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
35025 "Signaled System Error on %s\n",
35026 pci_name(dev));
35027 - atomic_inc(&pci_nonparity_count);
35028 + atomic_inc_unchecked(&pci_nonparity_count);
35029 }
35030
35031 if (status & (PCI_STATUS_PARITY)) {
35032 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35033 "Master Data Parity Error on "
35034 "%s\n", pci_name(dev));
35035
35036 - atomic_inc(&pci_parity_count);
35037 + atomic_inc_unchecked(&pci_parity_count);
35038 }
35039
35040 if (status & (PCI_STATUS_DETECTED_PARITY)) {
35041 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35042 "Detected Parity Error on %s\n",
35043 pci_name(dev));
35044
35045 - atomic_inc(&pci_parity_count);
35046 + atomic_inc_unchecked(&pci_parity_count);
35047 }
35048 }
35049 }
35050 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
35051 if (!check_pci_errors)
35052 return;
35053
35054 - before_count = atomic_read(&pci_parity_count);
35055 + before_count = atomic_read_unchecked(&pci_parity_count);
35056
35057 /* scan all PCI devices looking for a Parity Error on devices and
35058 * bridges.
35059 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
35060 /* Only if operator has selected panic on PCI Error */
35061 if (edac_pci_get_panic_on_pe()) {
35062 /* If the count is different 'after' from 'before' */
35063 - if (before_count != atomic_read(&pci_parity_count))
35064 + if (before_count != atomic_read_unchecked(&pci_parity_count))
35065 panic("EDAC: PCI Parity Error");
35066 }
35067 }
35068 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
35069 index 51b7e3a..aa8a3e8 100644
35070 --- a/drivers/edac/mce_amd.h
35071 +++ b/drivers/edac/mce_amd.h
35072 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
35073 bool (*mc0_mce)(u16, u8);
35074 bool (*mc1_mce)(u16, u8);
35075 bool (*mc2_mce)(u16, u8);
35076 -};
35077 +} __no_const;
35078
35079 void amd_report_gart_errors(bool);
35080 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
35081 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
35082 index 57ea7f4..789e3c3 100644
35083 --- a/drivers/firewire/core-card.c
35084 +++ b/drivers/firewire/core-card.c
35085 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
35086
35087 void fw_core_remove_card(struct fw_card *card)
35088 {
35089 - struct fw_card_driver dummy_driver = dummy_driver_template;
35090 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
35091
35092 card->driver->update_phy_reg(card, 4,
35093 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
35094 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
35095 index 664a6ff..af13580 100644
35096 --- a/drivers/firewire/core-device.c
35097 +++ b/drivers/firewire/core-device.c
35098 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
35099 struct config_rom_attribute {
35100 struct device_attribute attr;
35101 u32 key;
35102 -};
35103 +} __do_const;
35104
35105 static ssize_t show_immediate(struct device *dev,
35106 struct device_attribute *dattr, char *buf)
35107 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35108 index 28a94c7..58da63a 100644
35109 --- a/drivers/firewire/core-transaction.c
35110 +++ b/drivers/firewire/core-transaction.c
35111 @@ -38,6 +38,7 @@
35112 #include <linux/timer.h>
35113 #include <linux/types.h>
35114 #include <linux/workqueue.h>
35115 +#include <linux/sched.h>
35116
35117 #include <asm/byteorder.h>
35118
35119 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35120 index 515a42c..5ecf3ba 100644
35121 --- a/drivers/firewire/core.h
35122 +++ b/drivers/firewire/core.h
35123 @@ -111,6 +111,7 @@ struct fw_card_driver {
35124
35125 int (*stop_iso)(struct fw_iso_context *ctx);
35126 };
35127 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35128
35129 void fw_card_initialize(struct fw_card *card,
35130 const struct fw_card_driver *driver, struct device *device);
35131 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35132 index 94a58a0..f5eba42 100644
35133 --- a/drivers/firmware/dmi-id.c
35134 +++ b/drivers/firmware/dmi-id.c
35135 @@ -16,7 +16,7 @@
35136 struct dmi_device_attribute{
35137 struct device_attribute dev_attr;
35138 int field;
35139 -};
35140 +} __do_const;
35141 #define to_dmi_dev_attr(_dev_attr) \
35142 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35143
35144 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35145 index b95159b..841ae55 100644
35146 --- a/drivers/firmware/dmi_scan.c
35147 +++ b/drivers/firmware/dmi_scan.c
35148 @@ -497,11 +497,6 @@ void __init dmi_scan_machine(void)
35149 }
35150 }
35151 else {
35152 - /*
35153 - * no iounmap() for that ioremap(); it would be a no-op, but
35154 - * it's so early in setup that sucker gets confused into doing
35155 - * what it shouldn't if we actually call it.
35156 - */
35157 p = dmi_ioremap(0xF0000, 0x10000);
35158 if (p == NULL)
35159 goto error;
35160 @@ -786,7 +781,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35161 if (buf == NULL)
35162 return -1;
35163
35164 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35165 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35166
35167 iounmap(buf);
35168 return 0;
35169 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
35170 index 5145fa3..0d3babd 100644
35171 --- a/drivers/firmware/efi/efi.c
35172 +++ b/drivers/firmware/efi/efi.c
35173 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
35174 };
35175
35176 static struct efivars generic_efivars;
35177 -static struct efivar_operations generic_ops;
35178 +static efivar_operations_no_const generic_ops __read_only;
35179
35180 static int generic_ops_register(void)
35181 {
35182 - generic_ops.get_variable = efi.get_variable;
35183 - generic_ops.set_variable = efi.set_variable;
35184 - generic_ops.get_next_variable = efi.get_next_variable;
35185 - generic_ops.query_variable_store = efi_query_variable_store;
35186 + pax_open_kernel();
35187 + *(void **)&generic_ops.get_variable = efi.get_variable;
35188 + *(void **)&generic_ops.set_variable = efi.set_variable;
35189 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
35190 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
35191 + pax_close_kernel();
35192
35193 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
35194 }
35195 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
35196 index 8bd1bb6..c48b0c6 100644
35197 --- a/drivers/firmware/efi/efivars.c
35198 +++ b/drivers/firmware/efi/efivars.c
35199 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
35200 static int
35201 create_efivars_bin_attributes(void)
35202 {
35203 - struct bin_attribute *attr;
35204 + bin_attribute_no_const *attr;
35205 int error;
35206
35207 /* new_var */
35208 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35209 index 2a90ba6..07f3733 100644
35210 --- a/drivers/firmware/google/memconsole.c
35211 +++ b/drivers/firmware/google/memconsole.c
35212 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35213 if (!found_memconsole())
35214 return -ENODEV;
35215
35216 - memconsole_bin_attr.size = memconsole_length;
35217 + pax_open_kernel();
35218 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35219 + pax_close_kernel();
35220
35221 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35222
35223 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35224 index e16d932..f0206ef 100644
35225 --- a/drivers/gpio/gpio-ich.c
35226 +++ b/drivers/gpio/gpio-ich.c
35227 @@ -69,7 +69,7 @@ struct ichx_desc {
35228 /* Some chipsets have quirks, let these use their own request/get */
35229 int (*request)(struct gpio_chip *chip, unsigned offset);
35230 int (*get)(struct gpio_chip *chip, unsigned offset);
35231 -};
35232 +} __do_const;
35233
35234 static struct {
35235 spinlock_t lock;
35236 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35237 index 9902732..64b62dd 100644
35238 --- a/drivers/gpio/gpio-vr41xx.c
35239 +++ b/drivers/gpio/gpio-vr41xx.c
35240 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35241 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35242 maskl, pendl, maskh, pendh);
35243
35244 - atomic_inc(&irq_err_count);
35245 + atomic_inc_unchecked(&irq_err_count);
35246
35247 return -EINVAL;
35248 }
35249 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35250 index ed1334e..ee0dd42 100644
35251 --- a/drivers/gpu/drm/drm_crtc_helper.c
35252 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35253 @@ -321,7 +321,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35254 struct drm_crtc *tmp;
35255 int crtc_mask = 1;
35256
35257 - WARN(!crtc, "checking null crtc?\n");
35258 + BUG_ON(!crtc);
35259
35260 dev = crtc->dev;
35261
35262 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35263 index 9cc247f..36aa285 100644
35264 --- a/drivers/gpu/drm/drm_drv.c
35265 +++ b/drivers/gpu/drm/drm_drv.c
35266 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
35267 /**
35268 * Copy and IOCTL return string to user space
35269 */
35270 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35271 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35272 {
35273 int len;
35274
35275 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
35276 struct drm_file *file_priv = filp->private_data;
35277 struct drm_device *dev;
35278 const struct drm_ioctl_desc *ioctl = NULL;
35279 - drm_ioctl_t *func;
35280 + drm_ioctl_no_const_t func;
35281 unsigned int nr = DRM_IOCTL_NR(cmd);
35282 int retcode = -EINVAL;
35283 char stack_kdata[128];
35284 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
35285 return -ENODEV;
35286
35287 atomic_inc(&dev->ioctl_count);
35288 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35289 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35290 ++file_priv->ioctl_count;
35291
35292 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
35293 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35294 index 429e07d..e681a2c 100644
35295 --- a/drivers/gpu/drm/drm_fops.c
35296 +++ b/drivers/gpu/drm/drm_fops.c
35297 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35298 }
35299
35300 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35301 - atomic_set(&dev->counts[i], 0);
35302 + atomic_set_unchecked(&dev->counts[i], 0);
35303
35304 dev->sigdata.lock = NULL;
35305
35306 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35307 if (drm_device_is_unplugged(dev))
35308 return -ENODEV;
35309
35310 - if (!dev->open_count++)
35311 + if (local_inc_return(&dev->open_count) == 1)
35312 need_setup = 1;
35313 mutex_lock(&dev->struct_mutex);
35314 old_imapping = inode->i_mapping;
35315 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35316 retcode = drm_open_helper(inode, filp, dev);
35317 if (retcode)
35318 goto err_undo;
35319 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35320 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35321 if (need_setup) {
35322 retcode = drm_setup(dev);
35323 if (retcode)
35324 @@ -166,7 +166,7 @@ err_undo:
35325 iput(container_of(dev->dev_mapping, struct inode, i_data));
35326 dev->dev_mapping = old_mapping;
35327 mutex_unlock(&dev->struct_mutex);
35328 - dev->open_count--;
35329 + local_dec(&dev->open_count);
35330 return retcode;
35331 }
35332 EXPORT_SYMBOL(drm_open);
35333 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
35334
35335 mutex_lock(&drm_global_mutex);
35336
35337 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35338 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35339
35340 if (dev->driver->preclose)
35341 dev->driver->preclose(dev, file_priv);
35342 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
35343 * Begin inline drm_release
35344 */
35345
35346 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35347 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35348 task_pid_nr(current),
35349 (long)old_encode_dev(file_priv->minor->device),
35350 - dev->open_count);
35351 + local_read(&dev->open_count));
35352
35353 /* Release any auth tokens that might point to this file_priv,
35354 (do that under the drm_global_mutex) */
35355 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
35356 * End inline drm_release
35357 */
35358
35359 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35360 - if (!--dev->open_count) {
35361 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35362 + if (local_dec_and_test(&dev->open_count)) {
35363 if (atomic_read(&dev->ioctl_count)) {
35364 DRM_ERROR("Device busy: %d\n",
35365 atomic_read(&dev->ioctl_count));
35366 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35367 index f731116..629842c 100644
35368 --- a/drivers/gpu/drm/drm_global.c
35369 +++ b/drivers/gpu/drm/drm_global.c
35370 @@ -36,7 +36,7 @@
35371 struct drm_global_item {
35372 struct mutex mutex;
35373 void *object;
35374 - int refcount;
35375 + atomic_t refcount;
35376 };
35377
35378 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35379 @@ -49,7 +49,7 @@ void drm_global_init(void)
35380 struct drm_global_item *item = &glob[i];
35381 mutex_init(&item->mutex);
35382 item->object = NULL;
35383 - item->refcount = 0;
35384 + atomic_set(&item->refcount, 0);
35385 }
35386 }
35387
35388 @@ -59,7 +59,7 @@ void drm_global_release(void)
35389 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35390 struct drm_global_item *item = &glob[i];
35391 BUG_ON(item->object != NULL);
35392 - BUG_ON(item->refcount != 0);
35393 + BUG_ON(atomic_read(&item->refcount) != 0);
35394 }
35395 }
35396
35397 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35398 void *object;
35399
35400 mutex_lock(&item->mutex);
35401 - if (item->refcount == 0) {
35402 + if (atomic_read(&item->refcount) == 0) {
35403 item->object = kzalloc(ref->size, GFP_KERNEL);
35404 if (unlikely(item->object == NULL)) {
35405 ret = -ENOMEM;
35406 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35407 goto out_err;
35408
35409 }
35410 - ++item->refcount;
35411 + atomic_inc(&item->refcount);
35412 ref->object = item->object;
35413 object = item->object;
35414 mutex_unlock(&item->mutex);
35415 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35416 struct drm_global_item *item = &glob[ref->global_type];
35417
35418 mutex_lock(&item->mutex);
35419 - BUG_ON(item->refcount == 0);
35420 + BUG_ON(atomic_read(&item->refcount) == 0);
35421 BUG_ON(ref->object != item->object);
35422 - if (--item->refcount == 0) {
35423 + if (atomic_dec_and_test(&item->refcount)) {
35424 ref->release(ref);
35425 item->object = NULL;
35426 }
35427 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35428 index d4b20ce..77a8d41 100644
35429 --- a/drivers/gpu/drm/drm_info.c
35430 +++ b/drivers/gpu/drm/drm_info.c
35431 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35432 struct drm_local_map *map;
35433 struct drm_map_list *r_list;
35434
35435 - /* Hardcoded from _DRM_FRAME_BUFFER,
35436 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35437 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35438 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35439 + static const char * const types[] = {
35440 + [_DRM_FRAME_BUFFER] = "FB",
35441 + [_DRM_REGISTERS] = "REG",
35442 + [_DRM_SHM] = "SHM",
35443 + [_DRM_AGP] = "AGP",
35444 + [_DRM_SCATTER_GATHER] = "SG",
35445 + [_DRM_CONSISTENT] = "PCI",
35446 + [_DRM_GEM] = "GEM" };
35447 const char *type;
35448 int i;
35449
35450 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35451 map = r_list->map;
35452 if (!map)
35453 continue;
35454 - if (map->type < 0 || map->type > 5)
35455 + if (map->type >= ARRAY_SIZE(types))
35456 type = "??";
35457 else
35458 type = types[map->type];
35459 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35460 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35461 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35462 vma->vm_flags & VM_IO ? 'i' : '-',
35463 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35464 + 0);
35465 +#else
35466 vma->vm_pgoff);
35467 +#endif
35468
35469 #if defined(__i386__)
35470 pgprot = pgprot_val(vma->vm_page_prot);
35471 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35472 index 2f4c434..dd12cd2 100644
35473 --- a/drivers/gpu/drm/drm_ioc32.c
35474 +++ b/drivers/gpu/drm/drm_ioc32.c
35475 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35476 request = compat_alloc_user_space(nbytes);
35477 if (!access_ok(VERIFY_WRITE, request, nbytes))
35478 return -EFAULT;
35479 - list = (struct drm_buf_desc *) (request + 1);
35480 + list = (struct drm_buf_desc __user *) (request + 1);
35481
35482 if (__put_user(count, &request->count)
35483 || __put_user(list, &request->list))
35484 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35485 request = compat_alloc_user_space(nbytes);
35486 if (!access_ok(VERIFY_WRITE, request, nbytes))
35487 return -EFAULT;
35488 - list = (struct drm_buf_pub *) (request + 1);
35489 + list = (struct drm_buf_pub __user *) (request + 1);
35490
35491 if (__put_user(count, &request->count)
35492 || __put_user(list, &request->list))
35493 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35494 return 0;
35495 }
35496
35497 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35498 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35499 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35500 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35501 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35502 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35503 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35504 {
35505 unsigned int nr = DRM_IOCTL_NR(cmd);
35506 - drm_ioctl_compat_t *fn;
35507 int ret;
35508
35509 /* Assume that ioctls without an explicit compat routine will just
35510 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35511 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35512 return drm_ioctl(filp, cmd, arg);
35513
35514 - fn = drm_compat_ioctls[nr];
35515 -
35516 - if (fn != NULL)
35517 - ret = (*fn) (filp, cmd, arg);
35518 + if (drm_compat_ioctls[nr] != NULL)
35519 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35520 else
35521 ret = drm_ioctl(filp, cmd, arg);
35522
35523 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35524 index e77bd8b..1571b85 100644
35525 --- a/drivers/gpu/drm/drm_ioctl.c
35526 +++ b/drivers/gpu/drm/drm_ioctl.c
35527 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35528 stats->data[i].value =
35529 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35530 else
35531 - stats->data[i].value = atomic_read(&dev->counts[i]);
35532 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35533 stats->data[i].type = dev->types[i];
35534 }
35535
35536 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35537 index d752c96..fe08455 100644
35538 --- a/drivers/gpu/drm/drm_lock.c
35539 +++ b/drivers/gpu/drm/drm_lock.c
35540 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35541 if (drm_lock_take(&master->lock, lock->context)) {
35542 master->lock.file_priv = file_priv;
35543 master->lock.lock_time = jiffies;
35544 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35545 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35546 break; /* Got lock */
35547 }
35548
35549 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35550 return -EINVAL;
35551 }
35552
35553 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35554 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35555
35556 if (drm_lock_free(&master->lock, lock->context)) {
35557 /* FIXME: Should really bail out here. */
35558 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35559 index 16f3ec5..b28f9ca 100644
35560 --- a/drivers/gpu/drm/drm_stub.c
35561 +++ b/drivers/gpu/drm/drm_stub.c
35562 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35563
35564 drm_device_set_unplugged(dev);
35565
35566 - if (dev->open_count == 0) {
35567 + if (local_read(&dev->open_count) == 0) {
35568 drm_put_dev(dev);
35569 }
35570 mutex_unlock(&drm_global_mutex);
35571 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
35572 index 0229665..f61329c 100644
35573 --- a/drivers/gpu/drm/drm_sysfs.c
35574 +++ b/drivers/gpu/drm/drm_sysfs.c
35575 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
35576 int drm_sysfs_device_add(struct drm_minor *minor)
35577 {
35578 int err;
35579 - char *minor_str;
35580 + const char *minor_str;
35581
35582 minor->kdev.parent = minor->dev->dev;
35583
35584 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35585 index 004ecdf..db1f6e0 100644
35586 --- a/drivers/gpu/drm/i810/i810_dma.c
35587 +++ b/drivers/gpu/drm/i810/i810_dma.c
35588 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35589 dma->buflist[vertex->idx],
35590 vertex->discard, vertex->used);
35591
35592 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35593 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35594 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35595 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35596 sarea_priv->last_enqueue = dev_priv->counter - 1;
35597 sarea_priv->last_dispatch = (int)hw_status[5];
35598
35599 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35600 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35601 mc->last_render);
35602
35603 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35604 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35605 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35606 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35607 sarea_priv->last_enqueue = dev_priv->counter - 1;
35608 sarea_priv->last_dispatch = (int)hw_status[5];
35609
35610 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35611 index 6e0acad..93c8289 100644
35612 --- a/drivers/gpu/drm/i810/i810_drv.h
35613 +++ b/drivers/gpu/drm/i810/i810_drv.h
35614 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35615 int page_flipping;
35616
35617 wait_queue_head_t irq_queue;
35618 - atomic_t irq_received;
35619 - atomic_t irq_emitted;
35620 + atomic_unchecked_t irq_received;
35621 + atomic_unchecked_t irq_emitted;
35622
35623 int front_offset;
35624 } drm_i810_private_t;
35625 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35626 index e913d32..4d9b351 100644
35627 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35628 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35629 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35630 I915_READ(GTIMR));
35631 }
35632 seq_printf(m, "Interrupts received: %d\n",
35633 - atomic_read(&dev_priv->irq_received));
35634 + atomic_read_unchecked(&dev_priv->irq_received));
35635 for_each_ring(ring, dev_priv, i) {
35636 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35637 seq_printf(m,
35638 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35639 index 3b315ba..aac280f 100644
35640 --- a/drivers/gpu/drm/i915/i915_dma.c
35641 +++ b/drivers/gpu/drm/i915/i915_dma.c
35642 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35643 bool can_switch;
35644
35645 spin_lock(&dev->count_lock);
35646 - can_switch = (dev->open_count == 0);
35647 + can_switch = (local_read(&dev->open_count) == 0);
35648 spin_unlock(&dev->count_lock);
35649 return can_switch;
35650 }
35651 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35652 index 9669a0b..bb65176 100644
35653 --- a/drivers/gpu/drm/i915/i915_drv.h
35654 +++ b/drivers/gpu/drm/i915/i915_drv.h
35655 @@ -915,7 +915,7 @@ typedef struct drm_i915_private {
35656 drm_dma_handle_t *status_page_dmah;
35657 struct resource mch_res;
35658
35659 - atomic_t irq_received;
35660 + atomic_unchecked_t irq_received;
35661
35662 /* protects the irq masks */
35663 spinlock_t irq_lock;
35664 @@ -1811,7 +1811,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35665 struct drm_i915_private *dev_priv, unsigned port);
35666 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35667 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35668 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35669 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35670 {
35671 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35672 }
35673 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35674 index 117ce38..eefd237 100644
35675 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35676 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35677 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35678
35679 static int
35680 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35681 - int count)
35682 + unsigned int count)
35683 {
35684 - int i;
35685 + unsigned int i;
35686 int relocs_total = 0;
35687 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35688
35689 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35690 index 3c59584..500f2e9 100644
35691 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35692 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35693 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35694 (unsigned long)request);
35695 }
35696
35697 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35698 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35699 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35700 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35701 [DRM_I915_GETPARAM] = compat_i915_getparam,
35702 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35703 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35704 {
35705 unsigned int nr = DRM_IOCTL_NR(cmd);
35706 - drm_ioctl_compat_t *fn = NULL;
35707 int ret;
35708
35709 if (nr < DRM_COMMAND_BASE)
35710 return drm_compat_ioctl(filp, cmd, arg);
35711
35712 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35713 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35714 -
35715 - if (fn != NULL)
35716 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35717 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35718 ret = (*fn) (filp, cmd, arg);
35719 - else
35720 + } else
35721 ret = drm_ioctl(filp, cmd, arg);
35722
35723 return ret;
35724 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35725 index e5e32869..1678f36 100644
35726 --- a/drivers/gpu/drm/i915/i915_irq.c
35727 +++ b/drivers/gpu/drm/i915/i915_irq.c
35728 @@ -670,7 +670,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35729 int pipe;
35730 u32 pipe_stats[I915_MAX_PIPES];
35731
35732 - atomic_inc(&dev_priv->irq_received);
35733 + atomic_inc_unchecked(&dev_priv->irq_received);
35734
35735 while (true) {
35736 iir = I915_READ(VLV_IIR);
35737 @@ -835,7 +835,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35738 irqreturn_t ret = IRQ_NONE;
35739 int i;
35740
35741 - atomic_inc(&dev_priv->irq_received);
35742 + atomic_inc_unchecked(&dev_priv->irq_received);
35743
35744 /* disable master interrupt before clearing iir */
35745 de_ier = I915_READ(DEIER);
35746 @@ -925,7 +925,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35747 int ret = IRQ_NONE;
35748 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35749
35750 - atomic_inc(&dev_priv->irq_received);
35751 + atomic_inc_unchecked(&dev_priv->irq_received);
35752
35753 /* disable master interrupt before clearing iir */
35754 de_ier = I915_READ(DEIER);
35755 @@ -2089,7 +2089,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35756 {
35757 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35758
35759 - atomic_set(&dev_priv->irq_received, 0);
35760 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35761
35762 I915_WRITE(HWSTAM, 0xeffe);
35763
35764 @@ -2124,7 +2124,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35765 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35766 int pipe;
35767
35768 - atomic_set(&dev_priv->irq_received, 0);
35769 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35770
35771 /* VLV magic */
35772 I915_WRITE(VLV_IMR, 0);
35773 @@ -2411,7 +2411,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35774 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35775 int pipe;
35776
35777 - atomic_set(&dev_priv->irq_received, 0);
35778 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35779
35780 for_each_pipe(pipe)
35781 I915_WRITE(PIPESTAT(pipe), 0);
35782 @@ -2490,7 +2490,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35783 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35784 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35785
35786 - atomic_inc(&dev_priv->irq_received);
35787 + atomic_inc_unchecked(&dev_priv->irq_received);
35788
35789 iir = I915_READ16(IIR);
35790 if (iir == 0)
35791 @@ -2565,7 +2565,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35792 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35793 int pipe;
35794
35795 - atomic_set(&dev_priv->irq_received, 0);
35796 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35797
35798 if (I915_HAS_HOTPLUG(dev)) {
35799 I915_WRITE(PORT_HOTPLUG_EN, 0);
35800 @@ -2664,7 +2664,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35801 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35802 int pipe, ret = IRQ_NONE;
35803
35804 - atomic_inc(&dev_priv->irq_received);
35805 + atomic_inc_unchecked(&dev_priv->irq_received);
35806
35807 iir = I915_READ(IIR);
35808 do {
35809 @@ -2791,7 +2791,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35810 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35811 int pipe;
35812
35813 - atomic_set(&dev_priv->irq_received, 0);
35814 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35815
35816 I915_WRITE(PORT_HOTPLUG_EN, 0);
35817 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35818 @@ -2898,7 +2898,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35819 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35820 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35821
35822 - atomic_inc(&dev_priv->irq_received);
35823 + atomic_inc_unchecked(&dev_priv->irq_received);
35824
35825 iir = I915_READ(IIR);
35826
35827 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35828 index 56746dc..b5a214f 100644
35829 --- a/drivers/gpu/drm/i915/intel_display.c
35830 +++ b/drivers/gpu/drm/i915/intel_display.c
35831 @@ -8919,13 +8919,13 @@ struct intel_quirk {
35832 int subsystem_vendor;
35833 int subsystem_device;
35834 void (*hook)(struct drm_device *dev);
35835 -};
35836 +} __do_const;
35837
35838 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35839 struct intel_dmi_quirk {
35840 void (*hook)(struct drm_device *dev);
35841 const struct dmi_system_id (*dmi_id_list)[];
35842 -};
35843 +} __do_const;
35844
35845 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35846 {
35847 @@ -8933,18 +8933,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35848 return 1;
35849 }
35850
35851 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35852 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35853 {
35854 - .dmi_id_list = &(const struct dmi_system_id[]) {
35855 - {
35856 - .callback = intel_dmi_reverse_brightness,
35857 - .ident = "NCR Corporation",
35858 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35859 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35860 - },
35861 - },
35862 - { } /* terminating entry */
35863 + .callback = intel_dmi_reverse_brightness,
35864 + .ident = "NCR Corporation",
35865 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35866 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35867 },
35868 + },
35869 + { } /* terminating entry */
35870 +};
35871 +
35872 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35873 + {
35874 + .dmi_id_list = &intel_dmi_quirks_table,
35875 .hook = quirk_invert_brightness,
35876 },
35877 };
35878 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35879 index 54558a0..2d97005 100644
35880 --- a/drivers/gpu/drm/mga/mga_drv.h
35881 +++ b/drivers/gpu/drm/mga/mga_drv.h
35882 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35883 u32 clear_cmd;
35884 u32 maccess;
35885
35886 - atomic_t vbl_received; /**< Number of vblanks received. */
35887 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35888 wait_queue_head_t fence_queue;
35889 - atomic_t last_fence_retired;
35890 + atomic_unchecked_t last_fence_retired;
35891 u32 next_fence_to_post;
35892
35893 unsigned int fb_cpp;
35894 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35895 index 709e90d..89a1c0d 100644
35896 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35897 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35898 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35899 return 0;
35900 }
35901
35902 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35903 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35904 [DRM_MGA_INIT] = compat_mga_init,
35905 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35906 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35907 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35908 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35909 {
35910 unsigned int nr = DRM_IOCTL_NR(cmd);
35911 - drm_ioctl_compat_t *fn = NULL;
35912 int ret;
35913
35914 if (nr < DRM_COMMAND_BASE)
35915 return drm_compat_ioctl(filp, cmd, arg);
35916
35917 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35918 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35919 -
35920 - if (fn != NULL)
35921 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35922 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35923 ret = (*fn) (filp, cmd, arg);
35924 - else
35925 + } else
35926 ret = drm_ioctl(filp, cmd, arg);
35927
35928 return ret;
35929 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35930 index 598c281..60d590e 100644
35931 --- a/drivers/gpu/drm/mga/mga_irq.c
35932 +++ b/drivers/gpu/drm/mga/mga_irq.c
35933 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35934 if (crtc != 0)
35935 return 0;
35936
35937 - return atomic_read(&dev_priv->vbl_received);
35938 + return atomic_read_unchecked(&dev_priv->vbl_received);
35939 }
35940
35941
35942 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35943 /* VBLANK interrupt */
35944 if (status & MGA_VLINEPEN) {
35945 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35946 - atomic_inc(&dev_priv->vbl_received);
35947 + atomic_inc_unchecked(&dev_priv->vbl_received);
35948 drm_handle_vblank(dev, 0);
35949 handled = 1;
35950 }
35951 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35952 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35953 MGA_WRITE(MGA_PRIMEND, prim_end);
35954
35955 - atomic_inc(&dev_priv->last_fence_retired);
35956 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35957 DRM_WAKEUP(&dev_priv->fence_queue);
35958 handled = 1;
35959 }
35960 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35961 * using fences.
35962 */
35963 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35964 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35965 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35966 - *sequence) <= (1 << 23)));
35967
35968 *sequence = cur_fence;
35969 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35970 index 6aa2137..fe8dc55 100644
35971 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35972 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35973 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35974 struct bit_table {
35975 const char id;
35976 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35977 -};
35978 +} __no_const;
35979
35980 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35981
35982 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35983 index f2b30f8..d0f9a95 100644
35984 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35985 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35986 @@ -92,7 +92,7 @@ struct nouveau_drm {
35987 struct drm_global_reference mem_global_ref;
35988 struct ttm_bo_global_ref bo_global_ref;
35989 struct ttm_bo_device bdev;
35990 - atomic_t validate_sequence;
35991 + atomic_unchecked_t validate_sequence;
35992 int (*move)(struct nouveau_channel *,
35993 struct ttm_buffer_object *,
35994 struct ttm_mem_reg *, struct ttm_mem_reg *);
35995 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35996 index b4b4d0c..b7edc15 100644
35997 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35998 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35999 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
36000 int ret, i;
36001 struct nouveau_bo *res_bo = NULL;
36002
36003 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
36004 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
36005 retry:
36006 if (++trycnt > 100000) {
36007 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
36008 @@ -359,7 +359,7 @@ retry:
36009 if (ret) {
36010 validate_fini(op, NULL);
36011 if (unlikely(ret == -EAGAIN)) {
36012 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
36013 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
36014 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
36015 sequence);
36016 if (!ret)
36017 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36018 index 08214bc..9208577 100644
36019 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36020 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36021 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
36022 unsigned long arg)
36023 {
36024 unsigned int nr = DRM_IOCTL_NR(cmd);
36025 - drm_ioctl_compat_t *fn = NULL;
36026 + drm_ioctl_compat_t fn = NULL;
36027 int ret;
36028
36029 if (nr < DRM_COMMAND_BASE)
36030 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
36031 index 25d3495..d81aaf6 100644
36032 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
36033 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
36034 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
36035 bool can_switch;
36036
36037 spin_lock(&dev->count_lock);
36038 - can_switch = (dev->open_count == 0);
36039 + can_switch = (local_read(&dev->open_count) == 0);
36040 spin_unlock(&dev->count_lock);
36041 return can_switch;
36042 }
36043 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
36044 index 489cb8c..0b8d0d3 100644
36045 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
36046 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
36047 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
36048 }
36049 }
36050
36051 -static struct vm_operations_struct qxl_ttm_vm_ops;
36052 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
36053 static const struct vm_operations_struct *ttm_vm_ops;
36054
36055 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36056 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
36057 return r;
36058 if (unlikely(ttm_vm_ops == NULL)) {
36059 ttm_vm_ops = vma->vm_ops;
36060 + pax_open_kernel();
36061 qxl_ttm_vm_ops = *ttm_vm_ops;
36062 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
36063 + pax_close_kernel();
36064 }
36065 vma->vm_ops = &qxl_ttm_vm_ops;
36066 return 0;
36067 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
36068 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
36069 {
36070 #if defined(CONFIG_DEBUG_FS)
36071 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
36072 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
36073 - unsigned i;
36074 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
36075 + {
36076 + .name = "qxl_mem_mm",
36077 + .show = &qxl_mm_dump_table,
36078 + },
36079 + {
36080 + .name = "qxl_surf_mm",
36081 + .show = &qxl_mm_dump_table,
36082 + }
36083 + };
36084
36085 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
36086 - if (i == 0)
36087 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
36088 - else
36089 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
36090 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
36091 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
36092 - qxl_mem_types_list[i].driver_features = 0;
36093 - if (i == 0)
36094 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36095 - else
36096 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36097 + pax_open_kernel();
36098 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36099 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36100 + pax_close_kernel();
36101
36102 - }
36103 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
36104 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
36105 #else
36106 return 0;
36107 #endif
36108 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
36109 index d4660cf..70dbe65 100644
36110 --- a/drivers/gpu/drm/r128/r128_cce.c
36111 +++ b/drivers/gpu/drm/r128/r128_cce.c
36112 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
36113
36114 /* GH: Simple idle check.
36115 */
36116 - atomic_set(&dev_priv->idle_count, 0);
36117 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36118
36119 /* We don't support anything other than bus-mastering ring mode,
36120 * but the ring can be in either AGP or PCI space for the ring
36121 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
36122 index 930c71b..499aded 100644
36123 --- a/drivers/gpu/drm/r128/r128_drv.h
36124 +++ b/drivers/gpu/drm/r128/r128_drv.h
36125 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
36126 int is_pci;
36127 unsigned long cce_buffers_offset;
36128
36129 - atomic_t idle_count;
36130 + atomic_unchecked_t idle_count;
36131
36132 int page_flipping;
36133 int current_page;
36134 u32 crtc_offset;
36135 u32 crtc_offset_cntl;
36136
36137 - atomic_t vbl_received;
36138 + atomic_unchecked_t vbl_received;
36139
36140 u32 color_fmt;
36141 unsigned int front_offset;
36142 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36143 index a954c54..9cc595c 100644
36144 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36145 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36146 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36147 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36148 }
36149
36150 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36151 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36152 [DRM_R128_INIT] = compat_r128_init,
36153 [DRM_R128_DEPTH] = compat_r128_depth,
36154 [DRM_R128_STIPPLE] = compat_r128_stipple,
36155 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36156 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36157 {
36158 unsigned int nr = DRM_IOCTL_NR(cmd);
36159 - drm_ioctl_compat_t *fn = NULL;
36160 int ret;
36161
36162 if (nr < DRM_COMMAND_BASE)
36163 return drm_compat_ioctl(filp, cmd, arg);
36164
36165 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36166 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36167 -
36168 - if (fn != NULL)
36169 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36170 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36171 ret = (*fn) (filp, cmd, arg);
36172 - else
36173 + } else
36174 ret = drm_ioctl(filp, cmd, arg);
36175
36176 return ret;
36177 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36178 index 2ea4f09..d391371 100644
36179 --- a/drivers/gpu/drm/r128/r128_irq.c
36180 +++ b/drivers/gpu/drm/r128/r128_irq.c
36181 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36182 if (crtc != 0)
36183 return 0;
36184
36185 - return atomic_read(&dev_priv->vbl_received);
36186 + return atomic_read_unchecked(&dev_priv->vbl_received);
36187 }
36188
36189 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36190 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36191 /* VBLANK interrupt */
36192 if (status & R128_CRTC_VBLANK_INT) {
36193 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36194 - atomic_inc(&dev_priv->vbl_received);
36195 + atomic_inc_unchecked(&dev_priv->vbl_received);
36196 drm_handle_vblank(dev, 0);
36197 return IRQ_HANDLED;
36198 }
36199 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36200 index 19bb7e6..de7e2a2 100644
36201 --- a/drivers/gpu/drm/r128/r128_state.c
36202 +++ b/drivers/gpu/drm/r128/r128_state.c
36203 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36204
36205 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36206 {
36207 - if (atomic_read(&dev_priv->idle_count) == 0)
36208 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36209 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36210 else
36211 - atomic_set(&dev_priv->idle_count, 0);
36212 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36213 }
36214
36215 #endif
36216 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36217 index 5a82b6b..9e69c73 100644
36218 --- a/drivers/gpu/drm/radeon/mkregtable.c
36219 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36220 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36221 regex_t mask_rex;
36222 regmatch_t match[4];
36223 char buf[1024];
36224 - size_t end;
36225 + long end;
36226 int len;
36227 int done = 0;
36228 int r;
36229 unsigned o;
36230 struct offset *offset;
36231 char last_reg_s[10];
36232 - int last_reg;
36233 + unsigned long last_reg;
36234
36235 if (regcomp
36236 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36237 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36238 index b0dc0b6..a9bfe9c 100644
36239 --- a/drivers/gpu/drm/radeon/radeon_device.c
36240 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36241 @@ -1014,7 +1014,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36242 bool can_switch;
36243
36244 spin_lock(&dev->count_lock);
36245 - can_switch = (dev->open_count == 0);
36246 + can_switch = (local_read(&dev->open_count) == 0);
36247 spin_unlock(&dev->count_lock);
36248 return can_switch;
36249 }
36250 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36251 index b369d42..8dd04eb 100644
36252 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36253 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36254 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
36255
36256 /* SW interrupt */
36257 wait_queue_head_t swi_queue;
36258 - atomic_t swi_emitted;
36259 + atomic_unchecked_t swi_emitted;
36260 int vblank_crtc;
36261 uint32_t irq_enable_reg;
36262 uint32_t r500_disp_irq_reg;
36263 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36264 index c180df8..5fd8186 100644
36265 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36266 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36267 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36268 request = compat_alloc_user_space(sizeof(*request));
36269 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36270 || __put_user(req32.param, &request->param)
36271 - || __put_user((void __user *)(unsigned long)req32.value,
36272 + || __put_user((unsigned long)req32.value,
36273 &request->value))
36274 return -EFAULT;
36275
36276 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36277 #define compat_radeon_cp_setparam NULL
36278 #endif /* X86_64 || IA64 */
36279
36280 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36281 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36282 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36283 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36284 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36285 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36286 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36287 {
36288 unsigned int nr = DRM_IOCTL_NR(cmd);
36289 - drm_ioctl_compat_t *fn = NULL;
36290 int ret;
36291
36292 if (nr < DRM_COMMAND_BASE)
36293 return drm_compat_ioctl(filp, cmd, arg);
36294
36295 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36296 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36297 -
36298 - if (fn != NULL)
36299 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36300 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36301 ret = (*fn) (filp, cmd, arg);
36302 - else
36303 + } else
36304 ret = drm_ioctl(filp, cmd, arg);
36305
36306 return ret;
36307 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36308 index 8d68e97..9dcfed8 100644
36309 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36310 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36311 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36312 unsigned int ret;
36313 RING_LOCALS;
36314
36315 - atomic_inc(&dev_priv->swi_emitted);
36316 - ret = atomic_read(&dev_priv->swi_emitted);
36317 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36318 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36319
36320 BEGIN_RING(4);
36321 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36322 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36323 drm_radeon_private_t *dev_priv =
36324 (drm_radeon_private_t *) dev->dev_private;
36325
36326 - atomic_set(&dev_priv->swi_emitted, 0);
36327 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36328 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36329
36330 dev->max_vblank_count = 0x001fffff;
36331 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36332 index 4d20910..6726b6d 100644
36333 --- a/drivers/gpu/drm/radeon/radeon_state.c
36334 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36335 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36336 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36337 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36338
36339 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36340 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36341 sarea_priv->nbox * sizeof(depth_boxes[0])))
36342 return -EFAULT;
36343
36344 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36345 {
36346 drm_radeon_private_t *dev_priv = dev->dev_private;
36347 drm_radeon_getparam_t *param = data;
36348 - int value;
36349 + int value = 0;
36350
36351 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36352
36353 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36354 index 6c0ce89..57a2529 100644
36355 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36356 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36357 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36358 man->size = size >> PAGE_SHIFT;
36359 }
36360
36361 -static struct vm_operations_struct radeon_ttm_vm_ops;
36362 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36363 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36364
36365 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36366 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36367 }
36368 if (unlikely(ttm_vm_ops == NULL)) {
36369 ttm_vm_ops = vma->vm_ops;
36370 + pax_open_kernel();
36371 radeon_ttm_vm_ops = *ttm_vm_ops;
36372 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36373 + pax_close_kernel();
36374 }
36375 vma->vm_ops = &radeon_ttm_vm_ops;
36376 return 0;
36377 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
36378 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36379 {
36380 #if defined(CONFIG_DEBUG_FS)
36381 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
36382 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
36383 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
36384 + {
36385 + .name = "radeon_vram_mm",
36386 + .show = &radeon_mm_dump_table,
36387 + },
36388 + {
36389 + .name = "radeon_gtt_mm",
36390 + .show = &radeon_mm_dump_table,
36391 + },
36392 + {
36393 + .name = "ttm_page_pool",
36394 + .show = &ttm_page_alloc_debugfs,
36395 + },
36396 + {
36397 + .name = "ttm_dma_page_pool",
36398 + .show = &ttm_dma_page_alloc_debugfs,
36399 + },
36400 + };
36401 unsigned i;
36402
36403 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
36404 - if (i == 0)
36405 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36406 - else
36407 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36408 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36409 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36410 - radeon_mem_types_list[i].driver_features = 0;
36411 - if (i == 0)
36412 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36413 - else
36414 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36415 -
36416 - }
36417 - /* Add ttm page pool to debugfs */
36418 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36419 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36420 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36421 - radeon_mem_types_list[i].driver_features = 0;
36422 - radeon_mem_types_list[i++].data = NULL;
36423 + pax_open_kernel();
36424 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36425 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36426 + pax_close_kernel();
36427 #ifdef CONFIG_SWIOTLB
36428 - if (swiotlb_nr_tbl()) {
36429 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36430 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36431 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36432 - radeon_mem_types_list[i].driver_features = 0;
36433 - radeon_mem_types_list[i++].data = NULL;
36434 - }
36435 + if (swiotlb_nr_tbl())
36436 + i++;
36437 #endif
36438 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36439
36440 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36441 index 55880d5..9e95342 100644
36442 --- a/drivers/gpu/drm/radeon/rs690.c
36443 +++ b/drivers/gpu/drm/radeon/rs690.c
36444 @@ -327,9 +327,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36445 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36446 rdev->pm.sideport_bandwidth.full)
36447 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36448 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36449 + read_delay_latency.full = dfixed_const(800 * 1000);
36450 read_delay_latency.full = dfixed_div(read_delay_latency,
36451 rdev->pm.igp_sideport_mclk);
36452 + a.full = dfixed_const(370);
36453 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36454 } else {
36455 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36456 rdev->pm.k8_bandwidth.full)
36457 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
36458 index dbc2def..0a9f710 100644
36459 --- a/drivers/gpu/drm/ttm/ttm_memory.c
36460 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
36461 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
36462 zone->glob = glob;
36463 glob->zone_kernel = zone;
36464 ret = kobject_init_and_add(
36465 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36466 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36467 if (unlikely(ret != 0)) {
36468 kobject_put(&zone->kobj);
36469 return ret;
36470 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
36471 zone->glob = glob;
36472 glob->zone_dma32 = zone;
36473 ret = kobject_init_and_add(
36474 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36475 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36476 if (unlikely(ret != 0)) {
36477 kobject_put(&zone->kobj);
36478 return ret;
36479 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36480 index bd2a3b4..122d9ad 100644
36481 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36482 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36483 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36484 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36485 struct shrink_control *sc)
36486 {
36487 - static atomic_t start_pool = ATOMIC_INIT(0);
36488 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36489 unsigned i;
36490 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36491 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36492 struct ttm_page_pool *pool;
36493 int shrink_pages = sc->nr_to_scan;
36494
36495 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36496 index dc0c065..58a0782 100644
36497 --- a/drivers/gpu/drm/udl/udl_fb.c
36498 +++ b/drivers/gpu/drm/udl/udl_fb.c
36499 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36500 fb_deferred_io_cleanup(info);
36501 kfree(info->fbdefio);
36502 info->fbdefio = NULL;
36503 - info->fbops->fb_mmap = udl_fb_mmap;
36504 }
36505
36506 pr_warn("released /dev/fb%d user=%d count=%d\n",
36507 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36508 index 893a650..6190d3b 100644
36509 --- a/drivers/gpu/drm/via/via_drv.h
36510 +++ b/drivers/gpu/drm/via/via_drv.h
36511 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36512 typedef uint32_t maskarray_t[5];
36513
36514 typedef struct drm_via_irq {
36515 - atomic_t irq_received;
36516 + atomic_unchecked_t irq_received;
36517 uint32_t pending_mask;
36518 uint32_t enable_mask;
36519 wait_queue_head_t irq_queue;
36520 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36521 struct timeval last_vblank;
36522 int last_vblank_valid;
36523 unsigned usec_per_vblank;
36524 - atomic_t vbl_received;
36525 + atomic_unchecked_t vbl_received;
36526 drm_via_state_t hc_state;
36527 char pci_buf[VIA_PCI_BUF_SIZE];
36528 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36529 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36530 index ac98964..5dbf512 100644
36531 --- a/drivers/gpu/drm/via/via_irq.c
36532 +++ b/drivers/gpu/drm/via/via_irq.c
36533 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36534 if (crtc != 0)
36535 return 0;
36536
36537 - return atomic_read(&dev_priv->vbl_received);
36538 + return atomic_read_unchecked(&dev_priv->vbl_received);
36539 }
36540
36541 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36542 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36543
36544 status = VIA_READ(VIA_REG_INTERRUPT);
36545 if (status & VIA_IRQ_VBLANK_PENDING) {
36546 - atomic_inc(&dev_priv->vbl_received);
36547 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36548 + atomic_inc_unchecked(&dev_priv->vbl_received);
36549 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36550 do_gettimeofday(&cur_vblank);
36551 if (dev_priv->last_vblank_valid) {
36552 dev_priv->usec_per_vblank =
36553 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36554 dev_priv->last_vblank = cur_vblank;
36555 dev_priv->last_vblank_valid = 1;
36556 }
36557 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36558 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36559 DRM_DEBUG("US per vblank is: %u\n",
36560 dev_priv->usec_per_vblank);
36561 }
36562 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36563
36564 for (i = 0; i < dev_priv->num_irqs; ++i) {
36565 if (status & cur_irq->pending_mask) {
36566 - atomic_inc(&cur_irq->irq_received);
36567 + atomic_inc_unchecked(&cur_irq->irq_received);
36568 DRM_WAKEUP(&cur_irq->irq_queue);
36569 handled = 1;
36570 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36571 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36572 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36573 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36574 masks[irq][4]));
36575 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36576 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36577 } else {
36578 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36579 (((cur_irq_sequence =
36580 - atomic_read(&cur_irq->irq_received)) -
36581 + atomic_read_unchecked(&cur_irq->irq_received)) -
36582 *sequence) <= (1 << 23)));
36583 }
36584 *sequence = cur_irq_sequence;
36585 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36586 }
36587
36588 for (i = 0; i < dev_priv->num_irqs; ++i) {
36589 - atomic_set(&cur_irq->irq_received, 0);
36590 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36591 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36592 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36593 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36594 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36595 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36596 case VIA_IRQ_RELATIVE:
36597 irqwait->request.sequence +=
36598 - atomic_read(&cur_irq->irq_received);
36599 + atomic_read_unchecked(&cur_irq->irq_received);
36600 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36601 case VIA_IRQ_ABSOLUTE:
36602 break;
36603 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36604 index 13aeda7..4a952d1 100644
36605 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36606 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36607 @@ -290,7 +290,7 @@ struct vmw_private {
36608 * Fencing and IRQs.
36609 */
36610
36611 - atomic_t marker_seq;
36612 + atomic_unchecked_t marker_seq;
36613 wait_queue_head_t fence_queue;
36614 wait_queue_head_t fifo_queue;
36615 int fence_queue_waiters; /* Protected by hw_mutex */
36616 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36617 index 3eb1486..0a47ee9 100644
36618 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36619 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36620 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36621 (unsigned int) min,
36622 (unsigned int) fifo->capabilities);
36623
36624 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36625 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36626 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36627 vmw_marker_queue_init(&fifo->marker_queue);
36628 return vmw_fifo_send_fence(dev_priv, &dummy);
36629 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36630 if (reserveable)
36631 iowrite32(bytes, fifo_mem +
36632 SVGA_FIFO_RESERVED);
36633 - return fifo_mem + (next_cmd >> 2);
36634 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36635 } else {
36636 need_bounce = true;
36637 }
36638 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36639
36640 fm = vmw_fifo_reserve(dev_priv, bytes);
36641 if (unlikely(fm == NULL)) {
36642 - *seqno = atomic_read(&dev_priv->marker_seq);
36643 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36644 ret = -ENOMEM;
36645 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36646 false, 3*HZ);
36647 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36648 }
36649
36650 do {
36651 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36652 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36653 } while (*seqno == 0);
36654
36655 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36656 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36657 index c509d40..3b640c3 100644
36658 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36659 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36660 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36661 int ret;
36662
36663 num_clips = arg->num_clips;
36664 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36665 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36666
36667 if (unlikely(num_clips == 0))
36668 return 0;
36669 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36670 int ret;
36671
36672 num_clips = arg->num_clips;
36673 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36674 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36675
36676 if (unlikely(num_clips == 0))
36677 return 0;
36678 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36679 index 4640adb..e1384ed 100644
36680 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36681 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36682 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36683 * emitted. Then the fence is stale and signaled.
36684 */
36685
36686 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36687 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36688 > VMW_FENCE_WRAP);
36689
36690 return ret;
36691 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36692
36693 if (fifo_idle)
36694 down_read(&fifo_state->rwsem);
36695 - signal_seq = atomic_read(&dev_priv->marker_seq);
36696 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36697 ret = 0;
36698
36699 for (;;) {
36700 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36701 index 8a8725c2..afed796 100644
36702 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36703 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36704 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36705 while (!vmw_lag_lt(queue, us)) {
36706 spin_lock(&queue->lock);
36707 if (list_empty(&queue->head))
36708 - seqno = atomic_read(&dev_priv->marker_seq);
36709 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36710 else {
36711 marker = list_first_entry(&queue->head,
36712 struct vmw_marker, head);
36713 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
36714 index 8c04943..4370ed9 100644
36715 --- a/drivers/gpu/host1x/drm/dc.c
36716 +++ b/drivers/gpu/host1x/drm/dc.c
36717 @@ -999,7 +999,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
36718 }
36719
36720 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
36721 - dc->debugfs_files[i].data = dc;
36722 + *(void **)&dc->debugfs_files[i].data = dc;
36723
36724 err = drm_debugfs_create_files(dc->debugfs_files,
36725 ARRAY_SIZE(debugfs_files),
36726 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36727 index 402f486..f862d7e 100644
36728 --- a/drivers/hid/hid-core.c
36729 +++ b/drivers/hid/hid-core.c
36730 @@ -2275,7 +2275,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36731
36732 int hid_add_device(struct hid_device *hdev)
36733 {
36734 - static atomic_t id = ATOMIC_INIT(0);
36735 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36736 int ret;
36737
36738 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36739 @@ -2309,7 +2309,7 @@ int hid_add_device(struct hid_device *hdev)
36740 /* XXX hack, any other cleaner solution after the driver core
36741 * is converted to allow more than 20 bytes as the device name? */
36742 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36743 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36744 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36745
36746 hid_debug_register(hdev, dev_name(&hdev->dev));
36747 ret = device_add(&hdev->dev);
36748 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36749 index 90124ff..3761764 100644
36750 --- a/drivers/hid/hid-wiimote-debug.c
36751 +++ b/drivers/hid/hid-wiimote-debug.c
36752 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36753 else if (size == 0)
36754 return -EIO;
36755
36756 - if (copy_to_user(u, buf, size))
36757 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36758 return -EFAULT;
36759
36760 *off += size;
36761 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36762 index 0b122f8..b1d8160 100644
36763 --- a/drivers/hv/channel.c
36764 +++ b/drivers/hv/channel.c
36765 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36766 int ret = 0;
36767 int t;
36768
36769 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36770 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36771 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36772 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36773
36774 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36775 if (ret)
36776 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36777 index ae49237..380d4c9 100644
36778 --- a/drivers/hv/hv.c
36779 +++ b/drivers/hv/hv.c
36780 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36781 u64 output_address = (output) ? virt_to_phys(output) : 0;
36782 u32 output_address_hi = output_address >> 32;
36783 u32 output_address_lo = output_address & 0xFFFFFFFF;
36784 - void *hypercall_page = hv_context.hypercall_page;
36785 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36786
36787 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36788 "=a"(hv_status_lo) : "d" (control_hi),
36789 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36790 index 12f2f9e..679603c 100644
36791 --- a/drivers/hv/hyperv_vmbus.h
36792 +++ b/drivers/hv/hyperv_vmbus.h
36793 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36794 struct vmbus_connection {
36795 enum vmbus_connect_state conn_state;
36796
36797 - atomic_t next_gpadl_handle;
36798 + atomic_unchecked_t next_gpadl_handle;
36799
36800 /*
36801 * Represents channel interrupts. Each bit position represents a
36802 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36803 index 4004e54..c2de226 100644
36804 --- a/drivers/hv/vmbus_drv.c
36805 +++ b/drivers/hv/vmbus_drv.c
36806 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36807 {
36808 int ret = 0;
36809
36810 - static atomic_t device_num = ATOMIC_INIT(0);
36811 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36812
36813 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36814 - atomic_inc_return(&device_num));
36815 + atomic_inc_return_unchecked(&device_num));
36816
36817 child_device_obj->device.bus = &hv_bus;
36818 child_device_obj->device.parent = &hv_acpi_dev->dev;
36819 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36820 index 6351aba..dc4aaf4 100644
36821 --- a/drivers/hwmon/acpi_power_meter.c
36822 +++ b/drivers/hwmon/acpi_power_meter.c
36823 @@ -117,7 +117,7 @@ struct sensor_template {
36824 struct device_attribute *devattr,
36825 const char *buf, size_t count);
36826 int index;
36827 -};
36828 +} __do_const;
36829
36830 /* Averaging interval */
36831 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36832 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36833 struct sensor_template *attrs)
36834 {
36835 struct device *dev = &resource->acpi_dev->dev;
36836 - struct sensor_device_attribute *sensors =
36837 + sensor_device_attribute_no_const *sensors =
36838 &resource->sensors[resource->num_sensors];
36839 int res = 0;
36840
36841 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36842 index 62c2e32..8f2859a 100644
36843 --- a/drivers/hwmon/applesmc.c
36844 +++ b/drivers/hwmon/applesmc.c
36845 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36846 {
36847 struct applesmc_node_group *grp;
36848 struct applesmc_dev_attr *node;
36849 - struct attribute *attr;
36850 + attribute_no_const *attr;
36851 int ret, i;
36852
36853 for (grp = groups; grp->format; grp++) {
36854 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36855 index b25c643..a13460d 100644
36856 --- a/drivers/hwmon/asus_atk0110.c
36857 +++ b/drivers/hwmon/asus_atk0110.c
36858 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36859 struct atk_sensor_data {
36860 struct list_head list;
36861 struct atk_data *data;
36862 - struct device_attribute label_attr;
36863 - struct device_attribute input_attr;
36864 - struct device_attribute limit1_attr;
36865 - struct device_attribute limit2_attr;
36866 + device_attribute_no_const label_attr;
36867 + device_attribute_no_const input_attr;
36868 + device_attribute_no_const limit1_attr;
36869 + device_attribute_no_const limit2_attr;
36870 char label_attr_name[ATTR_NAME_SIZE];
36871 char input_attr_name[ATTR_NAME_SIZE];
36872 char limit1_attr_name[ATTR_NAME_SIZE];
36873 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36874 static struct device_attribute atk_name_attr =
36875 __ATTR(name, 0444, atk_name_show, NULL);
36876
36877 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36878 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36879 sysfs_show_func show)
36880 {
36881 sysfs_attr_init(&attr->attr);
36882 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36883 index 658ce3a..0d0c2f3 100644
36884 --- a/drivers/hwmon/coretemp.c
36885 +++ b/drivers/hwmon/coretemp.c
36886 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36887 return NOTIFY_OK;
36888 }
36889
36890 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36891 +static struct notifier_block coretemp_cpu_notifier = {
36892 .notifier_call = coretemp_cpu_callback,
36893 };
36894
36895 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36896 index 1429f6e..ee03d59 100644
36897 --- a/drivers/hwmon/ibmaem.c
36898 +++ b/drivers/hwmon/ibmaem.c
36899 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
36900 struct aem_rw_sensor_template *rw)
36901 {
36902 struct device *dev = &data->pdev->dev;
36903 - struct sensor_device_attribute *sensors = data->sensors;
36904 + sensor_device_attribute_no_const *sensors = data->sensors;
36905 int err;
36906
36907 /* Set up read-only sensors */
36908 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
36909 index 52b77af..aed1ddf 100644
36910 --- a/drivers/hwmon/iio_hwmon.c
36911 +++ b/drivers/hwmon/iio_hwmon.c
36912 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
36913 {
36914 struct device *dev = &pdev->dev;
36915 struct iio_hwmon_state *st;
36916 - struct sensor_device_attribute *a;
36917 + sensor_device_attribute_no_const *a;
36918 int ret, i;
36919 int in_i = 1, temp_i = 1, curr_i = 1;
36920 enum iio_chan_type type;
36921 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36922 index 9add6092..ee7ba3f 100644
36923 --- a/drivers/hwmon/pmbus/pmbus_core.c
36924 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36925 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36926 return 0;
36927 }
36928
36929 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36930 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36931 const char *name,
36932 umode_t mode,
36933 ssize_t (*show)(struct device *dev,
36934 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36935 dev_attr->store = store;
36936 }
36937
36938 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36939 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36940 const char *name,
36941 umode_t mode,
36942 ssize_t (*show)(struct device *dev,
36943 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36944 u16 reg, u8 mask)
36945 {
36946 struct pmbus_boolean *boolean;
36947 - struct sensor_device_attribute *a;
36948 + sensor_device_attribute_no_const *a;
36949
36950 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36951 if (!boolean)
36952 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36953 bool update, bool readonly)
36954 {
36955 struct pmbus_sensor *sensor;
36956 - struct device_attribute *a;
36957 + device_attribute_no_const *a;
36958
36959 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36960 if (!sensor)
36961 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36962 const char *lstring, int index)
36963 {
36964 struct pmbus_label *label;
36965 - struct device_attribute *a;
36966 + device_attribute_no_const *a;
36967
36968 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36969 if (!label)
36970 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36971 index 2507f90..1645765 100644
36972 --- a/drivers/hwmon/sht15.c
36973 +++ b/drivers/hwmon/sht15.c
36974 @@ -169,7 +169,7 @@ struct sht15_data {
36975 int supply_uv;
36976 bool supply_uv_valid;
36977 struct work_struct update_supply_work;
36978 - atomic_t interrupt_handled;
36979 + atomic_unchecked_t interrupt_handled;
36980 };
36981
36982 /**
36983 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36984 ret = gpio_direction_input(data->pdata->gpio_data);
36985 if (ret)
36986 return ret;
36987 - atomic_set(&data->interrupt_handled, 0);
36988 + atomic_set_unchecked(&data->interrupt_handled, 0);
36989
36990 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36991 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36992 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36993 /* Only relevant if the interrupt hasn't occurred. */
36994 - if (!atomic_read(&data->interrupt_handled))
36995 + if (!atomic_read_unchecked(&data->interrupt_handled))
36996 schedule_work(&data->read_work);
36997 }
36998 ret = wait_event_timeout(data->wait_queue,
36999 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
37000
37001 /* First disable the interrupt */
37002 disable_irq_nosync(irq);
37003 - atomic_inc(&data->interrupt_handled);
37004 + atomic_inc_unchecked(&data->interrupt_handled);
37005 /* Then schedule a reading work struct */
37006 if (data->state != SHT15_READING_NOTHING)
37007 schedule_work(&data->read_work);
37008 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
37009 * If not, then start the interrupt again - care here as could
37010 * have gone low in meantime so verify it hasn't!
37011 */
37012 - atomic_set(&data->interrupt_handled, 0);
37013 + atomic_set_unchecked(&data->interrupt_handled, 0);
37014 enable_irq(gpio_to_irq(data->pdata->gpio_data));
37015 /* If still not occurred or another handler was scheduled */
37016 if (gpio_get_value(data->pdata->gpio_data)
37017 - || atomic_read(&data->interrupt_handled))
37018 + || atomic_read_unchecked(&data->interrupt_handled))
37019 return;
37020 }
37021
37022 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
37023 index 76f157b..9c0db1b 100644
37024 --- a/drivers/hwmon/via-cputemp.c
37025 +++ b/drivers/hwmon/via-cputemp.c
37026 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
37027 return NOTIFY_OK;
37028 }
37029
37030 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
37031 +static struct notifier_block via_cputemp_cpu_notifier = {
37032 .notifier_call = via_cputemp_cpu_callback,
37033 };
37034
37035 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
37036 index 07f01ac..d79ad3d 100644
37037 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
37038 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
37039 @@ -43,7 +43,7 @@
37040 extern struct i2c_adapter amd756_smbus;
37041
37042 static struct i2c_adapter *s4882_adapter;
37043 -static struct i2c_algorithm *s4882_algo;
37044 +static i2c_algorithm_no_const *s4882_algo;
37045
37046 /* Wrapper access functions for multiplexed SMBus */
37047 static DEFINE_MUTEX(amd756_lock);
37048 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
37049 index 2ca268d..c6acbdf 100644
37050 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
37051 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
37052 @@ -41,7 +41,7 @@
37053 extern struct i2c_adapter *nforce2_smbus;
37054
37055 static struct i2c_adapter *s4985_adapter;
37056 -static struct i2c_algorithm *s4985_algo;
37057 +static i2c_algorithm_no_const *s4985_algo;
37058
37059 /* Wrapper access functions for multiplexed SMBus */
37060 static DEFINE_MUTEX(nforce2_lock);
37061 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
37062 index c3ccdea..5b3dc1a 100644
37063 --- a/drivers/i2c/i2c-dev.c
37064 +++ b/drivers/i2c/i2c-dev.c
37065 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
37066 break;
37067 }
37068
37069 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
37070 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
37071 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
37072 if (IS_ERR(rdwr_pa[i].buf)) {
37073 res = PTR_ERR(rdwr_pa[i].buf);
37074 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
37075 index 2ff6204..218c16e 100644
37076 --- a/drivers/ide/ide-cd.c
37077 +++ b/drivers/ide/ide-cd.c
37078 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
37079 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
37080 if ((unsigned long)buf & alignment
37081 || blk_rq_bytes(rq) & q->dma_pad_mask
37082 - || object_is_on_stack(buf))
37083 + || object_starts_on_stack(buf))
37084 drive->dma = 0;
37085 }
37086 }
37087 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
37088 index e145931..08bfc59 100644
37089 --- a/drivers/iio/industrialio-core.c
37090 +++ b/drivers/iio/industrialio-core.c
37091 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
37092 }
37093
37094 static
37095 -int __iio_device_attr_init(struct device_attribute *dev_attr,
37096 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
37097 const char *postfix,
37098 struct iio_chan_spec const *chan,
37099 ssize_t (*readfunc)(struct device *dev,
37100 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
37101 index 784b97c..c9ceadf 100644
37102 --- a/drivers/infiniband/core/cm.c
37103 +++ b/drivers/infiniband/core/cm.c
37104 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
37105
37106 struct cm_counter_group {
37107 struct kobject obj;
37108 - atomic_long_t counter[CM_ATTR_COUNT];
37109 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
37110 };
37111
37112 struct cm_counter_attribute {
37113 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
37114 struct ib_mad_send_buf *msg = NULL;
37115 int ret;
37116
37117 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37118 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37119 counter[CM_REQ_COUNTER]);
37120
37121 /* Quick state check to discard duplicate REQs. */
37122 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
37123 if (!cm_id_priv)
37124 return;
37125
37126 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37127 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37128 counter[CM_REP_COUNTER]);
37129 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
37130 if (ret)
37131 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
37132 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
37133 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
37134 spin_unlock_irq(&cm_id_priv->lock);
37135 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37136 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37137 counter[CM_RTU_COUNTER]);
37138 goto out;
37139 }
37140 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
37141 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
37142 dreq_msg->local_comm_id);
37143 if (!cm_id_priv) {
37144 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37145 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37146 counter[CM_DREQ_COUNTER]);
37147 cm_issue_drep(work->port, work->mad_recv_wc);
37148 return -EINVAL;
37149 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
37150 case IB_CM_MRA_REP_RCVD:
37151 break;
37152 case IB_CM_TIMEWAIT:
37153 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37154 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37155 counter[CM_DREQ_COUNTER]);
37156 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37157 goto unlock;
37158 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
37159 cm_free_msg(msg);
37160 goto deref;
37161 case IB_CM_DREQ_RCVD:
37162 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37163 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37164 counter[CM_DREQ_COUNTER]);
37165 goto unlock;
37166 default:
37167 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
37168 ib_modify_mad(cm_id_priv->av.port->mad_agent,
37169 cm_id_priv->msg, timeout)) {
37170 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
37171 - atomic_long_inc(&work->port->
37172 + atomic_long_inc_unchecked(&work->port->
37173 counter_group[CM_RECV_DUPLICATES].
37174 counter[CM_MRA_COUNTER]);
37175 goto out;
37176 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
37177 break;
37178 case IB_CM_MRA_REQ_RCVD:
37179 case IB_CM_MRA_REP_RCVD:
37180 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37181 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37182 counter[CM_MRA_COUNTER]);
37183 /* fall through */
37184 default:
37185 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
37186 case IB_CM_LAP_IDLE:
37187 break;
37188 case IB_CM_MRA_LAP_SENT:
37189 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37190 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37191 counter[CM_LAP_COUNTER]);
37192 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37193 goto unlock;
37194 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
37195 cm_free_msg(msg);
37196 goto deref;
37197 case IB_CM_LAP_RCVD:
37198 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37199 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37200 counter[CM_LAP_COUNTER]);
37201 goto unlock;
37202 default:
37203 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
37204 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
37205 if (cur_cm_id_priv) {
37206 spin_unlock_irq(&cm.lock);
37207 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37208 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37209 counter[CM_SIDR_REQ_COUNTER]);
37210 goto out; /* Duplicate message. */
37211 }
37212 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
37213 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
37214 msg->retries = 1;
37215
37216 - atomic_long_add(1 + msg->retries,
37217 + atomic_long_add_unchecked(1 + msg->retries,
37218 &port->counter_group[CM_XMIT].counter[attr_index]);
37219 if (msg->retries)
37220 - atomic_long_add(msg->retries,
37221 + atomic_long_add_unchecked(msg->retries,
37222 &port->counter_group[CM_XMIT_RETRIES].
37223 counter[attr_index]);
37224
37225 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
37226 }
37227
37228 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
37229 - atomic_long_inc(&port->counter_group[CM_RECV].
37230 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
37231 counter[attr_id - CM_ATTR_ID_OFFSET]);
37232
37233 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
37234 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
37235 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
37236
37237 return sprintf(buf, "%ld\n",
37238 - atomic_long_read(&group->counter[cm_attr->index]));
37239 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
37240 }
37241
37242 static const struct sysfs_ops cm_counter_ops = {
37243 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
37244 index 9f5ad7c..588cd84 100644
37245 --- a/drivers/infiniband/core/fmr_pool.c
37246 +++ b/drivers/infiniband/core/fmr_pool.c
37247 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
37248
37249 struct task_struct *thread;
37250
37251 - atomic_t req_ser;
37252 - atomic_t flush_ser;
37253 + atomic_unchecked_t req_ser;
37254 + atomic_unchecked_t flush_ser;
37255
37256 wait_queue_head_t force_wait;
37257 };
37258 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37259 struct ib_fmr_pool *pool = pool_ptr;
37260
37261 do {
37262 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
37263 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37264 ib_fmr_batch_release(pool);
37265
37266 - atomic_inc(&pool->flush_ser);
37267 + atomic_inc_unchecked(&pool->flush_ser);
37268 wake_up_interruptible(&pool->force_wait);
37269
37270 if (pool->flush_function)
37271 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37272 }
37273
37274 set_current_state(TASK_INTERRUPTIBLE);
37275 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37276 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37277 !kthread_should_stop())
37278 schedule();
37279 __set_current_state(TASK_RUNNING);
37280 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37281 pool->dirty_watermark = params->dirty_watermark;
37282 pool->dirty_len = 0;
37283 spin_lock_init(&pool->pool_lock);
37284 - atomic_set(&pool->req_ser, 0);
37285 - atomic_set(&pool->flush_ser, 0);
37286 + atomic_set_unchecked(&pool->req_ser, 0);
37287 + atomic_set_unchecked(&pool->flush_ser, 0);
37288 init_waitqueue_head(&pool->force_wait);
37289
37290 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37291 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37292 }
37293 spin_unlock_irq(&pool->pool_lock);
37294
37295 - serial = atomic_inc_return(&pool->req_ser);
37296 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37297 wake_up_process(pool->thread);
37298
37299 if (wait_event_interruptible(pool->force_wait,
37300 - atomic_read(&pool->flush_ser) - serial >= 0))
37301 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37302 return -EINTR;
37303
37304 return 0;
37305 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37306 } else {
37307 list_add_tail(&fmr->list, &pool->dirty_list);
37308 if (++pool->dirty_len >= pool->dirty_watermark) {
37309 - atomic_inc(&pool->req_ser);
37310 + atomic_inc_unchecked(&pool->req_ser);
37311 wake_up_process(pool->thread);
37312 }
37313 }
37314 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37315 index 4cb8eb2..146bf60 100644
37316 --- a/drivers/infiniband/hw/cxgb4/mem.c
37317 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37318 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37319 int err;
37320 struct fw_ri_tpte tpt;
37321 u32 stag_idx;
37322 - static atomic_t key;
37323 + static atomic_unchecked_t key;
37324
37325 if (c4iw_fatal_error(rdev))
37326 return -EIO;
37327 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37328 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37329 rdev->stats.stag.max = rdev->stats.stag.cur;
37330 mutex_unlock(&rdev->stats.lock);
37331 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37332 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37333 }
37334 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37335 __func__, stag_state, type, pdid, stag_idx);
37336 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37337 index 79b3dbc..96e5fcc 100644
37338 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37339 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37340 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37341 struct ib_atomic_eth *ateth;
37342 struct ipath_ack_entry *e;
37343 u64 vaddr;
37344 - atomic64_t *maddr;
37345 + atomic64_unchecked_t *maddr;
37346 u64 sdata;
37347 u32 rkey;
37348 u8 next;
37349 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37350 IB_ACCESS_REMOTE_ATOMIC)))
37351 goto nack_acc_unlck;
37352 /* Perform atomic OP and save result. */
37353 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37354 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37355 sdata = be64_to_cpu(ateth->swap_data);
37356 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37357 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37358 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37359 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37360 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37361 be64_to_cpu(ateth->compare_data),
37362 sdata);
37363 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37364 index 1f95bba..9530f87 100644
37365 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37366 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37367 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37368 unsigned long flags;
37369 struct ib_wc wc;
37370 u64 sdata;
37371 - atomic64_t *maddr;
37372 + atomic64_unchecked_t *maddr;
37373 enum ib_wc_status send_status;
37374
37375 /*
37376 @@ -382,11 +382,11 @@ again:
37377 IB_ACCESS_REMOTE_ATOMIC)))
37378 goto acc_err;
37379 /* Perform atomic OP and save result. */
37380 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37381 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37382 sdata = wqe->wr.wr.atomic.compare_add;
37383 *(u64 *) sqp->s_sge.sge.vaddr =
37384 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37385 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37386 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37387 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37388 sdata, wqe->wr.wr.atomic.swap);
37389 goto send_comp;
37390 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37391 index 9d3e5c1..d9afe4a 100644
37392 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37393 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37394 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37395 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37396 }
37397
37398 -int mthca_QUERY_FW(struct mthca_dev *dev)
37399 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37400 {
37401 struct mthca_mailbox *mailbox;
37402 u32 *outbox;
37403 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37404 index ed9a989..e0c5871 100644
37405 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37406 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37407 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37408 return key;
37409 }
37410
37411 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37412 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37413 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37414 {
37415 struct mthca_mailbox *mailbox;
37416 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37417 index 4291410..d2ab1fb 100644
37418 --- a/drivers/infiniband/hw/nes/nes.c
37419 +++ b/drivers/infiniband/hw/nes/nes.c
37420 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37421 LIST_HEAD(nes_adapter_list);
37422 static LIST_HEAD(nes_dev_list);
37423
37424 -atomic_t qps_destroyed;
37425 +atomic_unchecked_t qps_destroyed;
37426
37427 static unsigned int ee_flsh_adapter;
37428 static unsigned int sysfs_nonidx_addr;
37429 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37430 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37431 struct nes_adapter *nesadapter = nesdev->nesadapter;
37432
37433 - atomic_inc(&qps_destroyed);
37434 + atomic_inc_unchecked(&qps_destroyed);
37435
37436 /* Free the control structures */
37437
37438 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37439 index 33cc589..3bd6538 100644
37440 --- a/drivers/infiniband/hw/nes/nes.h
37441 +++ b/drivers/infiniband/hw/nes/nes.h
37442 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37443 extern unsigned int wqm_quanta;
37444 extern struct list_head nes_adapter_list;
37445
37446 -extern atomic_t cm_connects;
37447 -extern atomic_t cm_accepts;
37448 -extern atomic_t cm_disconnects;
37449 -extern atomic_t cm_closes;
37450 -extern atomic_t cm_connecteds;
37451 -extern atomic_t cm_connect_reqs;
37452 -extern atomic_t cm_rejects;
37453 -extern atomic_t mod_qp_timouts;
37454 -extern atomic_t qps_created;
37455 -extern atomic_t qps_destroyed;
37456 -extern atomic_t sw_qps_destroyed;
37457 +extern atomic_unchecked_t cm_connects;
37458 +extern atomic_unchecked_t cm_accepts;
37459 +extern atomic_unchecked_t cm_disconnects;
37460 +extern atomic_unchecked_t cm_closes;
37461 +extern atomic_unchecked_t cm_connecteds;
37462 +extern atomic_unchecked_t cm_connect_reqs;
37463 +extern atomic_unchecked_t cm_rejects;
37464 +extern atomic_unchecked_t mod_qp_timouts;
37465 +extern atomic_unchecked_t qps_created;
37466 +extern atomic_unchecked_t qps_destroyed;
37467 +extern atomic_unchecked_t sw_qps_destroyed;
37468 extern u32 mh_detected;
37469 extern u32 mh_pauses_sent;
37470 extern u32 cm_packets_sent;
37471 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37472 extern u32 cm_packets_received;
37473 extern u32 cm_packets_dropped;
37474 extern u32 cm_packets_retrans;
37475 -extern atomic_t cm_listens_created;
37476 -extern atomic_t cm_listens_destroyed;
37477 +extern atomic_unchecked_t cm_listens_created;
37478 +extern atomic_unchecked_t cm_listens_destroyed;
37479 extern u32 cm_backlog_drops;
37480 -extern atomic_t cm_loopbacks;
37481 -extern atomic_t cm_nodes_created;
37482 -extern atomic_t cm_nodes_destroyed;
37483 -extern atomic_t cm_accel_dropped_pkts;
37484 -extern atomic_t cm_resets_recvd;
37485 -extern atomic_t pau_qps_created;
37486 -extern atomic_t pau_qps_destroyed;
37487 +extern atomic_unchecked_t cm_loopbacks;
37488 +extern atomic_unchecked_t cm_nodes_created;
37489 +extern atomic_unchecked_t cm_nodes_destroyed;
37490 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37491 +extern atomic_unchecked_t cm_resets_recvd;
37492 +extern atomic_unchecked_t pau_qps_created;
37493 +extern atomic_unchecked_t pau_qps_destroyed;
37494
37495 extern u32 int_mod_timer_init;
37496 extern u32 int_mod_cq_depth_256;
37497 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37498 index 24b9f1a..00fd004 100644
37499 --- a/drivers/infiniband/hw/nes/nes_cm.c
37500 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37501 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37502 u32 cm_packets_retrans;
37503 u32 cm_packets_created;
37504 u32 cm_packets_received;
37505 -atomic_t cm_listens_created;
37506 -atomic_t cm_listens_destroyed;
37507 +atomic_unchecked_t cm_listens_created;
37508 +atomic_unchecked_t cm_listens_destroyed;
37509 u32 cm_backlog_drops;
37510 -atomic_t cm_loopbacks;
37511 -atomic_t cm_nodes_created;
37512 -atomic_t cm_nodes_destroyed;
37513 -atomic_t cm_accel_dropped_pkts;
37514 -atomic_t cm_resets_recvd;
37515 +atomic_unchecked_t cm_loopbacks;
37516 +atomic_unchecked_t cm_nodes_created;
37517 +atomic_unchecked_t cm_nodes_destroyed;
37518 +atomic_unchecked_t cm_accel_dropped_pkts;
37519 +atomic_unchecked_t cm_resets_recvd;
37520
37521 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37522 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37523 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37524
37525 static struct nes_cm_core *g_cm_core;
37526
37527 -atomic_t cm_connects;
37528 -atomic_t cm_accepts;
37529 -atomic_t cm_disconnects;
37530 -atomic_t cm_closes;
37531 -atomic_t cm_connecteds;
37532 -atomic_t cm_connect_reqs;
37533 -atomic_t cm_rejects;
37534 +atomic_unchecked_t cm_connects;
37535 +atomic_unchecked_t cm_accepts;
37536 +atomic_unchecked_t cm_disconnects;
37537 +atomic_unchecked_t cm_closes;
37538 +atomic_unchecked_t cm_connecteds;
37539 +atomic_unchecked_t cm_connect_reqs;
37540 +atomic_unchecked_t cm_rejects;
37541
37542 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37543 {
37544 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37545 kfree(listener);
37546 listener = NULL;
37547 ret = 0;
37548 - atomic_inc(&cm_listens_destroyed);
37549 + atomic_inc_unchecked(&cm_listens_destroyed);
37550 } else {
37551 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37552 }
37553 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37554 cm_node->rem_mac);
37555
37556 add_hte_node(cm_core, cm_node);
37557 - atomic_inc(&cm_nodes_created);
37558 + atomic_inc_unchecked(&cm_nodes_created);
37559
37560 return cm_node;
37561 }
37562 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37563 }
37564
37565 atomic_dec(&cm_core->node_cnt);
37566 - atomic_inc(&cm_nodes_destroyed);
37567 + atomic_inc_unchecked(&cm_nodes_destroyed);
37568 nesqp = cm_node->nesqp;
37569 if (nesqp) {
37570 nesqp->cm_node = NULL;
37571 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37572
37573 static void drop_packet(struct sk_buff *skb)
37574 {
37575 - atomic_inc(&cm_accel_dropped_pkts);
37576 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37577 dev_kfree_skb_any(skb);
37578 }
37579
37580 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37581 {
37582
37583 int reset = 0; /* whether to send reset in case of err.. */
37584 - atomic_inc(&cm_resets_recvd);
37585 + atomic_inc_unchecked(&cm_resets_recvd);
37586 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37587 " refcnt=%d\n", cm_node, cm_node->state,
37588 atomic_read(&cm_node->ref_count));
37589 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37590 rem_ref_cm_node(cm_node->cm_core, cm_node);
37591 return NULL;
37592 }
37593 - atomic_inc(&cm_loopbacks);
37594 + atomic_inc_unchecked(&cm_loopbacks);
37595 loopbackremotenode->loopbackpartner = cm_node;
37596 loopbackremotenode->tcp_cntxt.rcv_wscale =
37597 NES_CM_DEFAULT_RCV_WND_SCALE;
37598 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37599 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37600 else {
37601 rem_ref_cm_node(cm_core, cm_node);
37602 - atomic_inc(&cm_accel_dropped_pkts);
37603 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37604 dev_kfree_skb_any(skb);
37605 }
37606 break;
37607 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37608
37609 if ((cm_id) && (cm_id->event_handler)) {
37610 if (issue_disconn) {
37611 - atomic_inc(&cm_disconnects);
37612 + atomic_inc_unchecked(&cm_disconnects);
37613 cm_event.event = IW_CM_EVENT_DISCONNECT;
37614 cm_event.status = disconn_status;
37615 cm_event.local_addr = cm_id->local_addr;
37616 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37617 }
37618
37619 if (issue_close) {
37620 - atomic_inc(&cm_closes);
37621 + atomic_inc_unchecked(&cm_closes);
37622 nes_disconnect(nesqp, 1);
37623
37624 cm_id->provider_data = nesqp;
37625 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37626
37627 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37628 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37629 - atomic_inc(&cm_accepts);
37630 + atomic_inc_unchecked(&cm_accepts);
37631
37632 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37633 netdev_refcnt_read(nesvnic->netdev));
37634 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37635 struct nes_cm_core *cm_core;
37636 u8 *start_buff;
37637
37638 - atomic_inc(&cm_rejects);
37639 + atomic_inc_unchecked(&cm_rejects);
37640 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37641 loopback = cm_node->loopbackpartner;
37642 cm_core = cm_node->cm_core;
37643 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37644 ntohl(cm_id->local_addr.sin_addr.s_addr),
37645 ntohs(cm_id->local_addr.sin_port));
37646
37647 - atomic_inc(&cm_connects);
37648 + atomic_inc_unchecked(&cm_connects);
37649 nesqp->active_conn = 1;
37650
37651 /* cache the cm_id in the qp */
37652 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37653 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37654 return err;
37655 }
37656 - atomic_inc(&cm_listens_created);
37657 + atomic_inc_unchecked(&cm_listens_created);
37658 }
37659
37660 cm_id->add_ref(cm_id);
37661 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37662
37663 if (nesqp->destroyed)
37664 return;
37665 - atomic_inc(&cm_connecteds);
37666 + atomic_inc_unchecked(&cm_connecteds);
37667 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37668 " local port 0x%04X. jiffies = %lu.\n",
37669 nesqp->hwqp.qp_id,
37670 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37671
37672 cm_id->add_ref(cm_id);
37673 ret = cm_id->event_handler(cm_id, &cm_event);
37674 - atomic_inc(&cm_closes);
37675 + atomic_inc_unchecked(&cm_closes);
37676 cm_event.event = IW_CM_EVENT_CLOSE;
37677 cm_event.status = 0;
37678 cm_event.provider_data = cm_id->provider_data;
37679 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37680 return;
37681 cm_id = cm_node->cm_id;
37682
37683 - atomic_inc(&cm_connect_reqs);
37684 + atomic_inc_unchecked(&cm_connect_reqs);
37685 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37686 cm_node, cm_id, jiffies);
37687
37688 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37689 return;
37690 cm_id = cm_node->cm_id;
37691
37692 - atomic_inc(&cm_connect_reqs);
37693 + atomic_inc_unchecked(&cm_connect_reqs);
37694 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37695 cm_node, cm_id, jiffies);
37696
37697 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37698 index 4166452..fc952c3 100644
37699 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37700 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37701 @@ -40,8 +40,8 @@
37702 #include "nes.h"
37703 #include "nes_mgt.h"
37704
37705 -atomic_t pau_qps_created;
37706 -atomic_t pau_qps_destroyed;
37707 +atomic_unchecked_t pau_qps_created;
37708 +atomic_unchecked_t pau_qps_destroyed;
37709
37710 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37711 {
37712 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37713 {
37714 struct sk_buff *skb;
37715 unsigned long flags;
37716 - atomic_inc(&pau_qps_destroyed);
37717 + atomic_inc_unchecked(&pau_qps_destroyed);
37718
37719 /* Free packets that have not yet been forwarded */
37720 /* Lock is acquired by skb_dequeue when removing the skb */
37721 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37722 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37723 skb_queue_head_init(&nesqp->pau_list);
37724 spin_lock_init(&nesqp->pau_lock);
37725 - atomic_inc(&pau_qps_created);
37726 + atomic_inc_unchecked(&pau_qps_created);
37727 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37728 }
37729
37730 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37731 index 49eb511..a774366 100644
37732 --- a/drivers/infiniband/hw/nes/nes_nic.c
37733 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37734 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37735 target_stat_values[++index] = mh_detected;
37736 target_stat_values[++index] = mh_pauses_sent;
37737 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37738 - target_stat_values[++index] = atomic_read(&cm_connects);
37739 - target_stat_values[++index] = atomic_read(&cm_accepts);
37740 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37741 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37742 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37743 - target_stat_values[++index] = atomic_read(&cm_rejects);
37744 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37745 - target_stat_values[++index] = atomic_read(&qps_created);
37746 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37747 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37748 - target_stat_values[++index] = atomic_read(&cm_closes);
37749 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37750 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37751 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37752 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37753 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37754 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37755 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37756 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37757 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37758 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37759 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37760 target_stat_values[++index] = cm_packets_sent;
37761 target_stat_values[++index] = cm_packets_bounced;
37762 target_stat_values[++index] = cm_packets_created;
37763 target_stat_values[++index] = cm_packets_received;
37764 target_stat_values[++index] = cm_packets_dropped;
37765 target_stat_values[++index] = cm_packets_retrans;
37766 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37767 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37768 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37769 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37770 target_stat_values[++index] = cm_backlog_drops;
37771 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37772 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37773 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37774 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37775 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37776 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37777 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37778 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37779 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37780 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37781 target_stat_values[++index] = nesadapter->free_4kpbl;
37782 target_stat_values[++index] = nesadapter->free_256pbl;
37783 target_stat_values[++index] = int_mod_timer_init;
37784 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37785 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37786 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37787 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37788 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37789 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37790 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37791 }
37792
37793 /**
37794 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37795 index 8f67fe2..8960859 100644
37796 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37797 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37798 @@ -46,9 +46,9 @@
37799
37800 #include <rdma/ib_umem.h>
37801
37802 -atomic_t mod_qp_timouts;
37803 -atomic_t qps_created;
37804 -atomic_t sw_qps_destroyed;
37805 +atomic_unchecked_t mod_qp_timouts;
37806 +atomic_unchecked_t qps_created;
37807 +atomic_unchecked_t sw_qps_destroyed;
37808
37809 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37810
37811 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37812 if (init_attr->create_flags)
37813 return ERR_PTR(-EINVAL);
37814
37815 - atomic_inc(&qps_created);
37816 + atomic_inc_unchecked(&qps_created);
37817 switch (init_attr->qp_type) {
37818 case IB_QPT_RC:
37819 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37820 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37821 struct iw_cm_event cm_event;
37822 int ret = 0;
37823
37824 - atomic_inc(&sw_qps_destroyed);
37825 + atomic_inc_unchecked(&sw_qps_destroyed);
37826 nesqp->destroyed = 1;
37827
37828 /* Blow away the connection if it exists. */
37829 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37830 index 4d11575..3e890e5 100644
37831 --- a/drivers/infiniband/hw/qib/qib.h
37832 +++ b/drivers/infiniband/hw/qib/qib.h
37833 @@ -51,6 +51,7 @@
37834 #include <linux/completion.h>
37835 #include <linux/kref.h>
37836 #include <linux/sched.h>
37837 +#include <linux/slab.h>
37838
37839 #include "qib_common.h"
37840 #include "qib_verbs.h"
37841 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37842 index da739d9..da1c7f4 100644
37843 --- a/drivers/input/gameport/gameport.c
37844 +++ b/drivers/input/gameport/gameport.c
37845 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37846 */
37847 static void gameport_init_port(struct gameport *gameport)
37848 {
37849 - static atomic_t gameport_no = ATOMIC_INIT(0);
37850 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37851
37852 __module_get(THIS_MODULE);
37853
37854 mutex_init(&gameport->drv_mutex);
37855 device_initialize(&gameport->dev);
37856 dev_set_name(&gameport->dev, "gameport%lu",
37857 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37858 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37859 gameport->dev.bus = &gameport_bus;
37860 gameport->dev.release = gameport_release_port;
37861 if (gameport->parent)
37862 diff --git a/drivers/input/input.c b/drivers/input/input.c
37863 index c044699..174d71a 100644
37864 --- a/drivers/input/input.c
37865 +++ b/drivers/input/input.c
37866 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37867 */
37868 int input_register_device(struct input_dev *dev)
37869 {
37870 - static atomic_t input_no = ATOMIC_INIT(0);
37871 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37872 struct input_devres *devres = NULL;
37873 struct input_handler *handler;
37874 unsigned int packet_size;
37875 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37876 dev->setkeycode = input_default_setkeycode;
37877
37878 dev_set_name(&dev->dev, "input%ld",
37879 - (unsigned long) atomic_inc_return(&input_no) - 1);
37880 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37881
37882 error = device_add(&dev->dev);
37883 if (error)
37884 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37885 index 04c69af..5f92d00 100644
37886 --- a/drivers/input/joystick/sidewinder.c
37887 +++ b/drivers/input/joystick/sidewinder.c
37888 @@ -30,6 +30,7 @@
37889 #include <linux/kernel.h>
37890 #include <linux/module.h>
37891 #include <linux/slab.h>
37892 +#include <linux/sched.h>
37893 #include <linux/init.h>
37894 #include <linux/input.h>
37895 #include <linux/gameport.h>
37896 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37897 index fa061d4..4a6957c 100644
37898 --- a/drivers/input/joystick/xpad.c
37899 +++ b/drivers/input/joystick/xpad.c
37900 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37901
37902 static int xpad_led_probe(struct usb_xpad *xpad)
37903 {
37904 - static atomic_t led_seq = ATOMIC_INIT(0);
37905 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37906 long led_no;
37907 struct xpad_led *led;
37908 struct led_classdev *led_cdev;
37909 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37910 if (!led)
37911 return -ENOMEM;
37912
37913 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37914 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37915
37916 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37917 led->xpad = xpad;
37918 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37919 index 2f0b39d..7370f13 100644
37920 --- a/drivers/input/mouse/psmouse.h
37921 +++ b/drivers/input/mouse/psmouse.h
37922 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37923 ssize_t (*set)(struct psmouse *psmouse, void *data,
37924 const char *buf, size_t count);
37925 bool protect;
37926 -};
37927 +} __do_const;
37928 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37929
37930 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37931 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37932 index 4c842c3..590b0bf 100644
37933 --- a/drivers/input/mousedev.c
37934 +++ b/drivers/input/mousedev.c
37935 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37936
37937 spin_unlock_irq(&client->packet_lock);
37938
37939 - if (copy_to_user(buffer, data, count))
37940 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37941 return -EFAULT;
37942
37943 return count;
37944 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37945 index 25fc597..558bf3b3 100644
37946 --- a/drivers/input/serio/serio.c
37947 +++ b/drivers/input/serio/serio.c
37948 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37949 */
37950 static void serio_init_port(struct serio *serio)
37951 {
37952 - static atomic_t serio_no = ATOMIC_INIT(0);
37953 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37954
37955 __module_get(THIS_MODULE);
37956
37957 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37958 mutex_init(&serio->drv_mutex);
37959 device_initialize(&serio->dev);
37960 dev_set_name(&serio->dev, "serio%ld",
37961 - (long)atomic_inc_return(&serio_no) - 1);
37962 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37963 serio->dev.bus = &serio_bus;
37964 serio->dev.release = serio_release_port;
37965 serio->dev.groups = serio_device_attr_groups;
37966 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37967 index d8f98b1..f62a640 100644
37968 --- a/drivers/iommu/iommu.c
37969 +++ b/drivers/iommu/iommu.c
37970 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
37971 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37972 {
37973 bus_register_notifier(bus, &iommu_bus_nb);
37974 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37975 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37976 }
37977
37978 /**
37979 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37980 index dcfea4e..f4226b2 100644
37981 --- a/drivers/iommu/irq_remapping.c
37982 +++ b/drivers/iommu/irq_remapping.c
37983 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
37984 void panic_if_irq_remap(const char *msg)
37985 {
37986 if (irq_remapping_enabled)
37987 - panic(msg);
37988 + panic("%s", msg);
37989 }
37990
37991 static void ir_ack_apic_edge(struct irq_data *data)
37992 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37993
37994 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37995 {
37996 - chip->irq_print_chip = ir_print_prefix;
37997 - chip->irq_ack = ir_ack_apic_edge;
37998 - chip->irq_eoi = ir_ack_apic_level;
37999 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
38000 + pax_open_kernel();
38001 + *(void **)&chip->irq_print_chip = ir_print_prefix;
38002 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
38003 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
38004 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
38005 + pax_close_kernel();
38006 }
38007
38008 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
38009 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
38010 index 19ceaa6..3625818 100644
38011 --- a/drivers/irqchip/irq-gic.c
38012 +++ b/drivers/irqchip/irq-gic.c
38013 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
38014 * Supported arch specific GIC irq extension.
38015 * Default make them NULL.
38016 */
38017 -struct irq_chip gic_arch_extn = {
38018 +irq_chip_no_const gic_arch_extn = {
38019 .irq_eoi = NULL,
38020 .irq_mask = NULL,
38021 .irq_unmask = NULL,
38022 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
38023 chained_irq_exit(chip, desc);
38024 }
38025
38026 -static struct irq_chip gic_chip = {
38027 +static irq_chip_no_const gic_chip __read_only = {
38028 .name = "GIC",
38029 .irq_mask = gic_mask_irq,
38030 .irq_unmask = gic_unmask_irq,
38031 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
38032 index ac6f72b..81150f2 100644
38033 --- a/drivers/isdn/capi/capi.c
38034 +++ b/drivers/isdn/capi/capi.c
38035 @@ -81,8 +81,8 @@ struct capiminor {
38036
38037 struct capi20_appl *ap;
38038 u32 ncci;
38039 - atomic_t datahandle;
38040 - atomic_t msgid;
38041 + atomic_unchecked_t datahandle;
38042 + atomic_unchecked_t msgid;
38043
38044 struct tty_port port;
38045 int ttyinstop;
38046 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
38047 capimsg_setu16(s, 2, mp->ap->applid);
38048 capimsg_setu8 (s, 4, CAPI_DATA_B3);
38049 capimsg_setu8 (s, 5, CAPI_RESP);
38050 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
38051 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
38052 capimsg_setu32(s, 8, mp->ncci);
38053 capimsg_setu16(s, 12, datahandle);
38054 }
38055 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
38056 mp->outbytes -= len;
38057 spin_unlock_bh(&mp->outlock);
38058
38059 - datahandle = atomic_inc_return(&mp->datahandle);
38060 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
38061 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
38062 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38063 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38064 capimsg_setu16(skb->data, 2, mp->ap->applid);
38065 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
38066 capimsg_setu8 (skb->data, 5, CAPI_REQ);
38067 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
38068 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
38069 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
38070 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
38071 capimsg_setu16(skb->data, 16, len); /* Data length */
38072 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
38073 index 600c79b..3752bab 100644
38074 --- a/drivers/isdn/gigaset/interface.c
38075 +++ b/drivers/isdn/gigaset/interface.c
38076 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
38077 }
38078 tty->driver_data = cs;
38079
38080 - ++cs->port.count;
38081 + atomic_inc(&cs->port.count);
38082
38083 - if (cs->port.count == 1) {
38084 + if (atomic_read(&cs->port.count) == 1) {
38085 tty_port_tty_set(&cs->port, tty);
38086 cs->port.low_latency = 1;
38087 }
38088 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
38089
38090 if (!cs->connected)
38091 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
38092 - else if (!cs->port.count)
38093 + else if (!atomic_read(&cs->port.count))
38094 dev_warn(cs->dev, "%s: device not opened\n", __func__);
38095 - else if (!--cs->port.count)
38096 + else if (!atomic_dec_return(&cs->port.count))
38097 tty_port_tty_set(&cs->port, NULL);
38098
38099 mutex_unlock(&cs->mutex);
38100 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
38101 index 4d9b195..455075c 100644
38102 --- a/drivers/isdn/hardware/avm/b1.c
38103 +++ b/drivers/isdn/hardware/avm/b1.c
38104 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
38105 }
38106 if (left) {
38107 if (t4file->user) {
38108 - if (copy_from_user(buf, dp, left))
38109 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38110 return -EFAULT;
38111 } else {
38112 memcpy(buf, dp, left);
38113 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
38114 }
38115 if (left) {
38116 if (config->user) {
38117 - if (copy_from_user(buf, dp, left))
38118 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38119 return -EFAULT;
38120 } else {
38121 memcpy(buf, dp, left);
38122 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
38123 index 3c5f249..5fac4d0 100644
38124 --- a/drivers/isdn/i4l/isdn_tty.c
38125 +++ b/drivers/isdn/i4l/isdn_tty.c
38126 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
38127
38128 #ifdef ISDN_DEBUG_MODEM_OPEN
38129 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
38130 - port->count);
38131 + atomic_read(&port->count));
38132 #endif
38133 - port->count++;
38134 + atomic_inc(&port->count);
38135 port->tty = tty;
38136 /*
38137 * Start up serial port
38138 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38139 #endif
38140 return;
38141 }
38142 - if ((tty->count == 1) && (port->count != 1)) {
38143 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
38144 /*
38145 * Uh, oh. tty->count is 1, which means that the tty
38146 * structure will be freed. Info->count should always
38147 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38148 * serial port won't be shutdown.
38149 */
38150 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
38151 - "info->count is %d\n", port->count);
38152 - port->count = 1;
38153 + "info->count is %d\n", atomic_read(&port->count));
38154 + atomic_set(&port->count, 1);
38155 }
38156 - if (--port->count < 0) {
38157 + if (atomic_dec_return(&port->count) < 0) {
38158 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
38159 - info->line, port->count);
38160 - port->count = 0;
38161 + info->line, atomic_read(&port->count));
38162 + atomic_set(&port->count, 0);
38163 }
38164 - if (port->count) {
38165 + if (atomic_read(&port->count)) {
38166 #ifdef ISDN_DEBUG_MODEM_OPEN
38167 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
38168 #endif
38169 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
38170 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
38171 return;
38172 isdn_tty_shutdown(info);
38173 - port->count = 0;
38174 + atomic_set(&port->count, 0);
38175 port->flags &= ~ASYNC_NORMAL_ACTIVE;
38176 port->tty = NULL;
38177 wake_up_interruptible(&port->open_wait);
38178 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
38179 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
38180 modem_info *info = &dev->mdm.info[i];
38181
38182 - if (info->port.count == 0)
38183 + if (atomic_read(&info->port.count) == 0)
38184 continue;
38185 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
38186 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
38187 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
38188 index e74df7c..03a03ba 100644
38189 --- a/drivers/isdn/icn/icn.c
38190 +++ b/drivers/isdn/icn/icn.c
38191 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
38192 if (count > len)
38193 count = len;
38194 if (user) {
38195 - if (copy_from_user(msg, buf, count))
38196 + if (count > sizeof msg || copy_from_user(msg, buf, count))
38197 return -EFAULT;
38198 } else
38199 memcpy(msg, buf, count);
38200 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
38201 index 6a8405d..0bd1c7e 100644
38202 --- a/drivers/leds/leds-clevo-mail.c
38203 +++ b/drivers/leds/leds-clevo-mail.c
38204 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
38205 * detected as working, but in reality it is not) as low as
38206 * possible.
38207 */
38208 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
38209 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
38210 {
38211 .callback = clevo_mail_led_dmi_callback,
38212 .ident = "Clevo D410J",
38213 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
38214 index 64e204e..c6bf189 100644
38215 --- a/drivers/leds/leds-ss4200.c
38216 +++ b/drivers/leds/leds-ss4200.c
38217 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
38218 * detected as working, but in reality it is not) as low as
38219 * possible.
38220 */
38221 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
38222 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
38223 {
38224 .callback = ss4200_led_dmi_callback,
38225 .ident = "Intel SS4200-E",
38226 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
38227 index 0bf1e4e..b4bf44e 100644
38228 --- a/drivers/lguest/core.c
38229 +++ b/drivers/lguest/core.c
38230 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
38231 * The end address needs +1 because __get_vm_area allocates an
38232 * extra guard page, so we need space for that.
38233 */
38234 +
38235 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
38236 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38237 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
38238 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38239 +#else
38240 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38241 VM_ALLOC, switcher_addr, switcher_addr
38242 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38243 +#endif
38244 +
38245 if (!switcher_vma) {
38246 err = -ENOMEM;
38247 printk("lguest: could not map switcher pages high\n");
38248 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
38249 * Now the Switcher is mapped at the right address, we can't fail!
38250 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
38251 */
38252 - memcpy(switcher_vma->addr, start_switcher_text,
38253 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
38254 end_switcher_text - start_switcher_text);
38255
38256 printk(KERN_INFO "lguest: mapped switcher at %p\n",
38257 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
38258 index 5b9ac32..2ef4f26 100644
38259 --- a/drivers/lguest/page_tables.c
38260 +++ b/drivers/lguest/page_tables.c
38261 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
38262 /*:*/
38263
38264 #ifdef CONFIG_X86_PAE
38265 -static void release_pmd(pmd_t *spmd)
38266 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
38267 {
38268 /* If the entry's not present, there's nothing to release. */
38269 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
38270 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
38271 index f0a3347..f6608b2 100644
38272 --- a/drivers/lguest/x86/core.c
38273 +++ b/drivers/lguest/x86/core.c
38274 @@ -59,7 +59,7 @@ static struct {
38275 /* Offset from where switcher.S was compiled to where we've copied it */
38276 static unsigned long switcher_offset(void)
38277 {
38278 - return switcher_addr - (unsigned long)start_switcher_text;
38279 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
38280 }
38281
38282 /* This cpu's struct lguest_pages (after the Switcher text page) */
38283 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
38284 * These copies are pretty cheap, so we do them unconditionally: */
38285 /* Save the current Host top-level page directory.
38286 */
38287 +
38288 +#ifdef CONFIG_PAX_PER_CPU_PGD
38289 + pages->state.host_cr3 = read_cr3();
38290 +#else
38291 pages->state.host_cr3 = __pa(current->mm->pgd);
38292 +#endif
38293 +
38294 /*
38295 * Set up the Guest's page tables to see this CPU's pages (and no
38296 * other CPU's pages).
38297 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
38298 * compiled-in switcher code and the high-mapped copy we just made.
38299 */
38300 for (i = 0; i < IDT_ENTRIES; i++)
38301 - default_idt_entries[i] += switcher_offset();
38302 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
38303
38304 /*
38305 * Set up the Switcher's per-cpu areas.
38306 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
38307 * it will be undisturbed when we switch. To change %cs and jump we
38308 * need this structure to feed to Intel's "lcall" instruction.
38309 */
38310 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38311 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38312 lguest_entry.segment = LGUEST_CS;
38313
38314 /*
38315 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38316 index 40634b0..4f5855e 100644
38317 --- a/drivers/lguest/x86/switcher_32.S
38318 +++ b/drivers/lguest/x86/switcher_32.S
38319 @@ -87,6 +87,7 @@
38320 #include <asm/page.h>
38321 #include <asm/segment.h>
38322 #include <asm/lguest.h>
38323 +#include <asm/processor-flags.h>
38324
38325 // We mark the start of the code to copy
38326 // It's placed in .text tho it's never run here
38327 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38328 // Changes type when we load it: damn Intel!
38329 // For after we switch over our page tables
38330 // That entry will be read-only: we'd crash.
38331 +
38332 +#ifdef CONFIG_PAX_KERNEXEC
38333 + mov %cr0, %edx
38334 + xor $X86_CR0_WP, %edx
38335 + mov %edx, %cr0
38336 +#endif
38337 +
38338 movl $(GDT_ENTRY_TSS*8), %edx
38339 ltr %dx
38340
38341 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38342 // Let's clear it again for our return.
38343 // The GDT descriptor of the Host
38344 // Points to the table after two "size" bytes
38345 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38346 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38347 // Clear "used" from type field (byte 5, bit 2)
38348 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38349 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38350 +
38351 +#ifdef CONFIG_PAX_KERNEXEC
38352 + mov %cr0, %eax
38353 + xor $X86_CR0_WP, %eax
38354 + mov %eax, %cr0
38355 +#endif
38356
38357 // Once our page table's switched, the Guest is live!
38358 // The Host fades as we run this final step.
38359 @@ -295,13 +309,12 @@ deliver_to_host:
38360 // I consulted gcc, and it gave
38361 // These instructions, which I gladly credit:
38362 leal (%edx,%ebx,8), %eax
38363 - movzwl (%eax),%edx
38364 - movl 4(%eax), %eax
38365 - xorw %ax, %ax
38366 - orl %eax, %edx
38367 + movl 4(%eax), %edx
38368 + movw (%eax), %dx
38369 // Now the address of the handler's in %edx
38370 // We call it now: its "iret" drops us home.
38371 - jmp *%edx
38372 + ljmp $__KERNEL_CS, $1f
38373 +1: jmp *%edx
38374
38375 // Every interrupt can come to us here
38376 // But we must truly tell each apart.
38377 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
38378 index 0003992..854bbce 100644
38379 --- a/drivers/md/bcache/closure.h
38380 +++ b/drivers/md/bcache/closure.h
38381 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
38382 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
38383 struct workqueue_struct *wq)
38384 {
38385 - BUG_ON(object_is_on_stack(cl));
38386 + BUG_ON(object_starts_on_stack(cl));
38387 closure_set_ip(cl);
38388 cl->fn = fn;
38389 cl->wq = wq;
38390 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38391 index 5a2c754..0fa55db 100644
38392 --- a/drivers/md/bitmap.c
38393 +++ b/drivers/md/bitmap.c
38394 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38395 chunk_kb ? "KB" : "B");
38396 if (bitmap->storage.file) {
38397 seq_printf(seq, ", file: ");
38398 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38399 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38400 }
38401
38402 seq_printf(seq, "\n");
38403 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38404 index aa04f02..2a1309e 100644
38405 --- a/drivers/md/dm-ioctl.c
38406 +++ b/drivers/md/dm-ioctl.c
38407 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38408 cmd == DM_LIST_VERSIONS_CMD)
38409 return 0;
38410
38411 - if ((cmd == DM_DEV_CREATE_CMD)) {
38412 + if (cmd == DM_DEV_CREATE_CMD) {
38413 if (!*param->name) {
38414 DMWARN("name not supplied when creating device");
38415 return -EINVAL;
38416 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38417 index 699b5be..eac0a15 100644
38418 --- a/drivers/md/dm-raid1.c
38419 +++ b/drivers/md/dm-raid1.c
38420 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38421
38422 struct mirror {
38423 struct mirror_set *ms;
38424 - atomic_t error_count;
38425 + atomic_unchecked_t error_count;
38426 unsigned long error_type;
38427 struct dm_dev *dev;
38428 sector_t offset;
38429 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38430 struct mirror *m;
38431
38432 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38433 - if (!atomic_read(&m->error_count))
38434 + if (!atomic_read_unchecked(&m->error_count))
38435 return m;
38436
38437 return NULL;
38438 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38439 * simple way to tell if a device has encountered
38440 * errors.
38441 */
38442 - atomic_inc(&m->error_count);
38443 + atomic_inc_unchecked(&m->error_count);
38444
38445 if (test_and_set_bit(error_type, &m->error_type))
38446 return;
38447 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38448 struct mirror *m = get_default_mirror(ms);
38449
38450 do {
38451 - if (likely(!atomic_read(&m->error_count)))
38452 + if (likely(!atomic_read_unchecked(&m->error_count)))
38453 return m;
38454
38455 if (m-- == ms->mirror)
38456 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
38457 {
38458 struct mirror *default_mirror = get_default_mirror(m->ms);
38459
38460 - return !atomic_read(&default_mirror->error_count);
38461 + return !atomic_read_unchecked(&default_mirror->error_count);
38462 }
38463
38464 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38465 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38466 */
38467 if (likely(region_in_sync(ms, region, 1)))
38468 m = choose_mirror(ms, bio->bi_sector);
38469 - else if (m && atomic_read(&m->error_count))
38470 + else if (m && atomic_read_unchecked(&m->error_count))
38471 m = NULL;
38472
38473 if (likely(m))
38474 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38475 }
38476
38477 ms->mirror[mirror].ms = ms;
38478 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38479 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38480 ms->mirror[mirror].error_type = 0;
38481 ms->mirror[mirror].offset = offset;
38482
38483 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
38484 */
38485 static char device_status_char(struct mirror *m)
38486 {
38487 - if (!atomic_read(&(m->error_count)))
38488 + if (!atomic_read_unchecked(&(m->error_count)))
38489 return 'A';
38490
38491 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38492 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38493 index d907ca6..cfb8384 100644
38494 --- a/drivers/md/dm-stripe.c
38495 +++ b/drivers/md/dm-stripe.c
38496 @@ -20,7 +20,7 @@ struct stripe {
38497 struct dm_dev *dev;
38498 sector_t physical_start;
38499
38500 - atomic_t error_count;
38501 + atomic_unchecked_t error_count;
38502 };
38503
38504 struct stripe_c {
38505 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38506 kfree(sc);
38507 return r;
38508 }
38509 - atomic_set(&(sc->stripe[i].error_count), 0);
38510 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38511 }
38512
38513 ti->private = sc;
38514 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38515 DMEMIT("%d ", sc->stripes);
38516 for (i = 0; i < sc->stripes; i++) {
38517 DMEMIT("%s ", sc->stripe[i].dev->name);
38518 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38519 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38520 'D' : 'A';
38521 }
38522 buffer[i] = '\0';
38523 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38524 */
38525 for (i = 0; i < sc->stripes; i++)
38526 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38527 - atomic_inc(&(sc->stripe[i].error_count));
38528 - if (atomic_read(&(sc->stripe[i].error_count)) <
38529 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38530 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38531 DM_IO_ERROR_THRESHOLD)
38532 schedule_work(&sc->trigger_event);
38533 }
38534 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38535 index 1ff252a..ee384c1 100644
38536 --- a/drivers/md/dm-table.c
38537 +++ b/drivers/md/dm-table.c
38538 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38539 if (!dev_size)
38540 return 0;
38541
38542 - if ((start >= dev_size) || (start + len > dev_size)) {
38543 + if ((start >= dev_size) || (len > dev_size - start)) {
38544 DMWARN("%s: %s too small for target: "
38545 "start=%llu, len=%llu, dev_size=%llu",
38546 dm_device_name(ti->table->md), bdevname(bdev, b),
38547 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38548 index 60bce43..9b997d0 100644
38549 --- a/drivers/md/dm-thin-metadata.c
38550 +++ b/drivers/md/dm-thin-metadata.c
38551 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38552 {
38553 pmd->info.tm = pmd->tm;
38554 pmd->info.levels = 2;
38555 - pmd->info.value_type.context = pmd->data_sm;
38556 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38557 pmd->info.value_type.size = sizeof(__le64);
38558 pmd->info.value_type.inc = data_block_inc;
38559 pmd->info.value_type.dec = data_block_dec;
38560 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38561
38562 pmd->bl_info.tm = pmd->tm;
38563 pmd->bl_info.levels = 1;
38564 - pmd->bl_info.value_type.context = pmd->data_sm;
38565 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38566 pmd->bl_info.value_type.size = sizeof(__le64);
38567 pmd->bl_info.value_type.inc = data_block_inc;
38568 pmd->bl_info.value_type.dec = data_block_dec;
38569 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38570 index d5370a9..8761bbc 100644
38571 --- a/drivers/md/dm.c
38572 +++ b/drivers/md/dm.c
38573 @@ -169,9 +169,9 @@ struct mapped_device {
38574 /*
38575 * Event handling.
38576 */
38577 - atomic_t event_nr;
38578 + atomic_unchecked_t event_nr;
38579 wait_queue_head_t eventq;
38580 - atomic_t uevent_seq;
38581 + atomic_unchecked_t uevent_seq;
38582 struct list_head uevent_list;
38583 spinlock_t uevent_lock; /* Protect access to uevent_list */
38584
38585 @@ -1877,8 +1877,8 @@ static struct mapped_device *alloc_dev(int minor)
38586 rwlock_init(&md->map_lock);
38587 atomic_set(&md->holders, 1);
38588 atomic_set(&md->open_count, 0);
38589 - atomic_set(&md->event_nr, 0);
38590 - atomic_set(&md->uevent_seq, 0);
38591 + atomic_set_unchecked(&md->event_nr, 0);
38592 + atomic_set_unchecked(&md->uevent_seq, 0);
38593 INIT_LIST_HEAD(&md->uevent_list);
38594 spin_lock_init(&md->uevent_lock);
38595
38596 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38597
38598 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38599
38600 - atomic_inc(&md->event_nr);
38601 + atomic_inc_unchecked(&md->event_nr);
38602 wake_up(&md->eventq);
38603 }
38604
38605 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38606
38607 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38608 {
38609 - return atomic_add_return(1, &md->uevent_seq);
38610 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38611 }
38612
38613 uint32_t dm_get_event_nr(struct mapped_device *md)
38614 {
38615 - return atomic_read(&md->event_nr);
38616 + return atomic_read_unchecked(&md->event_nr);
38617 }
38618
38619 int dm_wait_event(struct mapped_device *md, int event_nr)
38620 {
38621 return wait_event_interruptible(md->eventq,
38622 - (event_nr != atomic_read(&md->event_nr)));
38623 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38624 }
38625
38626 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38627 diff --git a/drivers/md/md.c b/drivers/md/md.c
38628 index 9b82377..6b6922d 100644
38629 --- a/drivers/md/md.c
38630 +++ b/drivers/md/md.c
38631 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38632 * start build, activate spare
38633 */
38634 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38635 -static atomic_t md_event_count;
38636 +static atomic_unchecked_t md_event_count;
38637 void md_new_event(struct mddev *mddev)
38638 {
38639 - atomic_inc(&md_event_count);
38640 + atomic_inc_unchecked(&md_event_count);
38641 wake_up(&md_event_waiters);
38642 }
38643 EXPORT_SYMBOL_GPL(md_new_event);
38644 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38645 */
38646 static void md_new_event_inintr(struct mddev *mddev)
38647 {
38648 - atomic_inc(&md_event_count);
38649 + atomic_inc_unchecked(&md_event_count);
38650 wake_up(&md_event_waiters);
38651 }
38652
38653 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38654 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38655 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38656 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38657 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38658 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38659
38660 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38661 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38662 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38663 else
38664 sb->resync_offset = cpu_to_le64(0);
38665
38666 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38667 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38668
38669 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38670 sb->size = cpu_to_le64(mddev->dev_sectors);
38671 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38672 static ssize_t
38673 errors_show(struct md_rdev *rdev, char *page)
38674 {
38675 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38676 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38677 }
38678
38679 static ssize_t
38680 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38681 char *e;
38682 unsigned long n = simple_strtoul(buf, &e, 10);
38683 if (*buf && (*e == 0 || *e == '\n')) {
38684 - atomic_set(&rdev->corrected_errors, n);
38685 + atomic_set_unchecked(&rdev->corrected_errors, n);
38686 return len;
38687 }
38688 return -EINVAL;
38689 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
38690 rdev->sb_loaded = 0;
38691 rdev->bb_page = NULL;
38692 atomic_set(&rdev->nr_pending, 0);
38693 - atomic_set(&rdev->read_errors, 0);
38694 - atomic_set(&rdev->corrected_errors, 0);
38695 + atomic_set_unchecked(&rdev->read_errors, 0);
38696 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38697
38698 INIT_LIST_HEAD(&rdev->same_set);
38699 init_waitqueue_head(&rdev->blocked_wait);
38700 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38701
38702 spin_unlock(&pers_lock);
38703 seq_printf(seq, "\n");
38704 - seq->poll_event = atomic_read(&md_event_count);
38705 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38706 return 0;
38707 }
38708 if (v == (void*)2) {
38709 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38710 return error;
38711
38712 seq = file->private_data;
38713 - seq->poll_event = atomic_read(&md_event_count);
38714 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38715 return error;
38716 }
38717
38718 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38719 /* always allow read */
38720 mask = POLLIN | POLLRDNORM;
38721
38722 - if (seq->poll_event != atomic_read(&md_event_count))
38723 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38724 mask |= POLLERR | POLLPRI;
38725 return mask;
38726 }
38727 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38728 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38729 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38730 (int)part_stat_read(&disk->part0, sectors[1]) -
38731 - atomic_read(&disk->sync_io);
38732 + atomic_read_unchecked(&disk->sync_io);
38733 /* sync IO will cause sync_io to increase before the disk_stats
38734 * as sync_io is counted when a request starts, and
38735 * disk_stats is counted when it completes.
38736 diff --git a/drivers/md/md.h b/drivers/md/md.h
38737 index 653f992b6..6af6c40 100644
38738 --- a/drivers/md/md.h
38739 +++ b/drivers/md/md.h
38740 @@ -94,13 +94,13 @@ struct md_rdev {
38741 * only maintained for arrays that
38742 * support hot removal
38743 */
38744 - atomic_t read_errors; /* number of consecutive read errors that
38745 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38746 * we have tried to ignore.
38747 */
38748 struct timespec last_read_error; /* monotonic time since our
38749 * last read error
38750 */
38751 - atomic_t corrected_errors; /* number of corrected read errors,
38752 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38753 * for reporting to userspace and storing
38754 * in superblock.
38755 */
38756 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38757
38758 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38759 {
38760 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38761 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38762 }
38763
38764 struct md_personality
38765 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38766 index 3e6d115..ffecdeb 100644
38767 --- a/drivers/md/persistent-data/dm-space-map.h
38768 +++ b/drivers/md/persistent-data/dm-space-map.h
38769 @@ -71,6 +71,7 @@ struct dm_space_map {
38770 dm_sm_threshold_fn fn,
38771 void *context);
38772 };
38773 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38774
38775 /*----------------------------------------------------------------*/
38776
38777 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38778 index 6e17f81..140f717 100644
38779 --- a/drivers/md/raid1.c
38780 +++ b/drivers/md/raid1.c
38781 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38782 if (r1_sync_page_io(rdev, sect, s,
38783 bio->bi_io_vec[idx].bv_page,
38784 READ) != 0)
38785 - atomic_add(s, &rdev->corrected_errors);
38786 + atomic_add_unchecked(s, &rdev->corrected_errors);
38787 }
38788 sectors -= s;
38789 sect += s;
38790 @@ -2042,7 +2042,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38791 test_bit(In_sync, &rdev->flags)) {
38792 if (r1_sync_page_io(rdev, sect, s,
38793 conf->tmppage, READ)) {
38794 - atomic_add(s, &rdev->corrected_errors);
38795 + atomic_add_unchecked(s, &rdev->corrected_errors);
38796 printk(KERN_INFO
38797 "md/raid1:%s: read error corrected "
38798 "(%d sectors at %llu on %s)\n",
38799 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38800 index d61eb7e..adfd00a 100644
38801 --- a/drivers/md/raid10.c
38802 +++ b/drivers/md/raid10.c
38803 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
38804 /* The write handler will notice the lack of
38805 * R10BIO_Uptodate and record any errors etc
38806 */
38807 - atomic_add(r10_bio->sectors,
38808 + atomic_add_unchecked(r10_bio->sectors,
38809 &conf->mirrors[d].rdev->corrected_errors);
38810
38811 /* for reconstruct, we always reschedule after a read.
38812 @@ -2292,7 +2292,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38813 {
38814 struct timespec cur_time_mon;
38815 unsigned long hours_since_last;
38816 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38817 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38818
38819 ktime_get_ts(&cur_time_mon);
38820
38821 @@ -2314,9 +2314,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38822 * overflowing the shift of read_errors by hours_since_last.
38823 */
38824 if (hours_since_last >= 8 * sizeof(read_errors))
38825 - atomic_set(&rdev->read_errors, 0);
38826 + atomic_set_unchecked(&rdev->read_errors, 0);
38827 else
38828 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38829 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38830 }
38831
38832 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38833 @@ -2370,8 +2370,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38834 return;
38835
38836 check_decay_read_errors(mddev, rdev);
38837 - atomic_inc(&rdev->read_errors);
38838 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38839 + atomic_inc_unchecked(&rdev->read_errors);
38840 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38841 char b[BDEVNAME_SIZE];
38842 bdevname(rdev->bdev, b);
38843
38844 @@ -2379,7 +2379,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38845 "md/raid10:%s: %s: Raid device exceeded "
38846 "read_error threshold [cur %d:max %d]\n",
38847 mdname(mddev), b,
38848 - atomic_read(&rdev->read_errors), max_read_errors);
38849 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38850 printk(KERN_NOTICE
38851 "md/raid10:%s: %s: Failing raid device\n",
38852 mdname(mddev), b);
38853 @@ -2534,7 +2534,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38854 sect +
38855 choose_data_offset(r10_bio, rdev)),
38856 bdevname(rdev->bdev, b));
38857 - atomic_add(s, &rdev->corrected_errors);
38858 + atomic_add_unchecked(s, &rdev->corrected_errors);
38859 }
38860
38861 rdev_dec_pending(rdev, mddev);
38862 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38863 index 05e4a10..48fbe37 100644
38864 --- a/drivers/md/raid5.c
38865 +++ b/drivers/md/raid5.c
38866 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38867 mdname(conf->mddev), STRIPE_SECTORS,
38868 (unsigned long long)s,
38869 bdevname(rdev->bdev, b));
38870 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38871 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38872 clear_bit(R5_ReadError, &sh->dev[i].flags);
38873 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38874 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38875 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38876
38877 - if (atomic_read(&rdev->read_errors))
38878 - atomic_set(&rdev->read_errors, 0);
38879 + if (atomic_read_unchecked(&rdev->read_errors))
38880 + atomic_set_unchecked(&rdev->read_errors, 0);
38881 } else {
38882 const char *bdn = bdevname(rdev->bdev, b);
38883 int retry = 0;
38884 int set_bad = 0;
38885
38886 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38887 - atomic_inc(&rdev->read_errors);
38888 + atomic_inc_unchecked(&rdev->read_errors);
38889 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38890 printk_ratelimited(
38891 KERN_WARNING
38892 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38893 mdname(conf->mddev),
38894 (unsigned long long)s,
38895 bdn);
38896 - } else if (atomic_read(&rdev->read_errors)
38897 + } else if (atomic_read_unchecked(&rdev->read_errors)
38898 > conf->max_nr_stripes)
38899 printk(KERN_WARNING
38900 "md/raid:%s: Too many read errors, failing device %s.\n",
38901 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38902 index 401ef64..836e563 100644
38903 --- a/drivers/media/dvb-core/dvbdev.c
38904 +++ b/drivers/media/dvb-core/dvbdev.c
38905 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38906 const struct dvb_device *template, void *priv, int type)
38907 {
38908 struct dvb_device *dvbdev;
38909 - struct file_operations *dvbdevfops;
38910 + file_operations_no_const *dvbdevfops;
38911 struct device *clsdev;
38912 int minor;
38913 int id;
38914 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38915 index 9b6c3bb..baeb5c7 100644
38916 --- a/drivers/media/dvb-frontends/dib3000.h
38917 +++ b/drivers/media/dvb-frontends/dib3000.h
38918 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38919 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38920 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38921 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38922 -};
38923 +} __no_const;
38924
38925 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38926 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38927 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38928 index c7a9be1..683f6f8 100644
38929 --- a/drivers/media/pci/cx88/cx88-video.c
38930 +++ b/drivers/media/pci/cx88/cx88-video.c
38931 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38932
38933 /* ------------------------------------------------------------------ */
38934
38935 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38936 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38937 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38938 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38939 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38940 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38941
38942 module_param_array(video_nr, int, NULL, 0444);
38943 module_param_array(vbi_nr, int, NULL, 0444);
38944 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38945 index d338b19..aae4f9e 100644
38946 --- a/drivers/media/platform/omap/omap_vout.c
38947 +++ b/drivers/media/platform/omap/omap_vout.c
38948 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38949 OMAP_VIDEO2,
38950 };
38951
38952 -static struct videobuf_queue_ops video_vbq_ops;
38953 /* Variables configurable through module params*/
38954 static u32 video1_numbuffers = 3;
38955 static u32 video2_numbuffers = 3;
38956 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
38957 {
38958 struct videobuf_queue *q;
38959 struct omap_vout_device *vout = NULL;
38960 + static struct videobuf_queue_ops video_vbq_ops = {
38961 + .buf_setup = omap_vout_buffer_setup,
38962 + .buf_prepare = omap_vout_buffer_prepare,
38963 + .buf_release = omap_vout_buffer_release,
38964 + .buf_queue = omap_vout_buffer_queue,
38965 + };
38966
38967 vout = video_drvdata(file);
38968 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38969 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
38970 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38971
38972 q = &vout->vbq;
38973 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38974 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38975 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38976 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38977 spin_lock_init(&vout->vbq_lock);
38978
38979 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38980 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38981 index 04e6490..2df65bf 100644
38982 --- a/drivers/media/platform/s5p-tv/mixer.h
38983 +++ b/drivers/media/platform/s5p-tv/mixer.h
38984 @@ -156,7 +156,7 @@ struct mxr_layer {
38985 /** layer index (unique identifier) */
38986 int idx;
38987 /** callbacks for layer methods */
38988 - struct mxr_layer_ops ops;
38989 + struct mxr_layer_ops *ops;
38990 /** format array */
38991 const struct mxr_format **fmt_array;
38992 /** size of format array */
38993 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38994 index b93a21f..2535195 100644
38995 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38996 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38997 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38998 {
38999 struct mxr_layer *layer;
39000 int ret;
39001 - struct mxr_layer_ops ops = {
39002 + static struct mxr_layer_ops ops = {
39003 .release = mxr_graph_layer_release,
39004 .buffer_set = mxr_graph_buffer_set,
39005 .stream_set = mxr_graph_stream_set,
39006 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
39007 index b713403..53cb5ad 100644
39008 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
39009 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
39010 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
39011 layer->update_buf = next;
39012 }
39013
39014 - layer->ops.buffer_set(layer, layer->update_buf);
39015 + layer->ops->buffer_set(layer, layer->update_buf);
39016
39017 if (done && done != layer->shadow_buf)
39018 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
39019 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
39020 index ef0efdf..8c78eb6 100644
39021 --- a/drivers/media/platform/s5p-tv/mixer_video.c
39022 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
39023 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
39024 layer->geo.src.height = layer->geo.src.full_height;
39025
39026 mxr_geometry_dump(mdev, &layer->geo);
39027 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39028 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39029 mxr_geometry_dump(mdev, &layer->geo);
39030 }
39031
39032 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
39033 layer->geo.dst.full_width = mbus_fmt.width;
39034 layer->geo.dst.full_height = mbus_fmt.height;
39035 layer->geo.dst.field = mbus_fmt.field;
39036 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39037 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39038
39039 mxr_geometry_dump(mdev, &layer->geo);
39040 }
39041 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
39042 /* set source size to highest accepted value */
39043 geo->src.full_width = max(geo->dst.full_width, pix->width);
39044 geo->src.full_height = max(geo->dst.full_height, pix->height);
39045 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39046 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39047 mxr_geometry_dump(mdev, &layer->geo);
39048 /* set cropping to total visible screen */
39049 geo->src.width = pix->width;
39050 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
39051 geo->src.x_offset = 0;
39052 geo->src.y_offset = 0;
39053 /* assure consistency of geometry */
39054 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39055 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39056 mxr_geometry_dump(mdev, &layer->geo);
39057 /* set full size to lowest possible value */
39058 geo->src.full_width = 0;
39059 geo->src.full_height = 0;
39060 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39061 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39062 mxr_geometry_dump(mdev, &layer->geo);
39063
39064 /* returning results */
39065 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
39066 target->width = s->r.width;
39067 target->height = s->r.height;
39068
39069 - layer->ops.fix_geometry(layer, stage, s->flags);
39070 + layer->ops->fix_geometry(layer, stage, s->flags);
39071
39072 /* retrieve update selection rectangle */
39073 res.left = target->x_offset;
39074 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
39075 mxr_output_get(mdev);
39076
39077 mxr_layer_update_output(layer);
39078 - layer->ops.format_set(layer);
39079 + layer->ops->format_set(layer);
39080 /* enabling layer in hardware */
39081 spin_lock_irqsave(&layer->enq_slock, flags);
39082 layer->state = MXR_LAYER_STREAMING;
39083 spin_unlock_irqrestore(&layer->enq_slock, flags);
39084
39085 - layer->ops.stream_set(layer, MXR_ENABLE);
39086 + layer->ops->stream_set(layer, MXR_ENABLE);
39087 mxr_streamer_get(mdev);
39088
39089 return 0;
39090 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
39091 spin_unlock_irqrestore(&layer->enq_slock, flags);
39092
39093 /* disabling layer in hardware */
39094 - layer->ops.stream_set(layer, MXR_DISABLE);
39095 + layer->ops->stream_set(layer, MXR_DISABLE);
39096 /* remove one streamer */
39097 mxr_streamer_put(mdev);
39098 /* allow changes in output configuration */
39099 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
39100
39101 void mxr_layer_release(struct mxr_layer *layer)
39102 {
39103 - if (layer->ops.release)
39104 - layer->ops.release(layer);
39105 + if (layer->ops->release)
39106 + layer->ops->release(layer);
39107 }
39108
39109 void mxr_base_layer_release(struct mxr_layer *layer)
39110 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
39111
39112 layer->mdev = mdev;
39113 layer->idx = idx;
39114 - layer->ops = *ops;
39115 + layer->ops = ops;
39116
39117 spin_lock_init(&layer->enq_slock);
39118 INIT_LIST_HEAD(&layer->enq_list);
39119 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39120 index 3d13a63..da31bf1 100644
39121 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39122 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39123 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
39124 {
39125 struct mxr_layer *layer;
39126 int ret;
39127 - struct mxr_layer_ops ops = {
39128 + static struct mxr_layer_ops ops = {
39129 .release = mxr_vp_layer_release,
39130 .buffer_set = mxr_vp_buffer_set,
39131 .stream_set = mxr_vp_stream_set,
39132 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
39133 index 545c04c..a14bded 100644
39134 --- a/drivers/media/radio/radio-cadet.c
39135 +++ b/drivers/media/radio/radio-cadet.c
39136 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39137 unsigned char readbuf[RDS_BUFFER];
39138 int i = 0;
39139
39140 + if (count > RDS_BUFFER)
39141 + return -EFAULT;
39142 mutex_lock(&dev->lock);
39143 if (dev->rdsstat == 0)
39144 cadet_start_rds(dev);
39145 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39146 while (i < count && dev->rdsin != dev->rdsout)
39147 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
39148
39149 - if (i && copy_to_user(data, readbuf, i))
39150 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
39151 i = -EFAULT;
39152 unlock:
39153 mutex_unlock(&dev->lock);
39154 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
39155 index 3940bb0..fb3952a 100644
39156 --- a/drivers/media/usb/dvb-usb/cxusb.c
39157 +++ b/drivers/media/usb/dvb-usb/cxusb.c
39158 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
39159
39160 struct dib0700_adapter_state {
39161 int (*set_param_save) (struct dvb_frontend *);
39162 -};
39163 +} __no_const;
39164
39165 static int dib7070_set_param_override(struct dvb_frontend *fe)
39166 {
39167 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
39168 index 6e237b6..dc25556 100644
39169 --- a/drivers/media/usb/dvb-usb/dw2102.c
39170 +++ b/drivers/media/usb/dvb-usb/dw2102.c
39171 @@ -118,7 +118,7 @@ struct su3000_state {
39172
39173 struct s6x0_state {
39174 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
39175 -};
39176 +} __no_const;
39177
39178 /* debug */
39179 static int dvb_usb_dw2102_debug;
39180 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39181 index f129551..ecf6514 100644
39182 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39183 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39184 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
39185 __u32 reserved;
39186 };
39187
39188 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39189 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39190 enum v4l2_memory memory)
39191 {
39192 void __user *up_pln;
39193 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39194 return 0;
39195 }
39196
39197 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39198 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39199 enum v4l2_memory memory)
39200 {
39201 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
39202 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
39203 put_user(kp->start_block, &up->start_block) ||
39204 put_user(kp->blocks, &up->blocks) ||
39205 put_user(tmp, &up->edid) ||
39206 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
39207 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
39208 return -EFAULT;
39209 return 0;
39210 }
39211 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
39212 index 7658586..1079260 100644
39213 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
39214 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
39215 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
39216 struct file *file, void *fh, void *p);
39217 } u;
39218 void (*debug)(const void *arg, bool write_only);
39219 -};
39220 +} __do_const;
39221 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
39222
39223 /* This control needs a priority check */
39224 #define INFO_FL_PRIO (1 << 0)
39225 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
39226 struct video_device *vfd = video_devdata(file);
39227 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
39228 bool write_only = false;
39229 - struct v4l2_ioctl_info default_info;
39230 + v4l2_ioctl_info_no_const default_info;
39231 const struct v4l2_ioctl_info *info;
39232 void *fh = file->private_data;
39233 struct v4l2_fh *vfh = NULL;
39234 @@ -2251,7 +2252,7 @@ done:
39235 }
39236
39237 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39238 - void * __user *user_ptr, void ***kernel_ptr)
39239 + void __user **user_ptr, void ***kernel_ptr)
39240 {
39241 int ret = 0;
39242
39243 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39244 ret = -EINVAL;
39245 break;
39246 }
39247 - *user_ptr = (void __user *)buf->m.planes;
39248 + *user_ptr = (void __force_user *)buf->m.planes;
39249 *kernel_ptr = (void *)&buf->m.planes;
39250 *array_size = sizeof(struct v4l2_plane) * buf->length;
39251 ret = 1;
39252 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39253 ret = -EINVAL;
39254 break;
39255 }
39256 - *user_ptr = (void __user *)ctrls->controls;
39257 + *user_ptr = (void __force_user *)ctrls->controls;
39258 *kernel_ptr = (void *)&ctrls->controls;
39259 *array_size = sizeof(struct v4l2_ext_control)
39260 * ctrls->count;
39261 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
39262 index 767ff4d..c69d259 100644
39263 --- a/drivers/message/fusion/mptbase.c
39264 +++ b/drivers/message/fusion/mptbase.c
39265 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39266 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
39267 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
39268
39269 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39270 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
39271 +#else
39272 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
39273 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
39274 +#endif
39275 +
39276 /*
39277 * Rounding UP to nearest 4-kB boundary here...
39278 */
39279 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39280 ioc->facts.GlobalCredits);
39281
39282 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
39283 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39284 + NULL, NULL);
39285 +#else
39286 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
39287 +#endif
39288 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
39289 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
39290 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
39291 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
39292 index dd239bd..689c4f7 100644
39293 --- a/drivers/message/fusion/mptsas.c
39294 +++ b/drivers/message/fusion/mptsas.c
39295 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
39296 return 0;
39297 }
39298
39299 +static inline void
39300 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39301 +{
39302 + if (phy_info->port_details) {
39303 + phy_info->port_details->rphy = rphy;
39304 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39305 + ioc->name, rphy));
39306 + }
39307 +
39308 + if (rphy) {
39309 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39310 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39311 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39312 + ioc->name, rphy, rphy->dev.release));
39313 + }
39314 +}
39315 +
39316 /* no mutex */
39317 static void
39318 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
39319 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
39320 return NULL;
39321 }
39322
39323 -static inline void
39324 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39325 -{
39326 - if (phy_info->port_details) {
39327 - phy_info->port_details->rphy = rphy;
39328 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39329 - ioc->name, rphy));
39330 - }
39331 -
39332 - if (rphy) {
39333 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39334 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39335 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39336 - ioc->name, rphy, rphy->dev.release));
39337 - }
39338 -}
39339 -
39340 static inline struct sas_port *
39341 mptsas_get_port(struct mptsas_phyinfo *phy_info)
39342 {
39343 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
39344 index 727819c..ad74694 100644
39345 --- a/drivers/message/fusion/mptscsih.c
39346 +++ b/drivers/message/fusion/mptscsih.c
39347 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
39348
39349 h = shost_priv(SChost);
39350
39351 - if (h) {
39352 - if (h->info_kbuf == NULL)
39353 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39354 - return h->info_kbuf;
39355 - h->info_kbuf[0] = '\0';
39356 + if (!h)
39357 + return NULL;
39358
39359 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39360 - h->info_kbuf[size-1] = '\0';
39361 - }
39362 + if (h->info_kbuf == NULL)
39363 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39364 + return h->info_kbuf;
39365 + h->info_kbuf[0] = '\0';
39366 +
39367 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39368 + h->info_kbuf[size-1] = '\0';
39369
39370 return h->info_kbuf;
39371 }
39372 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39373 index b7d87cd..9890039 100644
39374 --- a/drivers/message/i2o/i2o_proc.c
39375 +++ b/drivers/message/i2o/i2o_proc.c
39376 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39377 "Array Controller Device"
39378 };
39379
39380 -static char *chtostr(char *tmp, u8 *chars, int n)
39381 -{
39382 - tmp[0] = 0;
39383 - return strncat(tmp, (char *)chars, n);
39384 -}
39385 -
39386 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39387 char *group)
39388 {
39389 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39390 } *result;
39391
39392 i2o_exec_execute_ddm_table ddm_table;
39393 - char tmp[28 + 1];
39394
39395 result = kmalloc(sizeof(*result), GFP_KERNEL);
39396 if (!result)
39397 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39398
39399 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39400 seq_printf(seq, "%-#8x", ddm_table.module_id);
39401 - seq_printf(seq, "%-29s",
39402 - chtostr(tmp, ddm_table.module_name_version, 28));
39403 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39404 seq_printf(seq, "%9d ", ddm_table.data_size);
39405 seq_printf(seq, "%8d", ddm_table.code_size);
39406
39407 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39408
39409 i2o_driver_result_table *result;
39410 i2o_driver_store_table *dst;
39411 - char tmp[28 + 1];
39412
39413 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39414 if (result == NULL)
39415 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39416
39417 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39418 seq_printf(seq, "%-#8x", dst->module_id);
39419 - seq_printf(seq, "%-29s",
39420 - chtostr(tmp, dst->module_name_version, 28));
39421 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39422 + seq_printf(seq, "%-.28s", dst->module_name_version);
39423 + seq_printf(seq, "%-.8s", dst->date);
39424 seq_printf(seq, "%8d ", dst->module_size);
39425 seq_printf(seq, "%8d ", dst->mpb_size);
39426 seq_printf(seq, "0x%04x", dst->module_flags);
39427 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39428 // == (allow) 512d bytes (max)
39429 static u16 *work16 = (u16 *) work32;
39430 int token;
39431 - char tmp[16 + 1];
39432
39433 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39434
39435 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39436 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39437 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39438 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39439 - seq_printf(seq, "Vendor info : %s\n",
39440 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39441 - seq_printf(seq, "Product info : %s\n",
39442 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39443 - seq_printf(seq, "Description : %s\n",
39444 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39445 - seq_printf(seq, "Product rev. : %s\n",
39446 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39447 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39448 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39449 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39450 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39451
39452 seq_printf(seq, "Serial number : ");
39453 print_serial_number(seq, (u8 *) (work32 + 16),
39454 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39455 u8 pad[256]; // allow up to 256 byte (max) serial number
39456 } result;
39457
39458 - char tmp[24 + 1];
39459 -
39460 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39461
39462 if (token < 0) {
39463 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39464 }
39465
39466 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39467 - seq_printf(seq, "Module name : %s\n",
39468 - chtostr(tmp, result.module_name, 24));
39469 - seq_printf(seq, "Module revision : %s\n",
39470 - chtostr(tmp, result.module_rev, 8));
39471 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39472 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39473
39474 seq_printf(seq, "Serial number : ");
39475 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39476 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39477 u8 instance_number[4];
39478 } result;
39479
39480 - char tmp[64 + 1];
39481 -
39482 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39483
39484 if (token < 0) {
39485 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39486 return 0;
39487 }
39488
39489 - seq_printf(seq, "Device name : %s\n",
39490 - chtostr(tmp, result.device_name, 64));
39491 - seq_printf(seq, "Service name : %s\n",
39492 - chtostr(tmp, result.service_name, 64));
39493 - seq_printf(seq, "Physical name : %s\n",
39494 - chtostr(tmp, result.physical_location, 64));
39495 - seq_printf(seq, "Instance number : %s\n",
39496 - chtostr(tmp, result.instance_number, 4));
39497 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39498 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39499 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39500 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39501
39502 return 0;
39503 }
39504 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39505 index a8c08f3..155fe3d 100644
39506 --- a/drivers/message/i2o/iop.c
39507 +++ b/drivers/message/i2o/iop.c
39508 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39509
39510 spin_lock_irqsave(&c->context_list_lock, flags);
39511
39512 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39513 - atomic_inc(&c->context_list_counter);
39514 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39515 + atomic_inc_unchecked(&c->context_list_counter);
39516
39517 - entry->context = atomic_read(&c->context_list_counter);
39518 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39519
39520 list_add(&entry->list, &c->context_list);
39521
39522 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39523
39524 #if BITS_PER_LONG == 64
39525 spin_lock_init(&c->context_list_lock);
39526 - atomic_set(&c->context_list_counter, 0);
39527 + atomic_set_unchecked(&c->context_list_counter, 0);
39528 INIT_LIST_HEAD(&c->context_list);
39529 #endif
39530
39531 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39532 index 45ece11..8efa218 100644
39533 --- a/drivers/mfd/janz-cmodio.c
39534 +++ b/drivers/mfd/janz-cmodio.c
39535 @@ -13,6 +13,7 @@
39536
39537 #include <linux/kernel.h>
39538 #include <linux/module.h>
39539 +#include <linux/slab.h>
39540 #include <linux/init.h>
39541 #include <linux/pci.h>
39542 #include <linux/interrupt.h>
39543 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39544 index a5f9888..1c0ed56 100644
39545 --- a/drivers/mfd/twl4030-irq.c
39546 +++ b/drivers/mfd/twl4030-irq.c
39547 @@ -35,6 +35,7 @@
39548 #include <linux/of.h>
39549 #include <linux/irqdomain.h>
39550 #include <linux/i2c/twl.h>
39551 +#include <asm/pgtable.h>
39552
39553 #include "twl-core.h"
39554
39555 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39556 * Install an irq handler for each of the SIH modules;
39557 * clone dummy irq_chip since PIH can't *do* anything
39558 */
39559 - twl4030_irq_chip = dummy_irq_chip;
39560 - twl4030_irq_chip.name = "twl4030";
39561 + pax_open_kernel();
39562 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39563 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39564
39565 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39566 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39567 + pax_close_kernel();
39568
39569 for (i = irq_base; i < irq_end; i++) {
39570 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39571 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39572 index 277a8db..0e0b754 100644
39573 --- a/drivers/mfd/twl6030-irq.c
39574 +++ b/drivers/mfd/twl6030-irq.c
39575 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39576 * install an irq handler for each of the modules;
39577 * clone dummy irq_chip since PIH can't *do* anything
39578 */
39579 - twl6030_irq_chip = dummy_irq_chip;
39580 - twl6030_irq_chip.name = "twl6030";
39581 - twl6030_irq_chip.irq_set_type = NULL;
39582 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39583 + pax_open_kernel();
39584 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39585 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39586 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39587 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39588 + pax_close_kernel();
39589
39590 for (i = irq_base; i < irq_end; i++) {
39591 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39592 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39593 index f32550a..e3e52a2 100644
39594 --- a/drivers/misc/c2port/core.c
39595 +++ b/drivers/misc/c2port/core.c
39596 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39597 mutex_init(&c2dev->mutex);
39598
39599 /* Create binary file */
39600 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39601 + pax_open_kernel();
39602 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39603 + pax_close_kernel();
39604 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39605 if (unlikely(ret))
39606 goto error_device_create_bin_file;
39607 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39608 index 36f5d52..32311c3 100644
39609 --- a/drivers/misc/kgdbts.c
39610 +++ b/drivers/misc/kgdbts.c
39611 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39612 char before[BREAK_INSTR_SIZE];
39613 char after[BREAK_INSTR_SIZE];
39614
39615 - probe_kernel_read(before, (char *)kgdbts_break_test,
39616 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39617 BREAK_INSTR_SIZE);
39618 init_simple_test();
39619 ts.tst = plant_and_detach_test;
39620 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39621 /* Activate test with initial breakpoint */
39622 if (!is_early)
39623 kgdb_breakpoint();
39624 - probe_kernel_read(after, (char *)kgdbts_break_test,
39625 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39626 BREAK_INSTR_SIZE);
39627 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39628 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39629 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39630 index 4cd4a3d..b48cbc7 100644
39631 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39632 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39633 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39634 * the lid is closed. This leads to interrupts as soon as a little move
39635 * is done.
39636 */
39637 - atomic_inc(&lis3->count);
39638 + atomic_inc_unchecked(&lis3->count);
39639
39640 wake_up_interruptible(&lis3->misc_wait);
39641 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39642 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39643 if (lis3->pm_dev)
39644 pm_runtime_get_sync(lis3->pm_dev);
39645
39646 - atomic_set(&lis3->count, 0);
39647 + atomic_set_unchecked(&lis3->count, 0);
39648 return 0;
39649 }
39650
39651 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39652 add_wait_queue(&lis3->misc_wait, &wait);
39653 while (true) {
39654 set_current_state(TASK_INTERRUPTIBLE);
39655 - data = atomic_xchg(&lis3->count, 0);
39656 + data = atomic_xchg_unchecked(&lis3->count, 0);
39657 if (data)
39658 break;
39659
39660 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39661 struct lis3lv02d, miscdev);
39662
39663 poll_wait(file, &lis3->misc_wait, wait);
39664 - if (atomic_read(&lis3->count))
39665 + if (atomic_read_unchecked(&lis3->count))
39666 return POLLIN | POLLRDNORM;
39667 return 0;
39668 }
39669 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39670 index c439c82..1f20f57 100644
39671 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39672 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39673 @@ -297,7 +297,7 @@ struct lis3lv02d {
39674 struct input_polled_dev *idev; /* input device */
39675 struct platform_device *pdev; /* platform device */
39676 struct regulator_bulk_data regulators[2];
39677 - atomic_t count; /* interrupt count after last read */
39678 + atomic_unchecked_t count; /* interrupt count after last read */
39679 union axis_conversion ac; /* hw -> logical axis */
39680 int mapped_btns[3];
39681
39682 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39683 index 2f30bad..c4c13d0 100644
39684 --- a/drivers/misc/sgi-gru/gruhandles.c
39685 +++ b/drivers/misc/sgi-gru/gruhandles.c
39686 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39687 unsigned long nsec;
39688
39689 nsec = CLKS2NSEC(clks);
39690 - atomic_long_inc(&mcs_op_statistics[op].count);
39691 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39692 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39693 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39694 if (mcs_op_statistics[op].max < nsec)
39695 mcs_op_statistics[op].max = nsec;
39696 }
39697 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39698 index 797d796..ae8f01e 100644
39699 --- a/drivers/misc/sgi-gru/gruprocfs.c
39700 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39701 @@ -32,9 +32,9 @@
39702
39703 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39704
39705 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39706 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39707 {
39708 - unsigned long val = atomic_long_read(v);
39709 + unsigned long val = atomic_long_read_unchecked(v);
39710
39711 seq_printf(s, "%16lu %s\n", val, id);
39712 }
39713 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39714
39715 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39716 for (op = 0; op < mcsop_last; op++) {
39717 - count = atomic_long_read(&mcs_op_statistics[op].count);
39718 - total = atomic_long_read(&mcs_op_statistics[op].total);
39719 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39720 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39721 max = mcs_op_statistics[op].max;
39722 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39723 count ? total / count : 0, max);
39724 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39725 index 5c3ce24..4915ccb 100644
39726 --- a/drivers/misc/sgi-gru/grutables.h
39727 +++ b/drivers/misc/sgi-gru/grutables.h
39728 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39729 * GRU statistics.
39730 */
39731 struct gru_stats_s {
39732 - atomic_long_t vdata_alloc;
39733 - atomic_long_t vdata_free;
39734 - atomic_long_t gts_alloc;
39735 - atomic_long_t gts_free;
39736 - atomic_long_t gms_alloc;
39737 - atomic_long_t gms_free;
39738 - atomic_long_t gts_double_allocate;
39739 - atomic_long_t assign_context;
39740 - atomic_long_t assign_context_failed;
39741 - atomic_long_t free_context;
39742 - atomic_long_t load_user_context;
39743 - atomic_long_t load_kernel_context;
39744 - atomic_long_t lock_kernel_context;
39745 - atomic_long_t unlock_kernel_context;
39746 - atomic_long_t steal_user_context;
39747 - atomic_long_t steal_kernel_context;
39748 - atomic_long_t steal_context_failed;
39749 - atomic_long_t nopfn;
39750 - atomic_long_t asid_new;
39751 - atomic_long_t asid_next;
39752 - atomic_long_t asid_wrap;
39753 - atomic_long_t asid_reuse;
39754 - atomic_long_t intr;
39755 - atomic_long_t intr_cbr;
39756 - atomic_long_t intr_tfh;
39757 - atomic_long_t intr_spurious;
39758 - atomic_long_t intr_mm_lock_failed;
39759 - atomic_long_t call_os;
39760 - atomic_long_t call_os_wait_queue;
39761 - atomic_long_t user_flush_tlb;
39762 - atomic_long_t user_unload_context;
39763 - atomic_long_t user_exception;
39764 - atomic_long_t set_context_option;
39765 - atomic_long_t check_context_retarget_intr;
39766 - atomic_long_t check_context_unload;
39767 - atomic_long_t tlb_dropin;
39768 - atomic_long_t tlb_preload_page;
39769 - atomic_long_t tlb_dropin_fail_no_asid;
39770 - atomic_long_t tlb_dropin_fail_upm;
39771 - atomic_long_t tlb_dropin_fail_invalid;
39772 - atomic_long_t tlb_dropin_fail_range_active;
39773 - atomic_long_t tlb_dropin_fail_idle;
39774 - atomic_long_t tlb_dropin_fail_fmm;
39775 - atomic_long_t tlb_dropin_fail_no_exception;
39776 - atomic_long_t tfh_stale_on_fault;
39777 - atomic_long_t mmu_invalidate_range;
39778 - atomic_long_t mmu_invalidate_page;
39779 - atomic_long_t flush_tlb;
39780 - atomic_long_t flush_tlb_gru;
39781 - atomic_long_t flush_tlb_gru_tgh;
39782 - atomic_long_t flush_tlb_gru_zero_asid;
39783 + atomic_long_unchecked_t vdata_alloc;
39784 + atomic_long_unchecked_t vdata_free;
39785 + atomic_long_unchecked_t gts_alloc;
39786 + atomic_long_unchecked_t gts_free;
39787 + atomic_long_unchecked_t gms_alloc;
39788 + atomic_long_unchecked_t gms_free;
39789 + atomic_long_unchecked_t gts_double_allocate;
39790 + atomic_long_unchecked_t assign_context;
39791 + atomic_long_unchecked_t assign_context_failed;
39792 + atomic_long_unchecked_t free_context;
39793 + atomic_long_unchecked_t load_user_context;
39794 + atomic_long_unchecked_t load_kernel_context;
39795 + atomic_long_unchecked_t lock_kernel_context;
39796 + atomic_long_unchecked_t unlock_kernel_context;
39797 + atomic_long_unchecked_t steal_user_context;
39798 + atomic_long_unchecked_t steal_kernel_context;
39799 + atomic_long_unchecked_t steal_context_failed;
39800 + atomic_long_unchecked_t nopfn;
39801 + atomic_long_unchecked_t asid_new;
39802 + atomic_long_unchecked_t asid_next;
39803 + atomic_long_unchecked_t asid_wrap;
39804 + atomic_long_unchecked_t asid_reuse;
39805 + atomic_long_unchecked_t intr;
39806 + atomic_long_unchecked_t intr_cbr;
39807 + atomic_long_unchecked_t intr_tfh;
39808 + atomic_long_unchecked_t intr_spurious;
39809 + atomic_long_unchecked_t intr_mm_lock_failed;
39810 + atomic_long_unchecked_t call_os;
39811 + atomic_long_unchecked_t call_os_wait_queue;
39812 + atomic_long_unchecked_t user_flush_tlb;
39813 + atomic_long_unchecked_t user_unload_context;
39814 + atomic_long_unchecked_t user_exception;
39815 + atomic_long_unchecked_t set_context_option;
39816 + atomic_long_unchecked_t check_context_retarget_intr;
39817 + atomic_long_unchecked_t check_context_unload;
39818 + atomic_long_unchecked_t tlb_dropin;
39819 + atomic_long_unchecked_t tlb_preload_page;
39820 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39821 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39822 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39823 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39824 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39825 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39826 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39827 + atomic_long_unchecked_t tfh_stale_on_fault;
39828 + atomic_long_unchecked_t mmu_invalidate_range;
39829 + atomic_long_unchecked_t mmu_invalidate_page;
39830 + atomic_long_unchecked_t flush_tlb;
39831 + atomic_long_unchecked_t flush_tlb_gru;
39832 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39833 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39834
39835 - atomic_long_t copy_gpa;
39836 - atomic_long_t read_gpa;
39837 + atomic_long_unchecked_t copy_gpa;
39838 + atomic_long_unchecked_t read_gpa;
39839
39840 - atomic_long_t mesq_receive;
39841 - atomic_long_t mesq_receive_none;
39842 - atomic_long_t mesq_send;
39843 - atomic_long_t mesq_send_failed;
39844 - atomic_long_t mesq_noop;
39845 - atomic_long_t mesq_send_unexpected_error;
39846 - atomic_long_t mesq_send_lb_overflow;
39847 - atomic_long_t mesq_send_qlimit_reached;
39848 - atomic_long_t mesq_send_amo_nacked;
39849 - atomic_long_t mesq_send_put_nacked;
39850 - atomic_long_t mesq_page_overflow;
39851 - atomic_long_t mesq_qf_locked;
39852 - atomic_long_t mesq_qf_noop_not_full;
39853 - atomic_long_t mesq_qf_switch_head_failed;
39854 - atomic_long_t mesq_qf_unexpected_error;
39855 - atomic_long_t mesq_noop_unexpected_error;
39856 - atomic_long_t mesq_noop_lb_overflow;
39857 - atomic_long_t mesq_noop_qlimit_reached;
39858 - atomic_long_t mesq_noop_amo_nacked;
39859 - atomic_long_t mesq_noop_put_nacked;
39860 - atomic_long_t mesq_noop_page_overflow;
39861 + atomic_long_unchecked_t mesq_receive;
39862 + atomic_long_unchecked_t mesq_receive_none;
39863 + atomic_long_unchecked_t mesq_send;
39864 + atomic_long_unchecked_t mesq_send_failed;
39865 + atomic_long_unchecked_t mesq_noop;
39866 + atomic_long_unchecked_t mesq_send_unexpected_error;
39867 + atomic_long_unchecked_t mesq_send_lb_overflow;
39868 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39869 + atomic_long_unchecked_t mesq_send_amo_nacked;
39870 + atomic_long_unchecked_t mesq_send_put_nacked;
39871 + atomic_long_unchecked_t mesq_page_overflow;
39872 + atomic_long_unchecked_t mesq_qf_locked;
39873 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39874 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39875 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39876 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39877 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39878 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39879 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39880 + atomic_long_unchecked_t mesq_noop_put_nacked;
39881 + atomic_long_unchecked_t mesq_noop_page_overflow;
39882
39883 };
39884
39885 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39886 tghop_invalidate, mcsop_last};
39887
39888 struct mcs_op_statistic {
39889 - atomic_long_t count;
39890 - atomic_long_t total;
39891 + atomic_long_unchecked_t count;
39892 + atomic_long_unchecked_t total;
39893 unsigned long max;
39894 };
39895
39896 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39897
39898 #define STAT(id) do { \
39899 if (gru_options & OPT_STATS) \
39900 - atomic_long_inc(&gru_stats.id); \
39901 + atomic_long_inc_unchecked(&gru_stats.id); \
39902 } while (0)
39903
39904 #ifdef CONFIG_SGI_GRU_DEBUG
39905 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39906 index c862cd4..0d176fe 100644
39907 --- a/drivers/misc/sgi-xp/xp.h
39908 +++ b/drivers/misc/sgi-xp/xp.h
39909 @@ -288,7 +288,7 @@ struct xpc_interface {
39910 xpc_notify_func, void *);
39911 void (*received) (short, int, void *);
39912 enum xp_retval (*partid_to_nasids) (short, void *);
39913 -};
39914 +} __no_const;
39915
39916 extern struct xpc_interface xpc_interface;
39917
39918 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39919 index b94d5f7..7f494c5 100644
39920 --- a/drivers/misc/sgi-xp/xpc.h
39921 +++ b/drivers/misc/sgi-xp/xpc.h
39922 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39923 void (*received_payload) (struct xpc_channel *, void *);
39924 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39925 };
39926 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39927
39928 /* struct xpc_partition act_state values (for XPC HB) */
39929
39930 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39931 /* found in xpc_main.c */
39932 extern struct device *xpc_part;
39933 extern struct device *xpc_chan;
39934 -extern struct xpc_arch_operations xpc_arch_ops;
39935 +extern xpc_arch_operations_no_const xpc_arch_ops;
39936 extern int xpc_disengage_timelimit;
39937 extern int xpc_disengage_timedout;
39938 extern int xpc_activate_IRQ_rcvd;
39939 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39940 index d971817..33bdca5 100644
39941 --- a/drivers/misc/sgi-xp/xpc_main.c
39942 +++ b/drivers/misc/sgi-xp/xpc_main.c
39943 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39944 .notifier_call = xpc_system_die,
39945 };
39946
39947 -struct xpc_arch_operations xpc_arch_ops;
39948 +xpc_arch_operations_no_const xpc_arch_ops;
39949
39950 /*
39951 * Timer function to enforce the timelimit on the partition disengage.
39952 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39953
39954 if (((die_args->trapnr == X86_TRAP_MF) ||
39955 (die_args->trapnr == X86_TRAP_XF)) &&
39956 - !user_mode_vm(die_args->regs))
39957 + !user_mode(die_args->regs))
39958 xpc_die_deactivate();
39959
39960 break;
39961 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39962 index 49f04bc..65660c2 100644
39963 --- a/drivers/mmc/core/mmc_ops.c
39964 +++ b/drivers/mmc/core/mmc_ops.c
39965 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39966 void *data_buf;
39967 int is_on_stack;
39968
39969 - is_on_stack = object_is_on_stack(buf);
39970 + is_on_stack = object_starts_on_stack(buf);
39971 if (is_on_stack) {
39972 /*
39973 * dma onto stack is unsafe/nonportable, but callers to this
39974 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39975 index 0b74189..818358f 100644
39976 --- a/drivers/mmc/host/dw_mmc.h
39977 +++ b/drivers/mmc/host/dw_mmc.h
39978 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
39979 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
39980 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
39981 int (*parse_dt)(struct dw_mci *host);
39982 -};
39983 +} __do_const;
39984 #endif /* _DW_MMC_H_ */
39985 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39986 index c6f6246..60760a8 100644
39987 --- a/drivers/mmc/host/sdhci-s3c.c
39988 +++ b/drivers/mmc/host/sdhci-s3c.c
39989 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39990 * we can use overriding functions instead of default.
39991 */
39992 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39993 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39994 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39995 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39996 + pax_open_kernel();
39997 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39998 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39999 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
40000 + pax_close_kernel();
40001 }
40002
40003 /* It supports additional host capabilities if needed */
40004 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
40005 index 0c8bb6b..6f35deb 100644
40006 --- a/drivers/mtd/nand/denali.c
40007 +++ b/drivers/mtd/nand/denali.c
40008 @@ -24,6 +24,7 @@
40009 #include <linux/slab.h>
40010 #include <linux/mtd/mtd.h>
40011 #include <linux/module.h>
40012 +#include <linux/slab.h>
40013
40014 #include "denali.h"
40015
40016 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
40017 index 51b9d6a..52af9a7 100644
40018 --- a/drivers/mtd/nftlmount.c
40019 +++ b/drivers/mtd/nftlmount.c
40020 @@ -24,6 +24,7 @@
40021 #include <asm/errno.h>
40022 #include <linux/delay.h>
40023 #include <linux/slab.h>
40024 +#include <linux/sched.h>
40025 #include <linux/mtd/mtd.h>
40026 #include <linux/mtd/nand.h>
40027 #include <linux/mtd/nftl.h>
40028 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
40029 index f9d5615..99dd95f 100644
40030 --- a/drivers/mtd/sm_ftl.c
40031 +++ b/drivers/mtd/sm_ftl.c
40032 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
40033 #define SM_CIS_VENDOR_OFFSET 0x59
40034 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
40035 {
40036 - struct attribute_group *attr_group;
40037 + attribute_group_no_const *attr_group;
40038 struct attribute **attributes;
40039 struct sm_sysfs_attribute *vendor_attribute;
40040
40041 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
40042 index f975696..4597e21 100644
40043 --- a/drivers/net/bonding/bond_main.c
40044 +++ b/drivers/net/bonding/bond_main.c
40045 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
40046 return tx_queues;
40047 }
40048
40049 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
40050 +static struct rtnl_link_ops bond_link_ops = {
40051 .kind = "bond",
40052 .priv_size = sizeof(struct bonding),
40053 .setup = bond_setup,
40054 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
40055
40056 bond_destroy_debugfs();
40057
40058 - rtnl_link_unregister(&bond_link_ops);
40059 unregister_pernet_subsys(&bond_net_ops);
40060 + rtnl_link_unregister(&bond_link_ops);
40061
40062 #ifdef CONFIG_NET_POLL_CONTROLLER
40063 /*
40064 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
40065 index e1d2643..7f4133b 100644
40066 --- a/drivers/net/ethernet/8390/ax88796.c
40067 +++ b/drivers/net/ethernet/8390/ax88796.c
40068 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
40069 if (ax->plat->reg_offsets)
40070 ei_local->reg_offset = ax->plat->reg_offsets;
40071 else {
40072 + resource_size_t _mem_size = mem_size;
40073 + do_div(_mem_size, 0x18);
40074 ei_local->reg_offset = ax->reg_offsets;
40075 for (ret = 0; ret < 0x18; ret++)
40076 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
40077 + ax->reg_offsets[ret] = _mem_size * ret;
40078 }
40079
40080 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
40081 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40082 index 151675d..0139a9d 100644
40083 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40084 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40085 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
40086 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
40087 {
40088 /* RX_MODE controlling object */
40089 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
40090 + bnx2x_init_rx_mode_obj(bp);
40091
40092 /* multicast configuration controlling object */
40093 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
40094 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40095 index ce1a916..10b52b0 100644
40096 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40097 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
40098 @@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
40099 struct bnx2x *bp = netdev_priv(dev);
40100
40101 /* Use the ethtool_dump "flag" field as the dump preset index */
40102 + if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
40103 + return -EINVAL;
40104 +
40105 bp->dump_preset_idx = val->flag;
40106 return 0;
40107 }
40108 @@ -986,8 +989,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
40109 struct bnx2x *bp = netdev_priv(dev);
40110 struct dump_header dump_hdr = {0};
40111
40112 - memset(p, 0, dump->len);
40113 -
40114 /* Disable parity attentions as long as following dump may
40115 * cause false alarms by reading never written registers. We
40116 * will re-enable parity attentions right after the dump.
40117 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40118 index b4c9dea..2a9927f 100644
40119 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40120 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40121 @@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
40122 bp->min_msix_vec_cnt = 2;
40123 BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
40124
40125 + bp->dump_preset_idx = 1;
40126 +
40127 return rc;
40128 }
40129
40130 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40131 index 32a9609..0b1c53a 100644
40132 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40133 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40134 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
40135 return rc;
40136 }
40137
40138 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40139 - struct bnx2x_rx_mode_obj *o)
40140 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
40141 {
40142 if (CHIP_IS_E1x(bp)) {
40143 - o->wait_comp = bnx2x_empty_rx_mode_wait;
40144 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
40145 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
40146 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
40147 } else {
40148 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
40149 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
40150 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
40151 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
40152 }
40153 }
40154
40155 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40156 index 43c00bc..dd1d03d 100644
40157 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40158 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40159 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
40160
40161 /********************* RX MODE ****************/
40162
40163 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40164 - struct bnx2x_rx_mode_obj *o);
40165 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
40166
40167 /**
40168 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
40169 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
40170 index ff6e30e..87e8452 100644
40171 --- a/drivers/net/ethernet/broadcom/tg3.h
40172 +++ b/drivers/net/ethernet/broadcom/tg3.h
40173 @@ -147,6 +147,7 @@
40174 #define CHIPREV_ID_5750_A0 0x4000
40175 #define CHIPREV_ID_5750_A1 0x4001
40176 #define CHIPREV_ID_5750_A3 0x4003
40177 +#define CHIPREV_ID_5750_C1 0x4201
40178 #define CHIPREV_ID_5750_C2 0x4202
40179 #define CHIPREV_ID_5752_A0_HW 0x5000
40180 #define CHIPREV_ID_5752_A0 0x6000
40181 diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40182 index 71497e8..b650951 100644
40183 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40184 +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
40185 @@ -3037,7 +3037,9 @@ static void t3_io_resume(struct pci_dev *pdev)
40186 CH_ALERT(adapter, "adapter recovering, PEX ERR 0x%x\n",
40187 t3_read_reg(adapter, A_PCIE_PEX_ERR));
40188
40189 + rtnl_lock();
40190 t3_resume_ports(adapter);
40191 + rtnl_unlock();
40192 }
40193
40194 static const struct pci_error_handlers t3_err_handler = {
40195 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40196 index 8cffcdf..aadf043 100644
40197 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40198 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40199 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
40200 */
40201 struct l2t_skb_cb {
40202 arp_failure_handler_func arp_failure_handler;
40203 -};
40204 +} __no_const;
40205
40206 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
40207
40208 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
40209 index 4c83003..2a2a5b9 100644
40210 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
40211 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
40212 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40213 for (i=0; i<ETH_ALEN; i++) {
40214 tmp.addr[i] = dev->dev_addr[i];
40215 }
40216 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40217 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40218 break;
40219
40220 case DE4X5_SET_HWADDR: /* Set the hardware address */
40221 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40222 spin_lock_irqsave(&lp->lock, flags);
40223 memcpy(&statbuf, &lp->pktStats, ioc->len);
40224 spin_unlock_irqrestore(&lp->lock, flags);
40225 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
40226 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
40227 return -EFAULT;
40228 break;
40229 }
40230 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
40231 index 6e43426..1bd8365 100644
40232 --- a/drivers/net/ethernet/emulex/benet/be_main.c
40233 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
40234 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
40235
40236 if (wrapped)
40237 newacc += 65536;
40238 - ACCESS_ONCE(*acc) = newacc;
40239 + ACCESS_ONCE_RW(*acc) = newacc;
40240 }
40241
40242 void populate_erx_stats(struct be_adapter *adapter,
40243 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
40244 index 21b85fb..b49e5fc 100644
40245 --- a/drivers/net/ethernet/faraday/ftgmac100.c
40246 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
40247 @@ -31,6 +31,8 @@
40248 #include <linux/netdevice.h>
40249 #include <linux/phy.h>
40250 #include <linux/platform_device.h>
40251 +#include <linux/interrupt.h>
40252 +#include <linux/irqreturn.h>
40253 #include <net/ip.h>
40254
40255 #include "ftgmac100.h"
40256 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
40257 index a6eda8d..935d273 100644
40258 --- a/drivers/net/ethernet/faraday/ftmac100.c
40259 +++ b/drivers/net/ethernet/faraday/ftmac100.c
40260 @@ -31,6 +31,8 @@
40261 #include <linux/module.h>
40262 #include <linux/netdevice.h>
40263 #include <linux/platform_device.h>
40264 +#include <linux/interrupt.h>
40265 +#include <linux/irqreturn.h>
40266
40267 #include "ftmac100.h"
40268
40269 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40270 index 331987d..3be1135 100644
40271 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40272 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40273 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40274 }
40275
40276 /* update the base incval used to calculate frequency adjustment */
40277 - ACCESS_ONCE(adapter->base_incval) = incval;
40278 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40279 smp_mb();
40280
40281 /* need lock to prevent incorrect read while modifying cyclecounter */
40282 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40283 index fbe5363..266b4e3 100644
40284 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40285 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40286 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40287 struct __vxge_hw_fifo *fifo;
40288 struct vxge_hw_fifo_config *config;
40289 u32 txdl_size, txdl_per_memblock;
40290 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40291 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40292 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40293 + };
40294 +
40295 struct __vxge_hw_virtualpath *vpath;
40296
40297 if ((vp == NULL) || (attr == NULL)) {
40298 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40299 goto exit;
40300 }
40301
40302 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40303 -
40304 fifo->mempool =
40305 __vxge_hw_mempool_create(vpath->hldev,
40306 fifo->config->memblock_size,
40307 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40308 index 5e7fb1d..f8d1810 100644
40309 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40310 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40311 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
40312 op_mode = QLC_83XX_DEFAULT_OPMODE;
40313
40314 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
40315 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40316 + pax_open_kernel();
40317 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40318 + pax_close_kernel();
40319 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40320 } else {
40321 return -EIO;
40322 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40323 index b0c3de9..fc5857e 100644
40324 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40325 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40326 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
40327 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
40328 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
40329 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40330 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40331 + pax_open_kernel();
40332 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40333 + pax_close_kernel();
40334 } else if (priv_level == QLCNIC_PRIV_FUNC) {
40335 ahw->op_mode = QLCNIC_PRIV_FUNC;
40336 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
40337 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40338 + pax_open_kernel();
40339 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40340 + pax_close_kernel();
40341 } else if (priv_level == QLCNIC_MGMT_FUNC) {
40342 ahw->op_mode = QLCNIC_MGMT_FUNC;
40343 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40344 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40345 + pax_open_kernel();
40346 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40347 + pax_close_kernel();
40348 } else {
40349 return -EIO;
40350 }
40351 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40352 index 393f961..d343034 100644
40353 --- a/drivers/net/ethernet/realtek/r8169.c
40354 +++ b/drivers/net/ethernet/realtek/r8169.c
40355 @@ -753,22 +753,22 @@ struct rtl8169_private {
40356 struct mdio_ops {
40357 void (*write)(struct rtl8169_private *, int, int);
40358 int (*read)(struct rtl8169_private *, int);
40359 - } mdio_ops;
40360 + } __no_const mdio_ops;
40361
40362 struct pll_power_ops {
40363 void (*down)(struct rtl8169_private *);
40364 void (*up)(struct rtl8169_private *);
40365 - } pll_power_ops;
40366 + } __no_const pll_power_ops;
40367
40368 struct jumbo_ops {
40369 void (*enable)(struct rtl8169_private *);
40370 void (*disable)(struct rtl8169_private *);
40371 - } jumbo_ops;
40372 + } __no_const jumbo_ops;
40373
40374 struct csi_ops {
40375 void (*write)(struct rtl8169_private *, int, int);
40376 u32 (*read)(struct rtl8169_private *, int);
40377 - } csi_ops;
40378 + } __no_const csi_ops;
40379
40380 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40381 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40382 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40383 index 9a95abf..36df7f9 100644
40384 --- a/drivers/net/ethernet/sfc/ptp.c
40385 +++ b/drivers/net/ethernet/sfc/ptp.c
40386 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40387 (u32)((u64)ptp->start.dma_addr >> 32));
40388
40389 /* Clear flag that signals MC ready */
40390 - ACCESS_ONCE(*start) = 0;
40391 + ACCESS_ONCE_RW(*start) = 0;
40392 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40393 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40394
40395 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40396 index 50617c5..b13724c 100644
40397 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40398 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40399 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40400
40401 writel(value, ioaddr + MMC_CNTRL);
40402
40403 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40404 - MMC_CNTRL, value);
40405 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40406 +// MMC_CNTRL, value);
40407 }
40408
40409 /* To mask all all interrupts.*/
40410 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40411 index e6fe0d8..2b7d752 100644
40412 --- a/drivers/net/hyperv/hyperv_net.h
40413 +++ b/drivers/net/hyperv/hyperv_net.h
40414 @@ -101,7 +101,7 @@ struct rndis_device {
40415
40416 enum rndis_device_state state;
40417 bool link_state;
40418 - atomic_t new_req_id;
40419 + atomic_unchecked_t new_req_id;
40420
40421 spinlock_t request_lock;
40422 struct list_head req_list;
40423 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40424 index 0775f0a..d4fb316 100644
40425 --- a/drivers/net/hyperv/rndis_filter.c
40426 +++ b/drivers/net/hyperv/rndis_filter.c
40427 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40428 * template
40429 */
40430 set = &rndis_msg->msg.set_req;
40431 - set->req_id = atomic_inc_return(&dev->new_req_id);
40432 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40433
40434 /* Add to the request list */
40435 spin_lock_irqsave(&dev->request_lock, flags);
40436 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40437
40438 /* Setup the rndis set */
40439 halt = &request->request_msg.msg.halt_req;
40440 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40441 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40442
40443 /* Ignore return since this msg is optional. */
40444 rndis_filter_send_request(dev, request);
40445 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40446 index bf0d55e..82bcfbd1 100644
40447 --- a/drivers/net/ieee802154/fakehard.c
40448 +++ b/drivers/net/ieee802154/fakehard.c
40449 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40450 phy->transmit_power = 0xbf;
40451
40452 dev->netdev_ops = &fake_ops;
40453 - dev->ml_priv = &fake_mlme;
40454 + dev->ml_priv = (void *)&fake_mlme;
40455
40456 priv = netdev_priv(dev);
40457 priv->phy = phy;
40458 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40459 index 6e91931..2b0ebe7 100644
40460 --- a/drivers/net/macvlan.c
40461 +++ b/drivers/net/macvlan.c
40462 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40463 int macvlan_link_register(struct rtnl_link_ops *ops)
40464 {
40465 /* common fields */
40466 - ops->priv_size = sizeof(struct macvlan_dev);
40467 - ops->validate = macvlan_validate;
40468 - ops->maxtype = IFLA_MACVLAN_MAX;
40469 - ops->policy = macvlan_policy;
40470 - ops->changelink = macvlan_changelink;
40471 - ops->get_size = macvlan_get_size;
40472 - ops->fill_info = macvlan_fill_info;
40473 + pax_open_kernel();
40474 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40475 + *(void **)&ops->validate = macvlan_validate;
40476 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40477 + *(const void **)&ops->policy = macvlan_policy;
40478 + *(void **)&ops->changelink = macvlan_changelink;
40479 + *(void **)&ops->get_size = macvlan_get_size;
40480 + *(void **)&ops->fill_info = macvlan_fill_info;
40481 + pax_close_kernel();
40482
40483 return rtnl_link_register(ops);
40484 };
40485 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40486 return NOTIFY_DONE;
40487 }
40488
40489 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40490 +static struct notifier_block macvlan_notifier_block = {
40491 .notifier_call = macvlan_device_event,
40492 };
40493
40494 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40495 index 523d6b2..5e16aa1 100644
40496 --- a/drivers/net/macvtap.c
40497 +++ b/drivers/net/macvtap.c
40498 @@ -1110,7 +1110,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40499 return NOTIFY_DONE;
40500 }
40501
40502 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40503 +static struct notifier_block macvtap_notifier_block = {
40504 .notifier_call = macvtap_device_event,
40505 };
40506
40507 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40508 index daec9b0..6428fcb 100644
40509 --- a/drivers/net/phy/mdio-bitbang.c
40510 +++ b/drivers/net/phy/mdio-bitbang.c
40511 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40512 struct mdiobb_ctrl *ctrl = bus->priv;
40513
40514 module_put(ctrl->ops->owner);
40515 + mdiobus_unregister(bus);
40516 mdiobus_free(bus);
40517 }
40518 EXPORT_SYMBOL(free_mdio_bitbang);
40519 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40520 index 72ff14b..11d442d 100644
40521 --- a/drivers/net/ppp/ppp_generic.c
40522 +++ b/drivers/net/ppp/ppp_generic.c
40523 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40524 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40525 struct ppp_stats stats;
40526 struct ppp_comp_stats cstats;
40527 - char *vers;
40528
40529 switch (cmd) {
40530 case SIOCGPPPSTATS:
40531 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40532 break;
40533
40534 case SIOCGPPPVER:
40535 - vers = PPP_VERSION;
40536 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40537 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40538 break;
40539 err = 0;
40540 break;
40541 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
40542 index 1252d9c..80e660b 100644
40543 --- a/drivers/net/slip/slhc.c
40544 +++ b/drivers/net/slip/slhc.c
40545 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
40546 register struct tcphdr *thp;
40547 register struct iphdr *ip;
40548 register struct cstate *cs;
40549 - int len, hdrlen;
40550 + long len, hdrlen;
40551 unsigned char *cp = icp;
40552
40553 /* We've got a compressed packet; read the change byte */
40554 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40555 index b305105..8ead6df 100644
40556 --- a/drivers/net/team/team.c
40557 +++ b/drivers/net/team/team.c
40558 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
40559 return NOTIFY_DONE;
40560 }
40561
40562 -static struct notifier_block team_notifier_block __read_mostly = {
40563 +static struct notifier_block team_notifier_block = {
40564 .notifier_call = team_device_event,
40565 };
40566
40567 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40568 index 2491eb2..694b2ec 100644
40569 --- a/drivers/net/tun.c
40570 +++ b/drivers/net/tun.c
40571 @@ -1869,7 +1869,7 @@ unlock:
40572 }
40573
40574 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40575 - unsigned long arg, int ifreq_len)
40576 + unsigned long arg, size_t ifreq_len)
40577 {
40578 struct tun_file *tfile = file->private_data;
40579 struct tun_struct *tun;
40580 @@ -1881,6 +1881,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40581 int vnet_hdr_sz;
40582 int ret;
40583
40584 + if (ifreq_len > sizeof ifr)
40585 + return -EFAULT;
40586 +
40587 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40588 if (copy_from_user(&ifr, argp, ifreq_len))
40589 return -EFAULT;
40590 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40591 index cba1d46..f703766 100644
40592 --- a/drivers/net/usb/hso.c
40593 +++ b/drivers/net/usb/hso.c
40594 @@ -71,7 +71,7 @@
40595 #include <asm/byteorder.h>
40596 #include <linux/serial_core.h>
40597 #include <linux/serial.h>
40598 -
40599 +#include <asm/local.h>
40600
40601 #define MOD_AUTHOR "Option Wireless"
40602 #define MOD_DESCRIPTION "USB High Speed Option driver"
40603 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40604 struct urb *urb;
40605
40606 urb = serial->rx_urb[0];
40607 - if (serial->port.count > 0) {
40608 + if (atomic_read(&serial->port.count) > 0) {
40609 count = put_rxbuf_data(urb, serial);
40610 if (count == -1)
40611 return;
40612 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40613 DUMP1(urb->transfer_buffer, urb->actual_length);
40614
40615 /* Anyone listening? */
40616 - if (serial->port.count == 0)
40617 + if (atomic_read(&serial->port.count) == 0)
40618 return;
40619
40620 if (status == 0) {
40621 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40622 tty_port_tty_set(&serial->port, tty);
40623
40624 /* check for port already opened, if not set the termios */
40625 - serial->port.count++;
40626 - if (serial->port.count == 1) {
40627 + if (atomic_inc_return(&serial->port.count) == 1) {
40628 serial->rx_state = RX_IDLE;
40629 /* Force default termio settings */
40630 _hso_serial_set_termios(tty, NULL);
40631 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40632 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40633 if (result) {
40634 hso_stop_serial_device(serial->parent);
40635 - serial->port.count--;
40636 + atomic_dec(&serial->port.count);
40637 kref_put(&serial->parent->ref, hso_serial_ref_free);
40638 }
40639 } else {
40640 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40641
40642 /* reset the rts and dtr */
40643 /* do the actual close */
40644 - serial->port.count--;
40645 + atomic_dec(&serial->port.count);
40646
40647 - if (serial->port.count <= 0) {
40648 - serial->port.count = 0;
40649 + if (atomic_read(&serial->port.count) <= 0) {
40650 + atomic_set(&serial->port.count, 0);
40651 tty_port_tty_set(&serial->port, NULL);
40652 if (!usb_gone)
40653 hso_stop_serial_device(serial->parent);
40654 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40655
40656 /* the actual setup */
40657 spin_lock_irqsave(&serial->serial_lock, flags);
40658 - if (serial->port.count)
40659 + if (atomic_read(&serial->port.count))
40660 _hso_serial_set_termios(tty, old);
40661 else
40662 tty->termios = *old;
40663 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40664 D1("Pending read interrupt on port %d\n", i);
40665 spin_lock(&serial->serial_lock);
40666 if (serial->rx_state == RX_IDLE &&
40667 - serial->port.count > 0) {
40668 + atomic_read(&serial->port.count) > 0) {
40669 /* Setup and send a ctrl req read on
40670 * port i */
40671 if (!serial->rx_urb_filled[0]) {
40672 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
40673 /* Start all serial ports */
40674 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40675 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40676 - if (dev2ser(serial_table[i])->port.count) {
40677 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40678 result =
40679 hso_start_serial_device(serial_table[i], GFP_NOIO);
40680 hso_kick_transmit(dev2ser(serial_table[i]));
40681 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40682 index 57325f3..36b181f 100644
40683 --- a/drivers/net/vxlan.c
40684 +++ b/drivers/net/vxlan.c
40685 @@ -1579,7 +1579,7 @@ nla_put_failure:
40686 return -EMSGSIZE;
40687 }
40688
40689 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40690 +static struct rtnl_link_ops vxlan_link_ops = {
40691 .kind = "vxlan",
40692 .maxtype = IFLA_VXLAN_MAX,
40693 .policy = vxlan_policy,
40694 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40695 index 34c8a33..3261fdc 100644
40696 --- a/drivers/net/wireless/at76c50x-usb.c
40697 +++ b/drivers/net/wireless/at76c50x-usb.c
40698 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40699 }
40700
40701 /* Convert timeout from the DFU status to jiffies */
40702 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40703 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40704 {
40705 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40706 | (s->poll_timeout[1] << 8)
40707 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40708 index 8d78253..bebbb68 100644
40709 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40710 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40711 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40712 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40713 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40714
40715 - ACCESS_ONCE(ads->ds_link) = i->link;
40716 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40717 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40718 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40719
40720 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40721 ctl6 = SM(i->keytype, AR_EncrType);
40722 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40723
40724 if ((i->is_first || i->is_last) &&
40725 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40726 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40727 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40728 | set11nTries(i->rates, 1)
40729 | set11nTries(i->rates, 2)
40730 | set11nTries(i->rates, 3)
40731 | (i->dur_update ? AR_DurUpdateEna : 0)
40732 | SM(0, AR_BurstDur);
40733
40734 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40735 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40736 | set11nRate(i->rates, 1)
40737 | set11nRate(i->rates, 2)
40738 | set11nRate(i->rates, 3);
40739 } else {
40740 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40741 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40742 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40743 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40744 }
40745
40746 if (!i->is_first) {
40747 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40748 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40749 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40750 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40751 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40752 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40753 return;
40754 }
40755
40756 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40757 break;
40758 }
40759
40760 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40761 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40762 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40763 | SM(i->txpower, AR_XmitPower)
40764 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40765 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40766 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40767 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40768
40769 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40770 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40771 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40772 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40773
40774 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40775 return;
40776
40777 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40778 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40779 | set11nPktDurRTSCTS(i->rates, 1);
40780
40781 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40782 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40783 | set11nPktDurRTSCTS(i->rates, 3);
40784
40785 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40786 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40787 | set11nRateFlags(i->rates, 1)
40788 | set11nRateFlags(i->rates, 2)
40789 | set11nRateFlags(i->rates, 3)
40790 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40791 index 301bf72..3f5654f 100644
40792 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40793 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40794 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40795 (i->qcu << AR_TxQcuNum_S) | desc_len;
40796
40797 checksum += val;
40798 - ACCESS_ONCE(ads->info) = val;
40799 + ACCESS_ONCE_RW(ads->info) = val;
40800
40801 checksum += i->link;
40802 - ACCESS_ONCE(ads->link) = i->link;
40803 + ACCESS_ONCE_RW(ads->link) = i->link;
40804
40805 checksum += i->buf_addr[0];
40806 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40807 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40808 checksum += i->buf_addr[1];
40809 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40810 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40811 checksum += i->buf_addr[2];
40812 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40813 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40814 checksum += i->buf_addr[3];
40815 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40816 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40817
40818 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40819 - ACCESS_ONCE(ads->ctl3) = val;
40820 + ACCESS_ONCE_RW(ads->ctl3) = val;
40821 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40822 - ACCESS_ONCE(ads->ctl5) = val;
40823 + ACCESS_ONCE_RW(ads->ctl5) = val;
40824 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40825 - ACCESS_ONCE(ads->ctl7) = val;
40826 + ACCESS_ONCE_RW(ads->ctl7) = val;
40827 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40828 - ACCESS_ONCE(ads->ctl9) = val;
40829 + ACCESS_ONCE_RW(ads->ctl9) = val;
40830
40831 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40832 - ACCESS_ONCE(ads->ctl10) = checksum;
40833 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40834
40835 if (i->is_first || i->is_last) {
40836 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40837 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40838 | set11nTries(i->rates, 1)
40839 | set11nTries(i->rates, 2)
40840 | set11nTries(i->rates, 3)
40841 | (i->dur_update ? AR_DurUpdateEna : 0)
40842 | SM(0, AR_BurstDur);
40843
40844 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40845 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40846 | set11nRate(i->rates, 1)
40847 | set11nRate(i->rates, 2)
40848 | set11nRate(i->rates, 3);
40849 } else {
40850 - ACCESS_ONCE(ads->ctl13) = 0;
40851 - ACCESS_ONCE(ads->ctl14) = 0;
40852 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40853 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40854 }
40855
40856 ads->ctl20 = 0;
40857 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40858
40859 ctl17 = SM(i->keytype, AR_EncrType);
40860 if (!i->is_first) {
40861 - ACCESS_ONCE(ads->ctl11) = 0;
40862 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40863 - ACCESS_ONCE(ads->ctl15) = 0;
40864 - ACCESS_ONCE(ads->ctl16) = 0;
40865 - ACCESS_ONCE(ads->ctl17) = ctl17;
40866 - ACCESS_ONCE(ads->ctl18) = 0;
40867 - ACCESS_ONCE(ads->ctl19) = 0;
40868 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40869 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40870 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40871 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40872 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40873 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40874 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40875 return;
40876 }
40877
40878 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40879 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40880 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40881 | SM(i->txpower, AR_XmitPower)
40882 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40883 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40884 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40885 ctl12 |= SM(val, AR_PAPRDChainMask);
40886
40887 - ACCESS_ONCE(ads->ctl12) = ctl12;
40888 - ACCESS_ONCE(ads->ctl17) = ctl17;
40889 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40890 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40891
40892 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40893 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40894 | set11nPktDurRTSCTS(i->rates, 1);
40895
40896 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40897 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40898 | set11nPktDurRTSCTS(i->rates, 3);
40899
40900 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40901 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40902 | set11nRateFlags(i->rates, 1)
40903 | set11nRateFlags(i->rates, 2)
40904 | set11nRateFlags(i->rates, 3)
40905 | SM(i->rtscts_rate, AR_RTSCTSRate);
40906
40907 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40908 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40909 }
40910
40911 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40912 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40913 index ae30343..a117806 100644
40914 --- a/drivers/net/wireless/ath/ath9k/hw.h
40915 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40916 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
40917
40918 /* ANI */
40919 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40920 -};
40921 +} __no_const;
40922
40923 /**
40924 * struct ath_spec_scan - parameters for Atheros spectral scan
40925 @@ -721,7 +721,7 @@ struct ath_hw_ops {
40926 struct ath_spec_scan *param);
40927 void (*spectral_scan_trigger)(struct ath_hw *ah);
40928 void (*spectral_scan_wait)(struct ath_hw *ah);
40929 -};
40930 +} __no_const;
40931
40932 struct ath_nf_limits {
40933 s16 max;
40934 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40935 index b37a582..680835d 100644
40936 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40937 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40938 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40939 */
40940 if (il3945_mod_params.disable_hw_scan) {
40941 D_INFO("Disabling hw_scan\n");
40942 - il3945_mac_ops.hw_scan = NULL;
40943 + pax_open_kernel();
40944 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40945 + pax_close_kernel();
40946 }
40947
40948 D_INFO("*** LOAD DRIVER ***\n");
40949 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40950 index d532948..e0d8bb1 100644
40951 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40952 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40953 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40954 {
40955 struct iwl_priv *priv = file->private_data;
40956 char buf[64];
40957 - int buf_size;
40958 + size_t buf_size;
40959 u32 offset, len;
40960
40961 memset(buf, 0, sizeof(buf));
40962 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40963 struct iwl_priv *priv = file->private_data;
40964
40965 char buf[8];
40966 - int buf_size;
40967 + size_t buf_size;
40968 u32 reset_flag;
40969
40970 memset(buf, 0, sizeof(buf));
40971 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40972 {
40973 struct iwl_priv *priv = file->private_data;
40974 char buf[8];
40975 - int buf_size;
40976 + size_t buf_size;
40977 int ht40;
40978
40979 memset(buf, 0, sizeof(buf));
40980 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40981 {
40982 struct iwl_priv *priv = file->private_data;
40983 char buf[8];
40984 - int buf_size;
40985 + size_t buf_size;
40986 int value;
40987
40988 memset(buf, 0, sizeof(buf));
40989 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
40990 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
40991 DEBUGFS_READ_FILE_OPS(current_sleep_command);
40992
40993 -static const char *fmt_value = " %-30s %10u\n";
40994 -static const char *fmt_hex = " %-30s 0x%02X\n";
40995 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
40996 -static const char *fmt_header =
40997 +static const char fmt_value[] = " %-30s %10u\n";
40998 +static const char fmt_hex[] = " %-30s 0x%02X\n";
40999 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
41000 +static const char fmt_header[] =
41001 "%-32s current cumulative delta max\n";
41002
41003 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
41004 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
41005 {
41006 struct iwl_priv *priv = file->private_data;
41007 char buf[8];
41008 - int buf_size;
41009 + size_t buf_size;
41010 int clear;
41011
41012 memset(buf, 0, sizeof(buf));
41013 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
41014 {
41015 struct iwl_priv *priv = file->private_data;
41016 char buf[8];
41017 - int buf_size;
41018 + size_t buf_size;
41019 int trace;
41020
41021 memset(buf, 0, sizeof(buf));
41022 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
41023 {
41024 struct iwl_priv *priv = file->private_data;
41025 char buf[8];
41026 - int buf_size;
41027 + size_t buf_size;
41028 int missed;
41029
41030 memset(buf, 0, sizeof(buf));
41031 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
41032
41033 struct iwl_priv *priv = file->private_data;
41034 char buf[8];
41035 - int buf_size;
41036 + size_t buf_size;
41037 int plcp;
41038
41039 memset(buf, 0, sizeof(buf));
41040 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
41041
41042 struct iwl_priv *priv = file->private_data;
41043 char buf[8];
41044 - int buf_size;
41045 + size_t buf_size;
41046 int flush;
41047
41048 memset(buf, 0, sizeof(buf));
41049 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
41050
41051 struct iwl_priv *priv = file->private_data;
41052 char buf[8];
41053 - int buf_size;
41054 + size_t buf_size;
41055 int rts;
41056
41057 if (!priv->cfg->ht_params)
41058 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
41059 {
41060 struct iwl_priv *priv = file->private_data;
41061 char buf[8];
41062 - int buf_size;
41063 + size_t buf_size;
41064
41065 memset(buf, 0, sizeof(buf));
41066 buf_size = min(count, sizeof(buf) - 1);
41067 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
41068 struct iwl_priv *priv = file->private_data;
41069 u32 event_log_flag;
41070 char buf[8];
41071 - int buf_size;
41072 + size_t buf_size;
41073
41074 /* check that the interface is up */
41075 if (!iwl_is_ready(priv))
41076 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
41077 struct iwl_priv *priv = file->private_data;
41078 char buf[8];
41079 u32 calib_disabled;
41080 - int buf_size;
41081 + size_t buf_size;
41082
41083 memset(buf, 0, sizeof(buf));
41084 buf_size = min(count, sizeof(buf) - 1);
41085 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
41086 index 50ba0a4..29424e7 100644
41087 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
41088 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
41089 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
41090 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
41091
41092 char buf[8];
41093 - int buf_size;
41094 + size_t buf_size;
41095 u32 reset_flag;
41096
41097 memset(buf, 0, sizeof(buf));
41098 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
41099 {
41100 struct iwl_trans *trans = file->private_data;
41101 char buf[8];
41102 - int buf_size;
41103 + size_t buf_size;
41104 int csr;
41105
41106 memset(buf, 0, sizeof(buf));
41107 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
41108 index cb34c78..9fec0dc 100644
41109 --- a/drivers/net/wireless/mac80211_hwsim.c
41110 +++ b/drivers/net/wireless/mac80211_hwsim.c
41111 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
41112
41113 if (channels > 1) {
41114 hwsim_if_comb.num_different_channels = channels;
41115 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41116 - mac80211_hwsim_ops.cancel_hw_scan =
41117 - mac80211_hwsim_cancel_hw_scan;
41118 - mac80211_hwsim_ops.sw_scan_start = NULL;
41119 - mac80211_hwsim_ops.sw_scan_complete = NULL;
41120 - mac80211_hwsim_ops.remain_on_channel =
41121 - mac80211_hwsim_roc;
41122 - mac80211_hwsim_ops.cancel_remain_on_channel =
41123 - mac80211_hwsim_croc;
41124 - mac80211_hwsim_ops.add_chanctx =
41125 - mac80211_hwsim_add_chanctx;
41126 - mac80211_hwsim_ops.remove_chanctx =
41127 - mac80211_hwsim_remove_chanctx;
41128 - mac80211_hwsim_ops.change_chanctx =
41129 - mac80211_hwsim_change_chanctx;
41130 - mac80211_hwsim_ops.assign_vif_chanctx =
41131 - mac80211_hwsim_assign_vif_chanctx;
41132 - mac80211_hwsim_ops.unassign_vif_chanctx =
41133 - mac80211_hwsim_unassign_vif_chanctx;
41134 + pax_open_kernel();
41135 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41136 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
41137 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
41138 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
41139 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
41140 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
41141 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
41142 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
41143 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
41144 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
41145 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
41146 + pax_close_kernel();
41147 }
41148
41149 spin_lock_init(&hwsim_radio_lock);
41150 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
41151 index 8169a85..7fa3b47 100644
41152 --- a/drivers/net/wireless/rndis_wlan.c
41153 +++ b/drivers/net/wireless/rndis_wlan.c
41154 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
41155
41156 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
41157
41158 - if (rts_threshold < 0 || rts_threshold > 2347)
41159 + if (rts_threshold > 2347)
41160 rts_threshold = 2347;
41161
41162 tmp = cpu_to_le32(rts_threshold);
41163 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
41164 index 7510723..5ba37f5 100644
41165 --- a/drivers/net/wireless/rt2x00/rt2x00.h
41166 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
41167 @@ -386,7 +386,7 @@ struct rt2x00_intf {
41168 * for hardware which doesn't support hardware
41169 * sequence counting.
41170 */
41171 - atomic_t seqno;
41172 + atomic_unchecked_t seqno;
41173 };
41174
41175 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
41176 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
41177 index 2c12311..7b77f24 100644
41178 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
41179 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
41180 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
41181 * sequence counter given by mac80211.
41182 */
41183 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
41184 - seqno = atomic_add_return(0x10, &intf->seqno);
41185 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
41186 else
41187 - seqno = atomic_read(&intf->seqno);
41188 + seqno = atomic_read_unchecked(&intf->seqno);
41189
41190 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
41191 hdr->seq_ctrl |= cpu_to_le16(seqno);
41192 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
41193 index e2b3d9c..67a5184 100644
41194 --- a/drivers/net/wireless/ti/wl1251/sdio.c
41195 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
41196 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
41197
41198 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
41199
41200 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41201 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41202 + pax_open_kernel();
41203 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41204 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41205 + pax_close_kernel();
41206
41207 wl1251_info("using dedicated interrupt line");
41208 } else {
41209 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41210 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41211 + pax_open_kernel();
41212 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41213 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41214 + pax_close_kernel();
41215
41216 wl1251_info("using SDIO interrupt");
41217 }
41218 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
41219 index 1c627da..69f7d17 100644
41220 --- a/drivers/net/wireless/ti/wl12xx/main.c
41221 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41222 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41223 sizeof(wl->conf.mem));
41224
41225 /* read data preparation is only needed by wl127x */
41226 - wl->ops->prepare_read = wl127x_prepare_read;
41227 + pax_open_kernel();
41228 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41229 + pax_close_kernel();
41230
41231 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41232 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41233 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41234 sizeof(wl->conf.mem));
41235
41236 /* read data preparation is only needed by wl127x */
41237 - wl->ops->prepare_read = wl127x_prepare_read;
41238 + pax_open_kernel();
41239 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41240 + pax_close_kernel();
41241
41242 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41243 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41244 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41245 index 9fa692d..b31fee0 100644
41246 --- a/drivers/net/wireless/ti/wl18xx/main.c
41247 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41248 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41249 }
41250
41251 if (!checksum_param) {
41252 - wl18xx_ops.set_rx_csum = NULL;
41253 - wl18xx_ops.init_vif = NULL;
41254 + pax_open_kernel();
41255 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41256 + *(void **)&wl18xx_ops.init_vif = NULL;
41257 + pax_close_kernel();
41258 }
41259
41260 /* Enable 11a Band only if we have 5G antennas */
41261 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41262 index 7ef0b4a..ff65c28 100644
41263 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41264 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41265 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
41266 {
41267 struct zd_usb *usb = urb->context;
41268 struct zd_usb_interrupt *intr = &usb->intr;
41269 - int len;
41270 + unsigned int len;
41271 u16 int_num;
41272
41273 ZD_ASSERT(in_interrupt());
41274 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41275 index d93b2b6..ae50401 100644
41276 --- a/drivers/oprofile/buffer_sync.c
41277 +++ b/drivers/oprofile/buffer_sync.c
41278 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41279 if (cookie == NO_COOKIE)
41280 offset = pc;
41281 if (cookie == INVALID_COOKIE) {
41282 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41283 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41284 offset = pc;
41285 }
41286 if (cookie != last_cookie) {
41287 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41288 /* add userspace sample */
41289
41290 if (!mm) {
41291 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41292 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41293 return 0;
41294 }
41295
41296 cookie = lookup_dcookie(mm, s->eip, &offset);
41297
41298 if (cookie == INVALID_COOKIE) {
41299 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41300 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41301 return 0;
41302 }
41303
41304 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41305 /* ignore backtraces if failed to add a sample */
41306 if (state == sb_bt_start) {
41307 state = sb_bt_ignore;
41308 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41309 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41310 }
41311 }
41312 release_mm(mm);
41313 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41314 index c0cc4e7..44d4e54 100644
41315 --- a/drivers/oprofile/event_buffer.c
41316 +++ b/drivers/oprofile/event_buffer.c
41317 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41318 }
41319
41320 if (buffer_pos == buffer_size) {
41321 - atomic_inc(&oprofile_stats.event_lost_overflow);
41322 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41323 return;
41324 }
41325
41326 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41327 index ed2c3ec..deda85a 100644
41328 --- a/drivers/oprofile/oprof.c
41329 +++ b/drivers/oprofile/oprof.c
41330 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41331 if (oprofile_ops.switch_events())
41332 return;
41333
41334 - atomic_inc(&oprofile_stats.multiplex_counter);
41335 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41336 start_switch_worker();
41337 }
41338
41339 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41340 index 84a208d..d61b0a1 100644
41341 --- a/drivers/oprofile/oprofile_files.c
41342 +++ b/drivers/oprofile/oprofile_files.c
41343 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41344
41345 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41346
41347 -static ssize_t timeout_read(struct file *file, char __user *buf,
41348 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41349 size_t count, loff_t *offset)
41350 {
41351 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41352 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41353 index 917d28e..d62d981 100644
41354 --- a/drivers/oprofile/oprofile_stats.c
41355 +++ b/drivers/oprofile/oprofile_stats.c
41356 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41357 cpu_buf->sample_invalid_eip = 0;
41358 }
41359
41360 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41361 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41362 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41363 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41364 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41365 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41366 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41367 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41368 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41369 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41370 }
41371
41372
41373 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41374 index 38b6fc0..b5cbfce 100644
41375 --- a/drivers/oprofile/oprofile_stats.h
41376 +++ b/drivers/oprofile/oprofile_stats.h
41377 @@ -13,11 +13,11 @@
41378 #include <linux/atomic.h>
41379
41380 struct oprofile_stat_struct {
41381 - atomic_t sample_lost_no_mm;
41382 - atomic_t sample_lost_no_mapping;
41383 - atomic_t bt_lost_no_mapping;
41384 - atomic_t event_lost_overflow;
41385 - atomic_t multiplex_counter;
41386 + atomic_unchecked_t sample_lost_no_mm;
41387 + atomic_unchecked_t sample_lost_no_mapping;
41388 + atomic_unchecked_t bt_lost_no_mapping;
41389 + atomic_unchecked_t event_lost_overflow;
41390 + atomic_unchecked_t multiplex_counter;
41391 };
41392
41393 extern struct oprofile_stat_struct oprofile_stats;
41394 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41395 index 7c12d9c..558bf3bb 100644
41396 --- a/drivers/oprofile/oprofilefs.c
41397 +++ b/drivers/oprofile/oprofilefs.c
41398 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
41399
41400
41401 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41402 - char const *name, atomic_t *val)
41403 + char const *name, atomic_unchecked_t *val)
41404 {
41405 return __oprofilefs_create_file(sb, root, name,
41406 &atomic_ro_fops, 0444, val);
41407 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41408 index 93404f7..4a313d8 100644
41409 --- a/drivers/oprofile/timer_int.c
41410 +++ b/drivers/oprofile/timer_int.c
41411 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41412 return NOTIFY_OK;
41413 }
41414
41415 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41416 +static struct notifier_block oprofile_cpu_notifier = {
41417 .notifier_call = oprofile_cpu_notify,
41418 };
41419
41420 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41421 index 92ed045..62d39bd7 100644
41422 --- a/drivers/parport/procfs.c
41423 +++ b/drivers/parport/procfs.c
41424 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41425
41426 *ppos += len;
41427
41428 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41429 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41430 }
41431
41432 #ifdef CONFIG_PARPORT_1284
41433 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41434
41435 *ppos += len;
41436
41437 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41438 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41439 }
41440 #endif /* IEEE1284.3 support. */
41441
41442 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41443 index c35e8ad..fc33beb 100644
41444 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41445 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41446 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41447 goto init_cleanup;
41448 }
41449
41450 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41451 + pax_open_kernel();
41452 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41453 + pax_close_kernel();
41454 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41455
41456 return retval;
41457 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41458 index a6a71c4..c91097b 100644
41459 --- a/drivers/pci/hotplug/cpcihp_generic.c
41460 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41461 @@ -73,7 +73,6 @@ static u16 port;
41462 static unsigned int enum_bit;
41463 static u8 enum_mask;
41464
41465 -static struct cpci_hp_controller_ops generic_hpc_ops;
41466 static struct cpci_hp_controller generic_hpc;
41467
41468 static int __init validate_parameters(void)
41469 @@ -139,6 +138,10 @@ static int query_enum(void)
41470 return ((value & enum_mask) == enum_mask);
41471 }
41472
41473 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41474 + .query_enum = query_enum,
41475 +};
41476 +
41477 static int __init cpcihp_generic_init(void)
41478 {
41479 int status;
41480 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41481 pci_dev_put(dev);
41482
41483 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41484 - generic_hpc_ops.query_enum = query_enum;
41485 generic_hpc.ops = &generic_hpc_ops;
41486
41487 status = cpci_hp_register_controller(&generic_hpc);
41488 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41489 index 449b4bb..257e2e8 100644
41490 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41491 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41492 @@ -59,7 +59,6 @@
41493 /* local variables */
41494 static bool debug;
41495 static bool poll;
41496 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41497 static struct cpci_hp_controller zt5550_hpc;
41498
41499 /* Primary cPCI bus bridge device */
41500 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41501 return 0;
41502 }
41503
41504 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41505 + .query_enum = zt5550_hc_query_enum,
41506 +};
41507 +
41508 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41509 {
41510 int status;
41511 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41512 dbg("returned from zt5550_hc_config");
41513
41514 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41515 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41516 zt5550_hpc.ops = &zt5550_hpc_ops;
41517 if(!poll) {
41518 zt5550_hpc.irq = hc_dev->irq;
41519 zt5550_hpc.irq_flags = IRQF_SHARED;
41520 zt5550_hpc.dev_id = hc_dev;
41521
41522 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41523 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41524 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41525 + pax_open_kernel();
41526 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41527 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41528 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41529 + pax_open_kernel();
41530 } else {
41531 info("using ENUM# polling mode");
41532 }
41533 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41534 index 76ba8a1..20ca857 100644
41535 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41536 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41537 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41538
41539 void compaq_nvram_init (void __iomem *rom_start)
41540 {
41541 +
41542 +#ifndef CONFIG_PAX_KERNEXEC
41543 if (rom_start) {
41544 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41545 }
41546 +#endif
41547 +
41548 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41549
41550 /* initialize our int15 lock */
41551 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41552 index ec20f74..c1d961e 100644
41553 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41554 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41555 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41556 return -EINVAL;
41557 }
41558
41559 - slot->ops->owner = owner;
41560 - slot->ops->mod_name = mod_name;
41561 + pax_open_kernel();
41562 + *(struct module **)&slot->ops->owner = owner;
41563 + *(const char **)&slot->ops->mod_name = mod_name;
41564 + pax_close_kernel();
41565
41566 mutex_lock(&pci_hp_mutex);
41567 /*
41568 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41569 index 7d72c5e..edce02c 100644
41570 --- a/drivers/pci/hotplug/pciehp_core.c
41571 +++ b/drivers/pci/hotplug/pciehp_core.c
41572 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41573 struct slot *slot = ctrl->slot;
41574 struct hotplug_slot *hotplug = NULL;
41575 struct hotplug_slot_info *info = NULL;
41576 - struct hotplug_slot_ops *ops = NULL;
41577 + hotplug_slot_ops_no_const *ops = NULL;
41578 char name[SLOT_NAME_SIZE];
41579 int retval = -ENOMEM;
41580
41581 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41582 index 5b4a9d9..cd5ac1f 100644
41583 --- a/drivers/pci/pci-sysfs.c
41584 +++ b/drivers/pci/pci-sysfs.c
41585 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41586 {
41587 /* allocate attribute structure, piggyback attribute name */
41588 int name_len = write_combine ? 13 : 10;
41589 - struct bin_attribute *res_attr;
41590 + bin_attribute_no_const *res_attr;
41591 int retval;
41592
41593 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41594 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41595 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41596 {
41597 int retval;
41598 - struct bin_attribute *attr;
41599 + bin_attribute_no_const *attr;
41600
41601 /* If the device has VPD, try to expose it in sysfs. */
41602 if (dev->vpd) {
41603 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41604 {
41605 int retval;
41606 int rom_size = 0;
41607 - struct bin_attribute *attr;
41608 + bin_attribute_no_const *attr;
41609
41610 if (!sysfs_initialized)
41611 return -EACCES;
41612 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41613 index d1182c4..2a138ec 100644
41614 --- a/drivers/pci/pci.h
41615 +++ b/drivers/pci/pci.h
41616 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
41617 struct pci_vpd {
41618 unsigned int len;
41619 const struct pci_vpd_ops *ops;
41620 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41621 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41622 };
41623
41624 int pci_vpd_pci22_init(struct pci_dev *dev);
41625 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41626 index d320df6..ca9a8f6 100644
41627 --- a/drivers/pci/pcie/aspm.c
41628 +++ b/drivers/pci/pcie/aspm.c
41629 @@ -27,9 +27,9 @@
41630 #define MODULE_PARAM_PREFIX "pcie_aspm."
41631
41632 /* Note: those are not register definitions */
41633 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41634 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41635 -#define ASPM_STATE_L1 (4) /* L1 state */
41636 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41637 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41638 +#define ASPM_STATE_L1 (4U) /* L1 state */
41639 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41640 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41641
41642 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41643 index ea37072..10e58e56 100644
41644 --- a/drivers/pci/probe.c
41645 +++ b/drivers/pci/probe.c
41646 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41647 struct pci_bus_region region;
41648 bool bar_too_big = false, bar_disabled = false;
41649
41650 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41651 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41652
41653 /* No printks while decoding is disabled! */
41654 if (!dev->mmio_always_on) {
41655 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41656 index 0812608..b04018c4 100644
41657 --- a/drivers/pci/proc.c
41658 +++ b/drivers/pci/proc.c
41659 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41660 static int __init pci_proc_init(void)
41661 {
41662 struct pci_dev *dev = NULL;
41663 +
41664 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41665 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41666 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41667 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41668 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41669 +#endif
41670 +#else
41671 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41672 +#endif
41673 proc_create("devices", 0, proc_bus_pci_dir,
41674 &proc_bus_pci_dev_operations);
41675 proc_initialized = 1;
41676 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41677 index 3e5b4497..dcdfb70 100644
41678 --- a/drivers/platform/x86/chromeos_laptop.c
41679 +++ b/drivers/platform/x86/chromeos_laptop.c
41680 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41681 return 0;
41682 }
41683
41684 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41685 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41686 {
41687 .ident = "Samsung Series 5 550 - Touchpad",
41688 .matches = {
41689 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41690 index 6b22938..bc9700e 100644
41691 --- a/drivers/platform/x86/msi-laptop.c
41692 +++ b/drivers/platform/x86/msi-laptop.c
41693 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41694
41695 if (!quirks->ec_read_only) {
41696 /* allow userland write sysfs file */
41697 - dev_attr_bluetooth.store = store_bluetooth;
41698 - dev_attr_wlan.store = store_wlan;
41699 - dev_attr_threeg.store = store_threeg;
41700 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41701 - dev_attr_wlan.attr.mode |= S_IWUSR;
41702 - dev_attr_threeg.attr.mode |= S_IWUSR;
41703 + pax_open_kernel();
41704 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41705 + *(void **)&dev_attr_wlan.store = store_wlan;
41706 + *(void **)&dev_attr_threeg.store = store_threeg;
41707 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41708 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41709 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41710 + pax_close_kernel();
41711 }
41712
41713 /* disable hardware control by fn key */
41714 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41715 index 2ac045f..39c443d 100644
41716 --- a/drivers/platform/x86/sony-laptop.c
41717 +++ b/drivers/platform/x86/sony-laptop.c
41718 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41719 }
41720
41721 /* High speed charging function */
41722 -static struct device_attribute *hsc_handle;
41723 +static device_attribute_no_const *hsc_handle;
41724
41725 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41726 struct device_attribute *attr,
41727 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41728 index 54d31c0..3f896d3 100644
41729 --- a/drivers/platform/x86/thinkpad_acpi.c
41730 +++ b/drivers/platform/x86/thinkpad_acpi.c
41731 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41732 return 0;
41733 }
41734
41735 -void static hotkey_mask_warn_incomplete_mask(void)
41736 +static void hotkey_mask_warn_incomplete_mask(void)
41737 {
41738 /* log only what the user can fix... */
41739 const u32 wantedmask = hotkey_driver_mask &
41740 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41741 }
41742 }
41743
41744 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41745 - struct tp_nvram_state *newn,
41746 - const u32 event_mask)
41747 -{
41748 -
41749 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41750 do { \
41751 if ((event_mask & (1 << __scancode)) && \
41752 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41753 tpacpi_hotkey_send_key(__scancode); \
41754 } while (0)
41755
41756 - void issue_volchange(const unsigned int oldvol,
41757 - const unsigned int newvol)
41758 - {
41759 - unsigned int i = oldvol;
41760 +static void issue_volchange(const unsigned int oldvol,
41761 + const unsigned int newvol,
41762 + const u32 event_mask)
41763 +{
41764 + unsigned int i = oldvol;
41765
41766 - while (i > newvol) {
41767 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41768 - i--;
41769 - }
41770 - while (i < newvol) {
41771 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41772 - i++;
41773 - }
41774 + while (i > newvol) {
41775 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41776 + i--;
41777 }
41778 + while (i < newvol) {
41779 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41780 + i++;
41781 + }
41782 +}
41783
41784 - void issue_brightnesschange(const unsigned int oldbrt,
41785 - const unsigned int newbrt)
41786 - {
41787 - unsigned int i = oldbrt;
41788 +static void issue_brightnesschange(const unsigned int oldbrt,
41789 + const unsigned int newbrt,
41790 + const u32 event_mask)
41791 +{
41792 + unsigned int i = oldbrt;
41793
41794 - while (i > newbrt) {
41795 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41796 - i--;
41797 - }
41798 - while (i < newbrt) {
41799 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41800 - i++;
41801 - }
41802 + while (i > newbrt) {
41803 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41804 + i--;
41805 + }
41806 + while (i < newbrt) {
41807 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41808 + i++;
41809 }
41810 +}
41811
41812 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41813 + struct tp_nvram_state *newn,
41814 + const u32 event_mask)
41815 +{
41816 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41817 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41818 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41819 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41820 oldn->volume_level != newn->volume_level) {
41821 /* recently muted, or repeated mute keypress, or
41822 * multiple presses ending in mute */
41823 - issue_volchange(oldn->volume_level, newn->volume_level);
41824 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41825 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41826 }
41827 } else {
41828 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41829 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41830 }
41831 if (oldn->volume_level != newn->volume_level) {
41832 - issue_volchange(oldn->volume_level, newn->volume_level);
41833 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41834 } else if (oldn->volume_toggle != newn->volume_toggle) {
41835 /* repeated vol up/down keypress at end of scale ? */
41836 if (newn->volume_level == 0)
41837 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41838 /* handle brightness */
41839 if (oldn->brightness_level != newn->brightness_level) {
41840 issue_brightnesschange(oldn->brightness_level,
41841 - newn->brightness_level);
41842 + newn->brightness_level,
41843 + event_mask);
41844 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41845 /* repeated key presses that didn't change state */
41846 if (newn->brightness_level == 0)
41847 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41848 && !tp_features.bright_unkfw)
41849 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41850 }
41851 +}
41852
41853 #undef TPACPI_COMPARE_KEY
41854 #undef TPACPI_MAY_SEND_KEY
41855 -}
41856
41857 /*
41858 * Polling driver
41859 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41860 index 769d265..a3a05ca 100644
41861 --- a/drivers/pnp/pnpbios/bioscalls.c
41862 +++ b/drivers/pnp/pnpbios/bioscalls.c
41863 @@ -58,7 +58,7 @@ do { \
41864 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41865 } while(0)
41866
41867 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41868 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41869 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41870
41871 /*
41872 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41873
41874 cpu = get_cpu();
41875 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41876 +
41877 + pax_open_kernel();
41878 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41879 + pax_close_kernel();
41880
41881 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41882 spin_lock_irqsave(&pnp_bios_lock, flags);
41883 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41884 :"memory");
41885 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41886
41887 + pax_open_kernel();
41888 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41889 + pax_close_kernel();
41890 +
41891 put_cpu();
41892
41893 /* If we get here and this is set then the PnP BIOS faulted on us. */
41894 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41895 return status;
41896 }
41897
41898 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41899 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41900 {
41901 int i;
41902
41903 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41904 pnp_bios_callpoint.offset = header->fields.pm16offset;
41905 pnp_bios_callpoint.segment = PNP_CS16;
41906
41907 + pax_open_kernel();
41908 +
41909 for_each_possible_cpu(i) {
41910 struct desc_struct *gdt = get_cpu_gdt_table(i);
41911 if (!gdt)
41912 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41913 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41914 (unsigned long)__va(header->fields.pm16dseg));
41915 }
41916 +
41917 + pax_close_kernel();
41918 }
41919 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41920 index 3e6db1c..1fbbdae 100644
41921 --- a/drivers/pnp/resource.c
41922 +++ b/drivers/pnp/resource.c
41923 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41924 return 1;
41925
41926 /* check if the resource is valid */
41927 - if (*irq < 0 || *irq > 15)
41928 + if (*irq > 15)
41929 return 0;
41930
41931 /* check if the resource is reserved */
41932 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41933 return 1;
41934
41935 /* check if the resource is valid */
41936 - if (*dma < 0 || *dma == 4 || *dma > 7)
41937 + if (*dma == 4 || *dma > 7)
41938 return 0;
41939
41940 /* check if the resource is reserved */
41941 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41942 index 0c52e2a..3421ab7 100644
41943 --- a/drivers/power/pda_power.c
41944 +++ b/drivers/power/pda_power.c
41945 @@ -37,7 +37,11 @@ static int polling;
41946
41947 #if IS_ENABLED(CONFIG_USB_PHY)
41948 static struct usb_phy *transceiver;
41949 -static struct notifier_block otg_nb;
41950 +static int otg_handle_notification(struct notifier_block *nb,
41951 + unsigned long event, void *unused);
41952 +static struct notifier_block otg_nb = {
41953 + .notifier_call = otg_handle_notification
41954 +};
41955 #endif
41956
41957 static struct regulator *ac_draw;
41958 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41959
41960 #if IS_ENABLED(CONFIG_USB_PHY)
41961 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41962 - otg_nb.notifier_call = otg_handle_notification;
41963 ret = usb_register_notifier(transceiver, &otg_nb);
41964 if (ret) {
41965 dev_err(dev, "failure to register otg notifier\n");
41966 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41967 index cc439fd..8fa30df 100644
41968 --- a/drivers/power/power_supply.h
41969 +++ b/drivers/power/power_supply.h
41970 @@ -16,12 +16,12 @@ struct power_supply;
41971
41972 #ifdef CONFIG_SYSFS
41973
41974 -extern void power_supply_init_attrs(struct device_type *dev_type);
41975 +extern void power_supply_init_attrs(void);
41976 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41977
41978 #else
41979
41980 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41981 +static inline void power_supply_init_attrs(void) {}
41982 #define power_supply_uevent NULL
41983
41984 #endif /* CONFIG_SYSFS */
41985 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41986 index 1c517c3..ffa2f17 100644
41987 --- a/drivers/power/power_supply_core.c
41988 +++ b/drivers/power/power_supply_core.c
41989 @@ -24,7 +24,10 @@
41990 struct class *power_supply_class;
41991 EXPORT_SYMBOL_GPL(power_supply_class);
41992
41993 -static struct device_type power_supply_dev_type;
41994 +extern const struct attribute_group *power_supply_attr_groups[];
41995 +static struct device_type power_supply_dev_type = {
41996 + .groups = power_supply_attr_groups,
41997 +};
41998
41999 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
42000 struct power_supply *supply)
42001 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
42002 return PTR_ERR(power_supply_class);
42003
42004 power_supply_class->dev_uevent = power_supply_uevent;
42005 - power_supply_init_attrs(&power_supply_dev_type);
42006 + power_supply_init_attrs();
42007
42008 return 0;
42009 }
42010 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
42011 index 29178f7..c65f324 100644
42012 --- a/drivers/power/power_supply_sysfs.c
42013 +++ b/drivers/power/power_supply_sysfs.c
42014 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
42015 .is_visible = power_supply_attr_is_visible,
42016 };
42017
42018 -static const struct attribute_group *power_supply_attr_groups[] = {
42019 +const struct attribute_group *power_supply_attr_groups[] = {
42020 &power_supply_attr_group,
42021 NULL,
42022 };
42023
42024 -void power_supply_init_attrs(struct device_type *dev_type)
42025 +void power_supply_init_attrs(void)
42026 {
42027 int i;
42028
42029 - dev_type->groups = power_supply_attr_groups;
42030 -
42031 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
42032 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
42033 }
42034 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
42035 index d428ef9..fdc0357 100644
42036 --- a/drivers/regulator/max8660.c
42037 +++ b/drivers/regulator/max8660.c
42038 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
42039 max8660->shadow_regs[MAX8660_OVER1] = 5;
42040 } else {
42041 /* Otherwise devices can be toggled via software */
42042 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
42043 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
42044 + pax_open_kernel();
42045 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
42046 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
42047 + pax_close_kernel();
42048 }
42049
42050 /*
42051 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
42052 index adb1414..c13e0ce 100644
42053 --- a/drivers/regulator/max8973-regulator.c
42054 +++ b/drivers/regulator/max8973-regulator.c
42055 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
42056 if (!pdata->enable_ext_control) {
42057 max->desc.enable_reg = MAX8973_VOUT;
42058 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
42059 - max8973_dcdc_ops.enable = regulator_enable_regmap;
42060 - max8973_dcdc_ops.disable = regulator_disable_regmap;
42061 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
42062 + pax_open_kernel();
42063 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
42064 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
42065 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
42066 + pax_close_kernel();
42067 }
42068
42069 max->enable_external_control = pdata->enable_ext_control;
42070 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
42071 index b716283..3cc4349 100644
42072 --- a/drivers/regulator/mc13892-regulator.c
42073 +++ b/drivers/regulator/mc13892-regulator.c
42074 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
42075 }
42076 mc13xxx_unlock(mc13892);
42077
42078 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42079 + pax_open_kernel();
42080 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42081 = mc13892_vcam_set_mode;
42082 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42083 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42084 = mc13892_vcam_get_mode;
42085 + pax_close_kernel();
42086
42087 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
42088 ARRAY_SIZE(mc13892_regulators));
42089 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
42090 index f1cb706..4c7832a 100644
42091 --- a/drivers/rtc/rtc-cmos.c
42092 +++ b/drivers/rtc/rtc-cmos.c
42093 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
42094 hpet_rtc_timer_init();
42095
42096 /* export at least the first block of NVRAM */
42097 - nvram.size = address_space - NVRAM_OFFSET;
42098 + pax_open_kernel();
42099 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
42100 + pax_close_kernel();
42101 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
42102 if (retval < 0) {
42103 dev_dbg(dev, "can't create nvram file? %d\n", retval);
42104 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
42105 index d049393..bb20be0 100644
42106 --- a/drivers/rtc/rtc-dev.c
42107 +++ b/drivers/rtc/rtc-dev.c
42108 @@ -16,6 +16,7 @@
42109 #include <linux/module.h>
42110 #include <linux/rtc.h>
42111 #include <linux/sched.h>
42112 +#include <linux/grsecurity.h>
42113 #include "rtc-core.h"
42114
42115 static dev_t rtc_devt;
42116 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
42117 if (copy_from_user(&tm, uarg, sizeof(tm)))
42118 return -EFAULT;
42119
42120 + gr_log_timechange();
42121 +
42122 return rtc_set_time(rtc, &tm);
42123
42124 case RTC_PIE_ON:
42125 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
42126 index b53992a..776df84 100644
42127 --- a/drivers/rtc/rtc-ds1307.c
42128 +++ b/drivers/rtc/rtc-ds1307.c
42129 @@ -107,7 +107,7 @@ struct ds1307 {
42130 u8 offset; /* register's offset */
42131 u8 regs[11];
42132 u16 nvram_offset;
42133 - struct bin_attribute *nvram;
42134 + bin_attribute_no_const *nvram;
42135 enum ds_type type;
42136 unsigned long flags;
42137 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
42138 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
42139 index 130f29a..6179d03 100644
42140 --- a/drivers/rtc/rtc-m48t59.c
42141 +++ b/drivers/rtc/rtc-m48t59.c
42142 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
42143 goto out;
42144 }
42145
42146 - m48t59_nvram_attr.size = pdata->offset;
42147 + pax_open_kernel();
42148 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
42149 + pax_close_kernel();
42150
42151 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
42152 if (ret) {
42153 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
42154 index e693af6..2e525b6 100644
42155 --- a/drivers/scsi/bfa/bfa_fcpim.h
42156 +++ b/drivers/scsi/bfa/bfa_fcpim.h
42157 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
42158
42159 struct bfa_itn_s {
42160 bfa_isr_func_t isr;
42161 -};
42162 +} __no_const;
42163
42164 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
42165 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
42166 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
42167 index 23a90e7..9cf04ee 100644
42168 --- a/drivers/scsi/bfa/bfa_ioc.h
42169 +++ b/drivers/scsi/bfa/bfa_ioc.h
42170 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
42171 bfa_ioc_disable_cbfn_t disable_cbfn;
42172 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
42173 bfa_ioc_reset_cbfn_t reset_cbfn;
42174 -};
42175 +} __no_const;
42176
42177 /*
42178 * IOC event notification mechanism.
42179 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
42180 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
42181 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
42182 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
42183 -};
42184 +} __no_const;
42185
42186 /*
42187 * Queue element to wait for room in request queue. FIFO order is
42188 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
42189 index df0c3c7..b00e1d0 100644
42190 --- a/drivers/scsi/hosts.c
42191 +++ b/drivers/scsi/hosts.c
42192 @@ -42,7 +42,7 @@
42193 #include "scsi_logging.h"
42194
42195
42196 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42197 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42198
42199
42200 static void scsi_host_cls_release(struct device *dev)
42201 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
42202 * subtract one because we increment first then return, but we need to
42203 * know what the next host number was before increment
42204 */
42205 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
42206 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
42207 shost->dma_channel = 0xff;
42208
42209 /* These three are default values which can be overridden */
42210 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
42211 index 7f4f790..b75b92a 100644
42212 --- a/drivers/scsi/hpsa.c
42213 +++ b/drivers/scsi/hpsa.c
42214 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
42215 unsigned long flags;
42216
42217 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42218 - return h->access.command_completed(h, q);
42219 + return h->access->command_completed(h, q);
42220
42221 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42222 a = rq->head[rq->current_entry];
42223 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
42224 while (!list_empty(&h->reqQ)) {
42225 c = list_entry(h->reqQ.next, struct CommandList, list);
42226 /* can't do anything if fifo is full */
42227 - if ((h->access.fifo_full(h))) {
42228 + if ((h->access->fifo_full(h))) {
42229 dev_warn(&h->pdev->dev, "fifo full\n");
42230 break;
42231 }
42232 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
42233
42234 /* Tell the controller execute command */
42235 spin_unlock_irqrestore(&h->lock, flags);
42236 - h->access.submit_command(h, c);
42237 + h->access->submit_command(h, c);
42238 spin_lock_irqsave(&h->lock, flags);
42239 }
42240 spin_unlock_irqrestore(&h->lock, flags);
42241 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
42242
42243 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42244 {
42245 - return h->access.command_completed(h, q);
42246 + return h->access->command_completed(h, q);
42247 }
42248
42249 static inline bool interrupt_pending(struct ctlr_info *h)
42250 {
42251 - return h->access.intr_pending(h);
42252 + return h->access->intr_pending(h);
42253 }
42254
42255 static inline long interrupt_not_for_us(struct ctlr_info *h)
42256 {
42257 - return (h->access.intr_pending(h) == 0) ||
42258 + return (h->access->intr_pending(h) == 0) ||
42259 (h->interrupts_enabled == 0);
42260 }
42261
42262 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42263 if (prod_index < 0)
42264 return -ENODEV;
42265 h->product_name = products[prod_index].product_name;
42266 - h->access = *(products[prod_index].access);
42267 + h->access = products[prod_index].access;
42268
42269 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42270 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42271 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42272
42273 assert_spin_locked(&lockup_detector_lock);
42274 remove_ctlr_from_lockup_detector_list(h);
42275 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42276 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42277 spin_lock_irqsave(&h->lock, flags);
42278 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42279 spin_unlock_irqrestore(&h->lock, flags);
42280 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
42281 }
42282
42283 /* make sure the board interrupts are off */
42284 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42285 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42286
42287 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42288 goto clean2;
42289 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
42290 * fake ones to scoop up any residual completions.
42291 */
42292 spin_lock_irqsave(&h->lock, flags);
42293 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42294 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42295 spin_unlock_irqrestore(&h->lock, flags);
42296 free_irqs(h);
42297 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42298 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
42299 dev_info(&h->pdev->dev, "Board READY.\n");
42300 dev_info(&h->pdev->dev,
42301 "Waiting for stale completions to drain.\n");
42302 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42303 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42304 msleep(10000);
42305 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42306 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42307
42308 rc = controller_reset_failed(h->cfgtable);
42309 if (rc)
42310 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
42311 }
42312
42313 /* Turn the interrupts on so we can service requests */
42314 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42315 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42316
42317 hpsa_hba_inquiry(h);
42318 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42319 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42320 * To write all data in the battery backed cache to disks
42321 */
42322 hpsa_flush_cache(h);
42323 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42324 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42325 hpsa_free_irqs_and_disable_msix(h);
42326 }
42327
42328 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42329 return;
42330 }
42331 /* Change the access methods to the performant access methods */
42332 - h->access = SA5_performant_access;
42333 + h->access = &SA5_performant_access;
42334 h->transMethod = CFGTBL_Trans_Performant;
42335 }
42336
42337 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42338 index 9816479..c5d4e97 100644
42339 --- a/drivers/scsi/hpsa.h
42340 +++ b/drivers/scsi/hpsa.h
42341 @@ -79,7 +79,7 @@ struct ctlr_info {
42342 unsigned int msix_vector;
42343 unsigned int msi_vector;
42344 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42345 - struct access_method access;
42346 + struct access_method *access;
42347
42348 /* queue and queue Info */
42349 struct list_head reqQ;
42350 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42351 index 8b928c6..9c76300 100644
42352 --- a/drivers/scsi/libfc/fc_exch.c
42353 +++ b/drivers/scsi/libfc/fc_exch.c
42354 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42355 u16 pool_max_index;
42356
42357 struct {
42358 - atomic_t no_free_exch;
42359 - atomic_t no_free_exch_xid;
42360 - atomic_t xid_not_found;
42361 - atomic_t xid_busy;
42362 - atomic_t seq_not_found;
42363 - atomic_t non_bls_resp;
42364 + atomic_unchecked_t no_free_exch;
42365 + atomic_unchecked_t no_free_exch_xid;
42366 + atomic_unchecked_t xid_not_found;
42367 + atomic_unchecked_t xid_busy;
42368 + atomic_unchecked_t seq_not_found;
42369 + atomic_unchecked_t non_bls_resp;
42370 } stats;
42371 };
42372
42373 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42374 /* allocate memory for exchange */
42375 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42376 if (!ep) {
42377 - atomic_inc(&mp->stats.no_free_exch);
42378 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42379 goto out;
42380 }
42381 memset(ep, 0, sizeof(*ep));
42382 @@ -797,7 +797,7 @@ out:
42383 return ep;
42384 err:
42385 spin_unlock_bh(&pool->lock);
42386 - atomic_inc(&mp->stats.no_free_exch_xid);
42387 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42388 mempool_free(ep, mp->ep_pool);
42389 return NULL;
42390 }
42391 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42392 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42393 ep = fc_exch_find(mp, xid);
42394 if (!ep) {
42395 - atomic_inc(&mp->stats.xid_not_found);
42396 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42397 reject = FC_RJT_OX_ID;
42398 goto out;
42399 }
42400 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42401 ep = fc_exch_find(mp, xid);
42402 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42403 if (ep) {
42404 - atomic_inc(&mp->stats.xid_busy);
42405 + atomic_inc_unchecked(&mp->stats.xid_busy);
42406 reject = FC_RJT_RX_ID;
42407 goto rel;
42408 }
42409 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42410 }
42411 xid = ep->xid; /* get our XID */
42412 } else if (!ep) {
42413 - atomic_inc(&mp->stats.xid_not_found);
42414 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42415 reject = FC_RJT_RX_ID; /* XID not found */
42416 goto out;
42417 }
42418 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42419 } else {
42420 sp = &ep->seq;
42421 if (sp->id != fh->fh_seq_id) {
42422 - atomic_inc(&mp->stats.seq_not_found);
42423 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42424 if (f_ctl & FC_FC_END_SEQ) {
42425 /*
42426 * Update sequence_id based on incoming last
42427 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42428
42429 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42430 if (!ep) {
42431 - atomic_inc(&mp->stats.xid_not_found);
42432 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42433 goto out;
42434 }
42435 if (ep->esb_stat & ESB_ST_COMPLETE) {
42436 - atomic_inc(&mp->stats.xid_not_found);
42437 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42438 goto rel;
42439 }
42440 if (ep->rxid == FC_XID_UNKNOWN)
42441 ep->rxid = ntohs(fh->fh_rx_id);
42442 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42443 - atomic_inc(&mp->stats.xid_not_found);
42444 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42445 goto rel;
42446 }
42447 if (ep->did != ntoh24(fh->fh_s_id) &&
42448 ep->did != FC_FID_FLOGI) {
42449 - atomic_inc(&mp->stats.xid_not_found);
42450 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42451 goto rel;
42452 }
42453 sof = fr_sof(fp);
42454 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42455 sp->ssb_stat |= SSB_ST_RESP;
42456 sp->id = fh->fh_seq_id;
42457 } else if (sp->id != fh->fh_seq_id) {
42458 - atomic_inc(&mp->stats.seq_not_found);
42459 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42460 goto rel;
42461 }
42462
42463 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42464 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42465
42466 if (!sp)
42467 - atomic_inc(&mp->stats.xid_not_found);
42468 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42469 else
42470 - atomic_inc(&mp->stats.non_bls_resp);
42471 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42472
42473 fc_frame_free(fp);
42474 }
42475 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42476
42477 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42478 mp = ema->mp;
42479 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42480 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42481 st->fc_no_free_exch_xid +=
42482 - atomic_read(&mp->stats.no_free_exch_xid);
42483 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42484 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42485 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42486 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42487 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42488 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42489 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42490 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42491 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42492 }
42493 }
42494 EXPORT_SYMBOL(fc_exch_update_stats);
42495 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42496 index 161c98e..6d563b3 100644
42497 --- a/drivers/scsi/libsas/sas_ata.c
42498 +++ b/drivers/scsi/libsas/sas_ata.c
42499 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42500 .postreset = ata_std_postreset,
42501 .error_handler = ata_std_error_handler,
42502 .post_internal_cmd = sas_ata_post_internal,
42503 - .qc_defer = ata_std_qc_defer,
42504 + .qc_defer = ata_std_qc_defer,
42505 .qc_prep = ata_noop_qc_prep,
42506 .qc_issue = sas_ata_qc_issue,
42507 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42508 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42509 index bcc56ca..6f4174a 100644
42510 --- a/drivers/scsi/lpfc/lpfc.h
42511 +++ b/drivers/scsi/lpfc/lpfc.h
42512 @@ -431,7 +431,7 @@ struct lpfc_vport {
42513 struct dentry *debug_nodelist;
42514 struct dentry *vport_debugfs_root;
42515 struct lpfc_debugfs_trc *disc_trc;
42516 - atomic_t disc_trc_cnt;
42517 + atomic_unchecked_t disc_trc_cnt;
42518 #endif
42519 uint8_t stat_data_enabled;
42520 uint8_t stat_data_blocked;
42521 @@ -865,8 +865,8 @@ struct lpfc_hba {
42522 struct timer_list fabric_block_timer;
42523 unsigned long bit_flags;
42524 #define FABRIC_COMANDS_BLOCKED 0
42525 - atomic_t num_rsrc_err;
42526 - atomic_t num_cmd_success;
42527 + atomic_unchecked_t num_rsrc_err;
42528 + atomic_unchecked_t num_cmd_success;
42529 unsigned long last_rsrc_error_time;
42530 unsigned long last_ramp_down_time;
42531 unsigned long last_ramp_up_time;
42532 @@ -902,7 +902,7 @@ struct lpfc_hba {
42533
42534 struct dentry *debug_slow_ring_trc;
42535 struct lpfc_debugfs_trc *slow_ring_trc;
42536 - atomic_t slow_ring_trc_cnt;
42537 + atomic_unchecked_t slow_ring_trc_cnt;
42538 /* iDiag debugfs sub-directory */
42539 struct dentry *idiag_root;
42540 struct dentry *idiag_pci_cfg;
42541 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42542 index f525ecb..32549a4 100644
42543 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42544 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42545 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42546
42547 #include <linux/debugfs.h>
42548
42549 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42550 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42551 static unsigned long lpfc_debugfs_start_time = 0L;
42552
42553 /* iDiag */
42554 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42555 lpfc_debugfs_enable = 0;
42556
42557 len = 0;
42558 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42559 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42560 (lpfc_debugfs_max_disc_trc - 1);
42561 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42562 dtp = vport->disc_trc + i;
42563 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42564 lpfc_debugfs_enable = 0;
42565
42566 len = 0;
42567 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42568 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42569 (lpfc_debugfs_max_slow_ring_trc - 1);
42570 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42571 dtp = phba->slow_ring_trc + i;
42572 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42573 !vport || !vport->disc_trc)
42574 return;
42575
42576 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42577 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42578 (lpfc_debugfs_max_disc_trc - 1);
42579 dtp = vport->disc_trc + index;
42580 dtp->fmt = fmt;
42581 dtp->data1 = data1;
42582 dtp->data2 = data2;
42583 dtp->data3 = data3;
42584 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42585 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42586 dtp->jif = jiffies;
42587 #endif
42588 return;
42589 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42590 !phba || !phba->slow_ring_trc)
42591 return;
42592
42593 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42594 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42595 (lpfc_debugfs_max_slow_ring_trc - 1);
42596 dtp = phba->slow_ring_trc + index;
42597 dtp->fmt = fmt;
42598 dtp->data1 = data1;
42599 dtp->data2 = data2;
42600 dtp->data3 = data3;
42601 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42602 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42603 dtp->jif = jiffies;
42604 #endif
42605 return;
42606 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42607 "slow_ring buffer\n");
42608 goto debug_failed;
42609 }
42610 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42611 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42612 memset(phba->slow_ring_trc, 0,
42613 (sizeof(struct lpfc_debugfs_trc) *
42614 lpfc_debugfs_max_slow_ring_trc));
42615 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42616 "buffer\n");
42617 goto debug_failed;
42618 }
42619 - atomic_set(&vport->disc_trc_cnt, 0);
42620 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42621
42622 snprintf(name, sizeof(name), "discovery_trace");
42623 vport->debug_disc_trc =
42624 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42625 index cb465b2..2e7b25f 100644
42626 --- a/drivers/scsi/lpfc/lpfc_init.c
42627 +++ b/drivers/scsi/lpfc/lpfc_init.c
42628 @@ -10950,8 +10950,10 @@ lpfc_init(void)
42629 "misc_register returned with status %d", error);
42630
42631 if (lpfc_enable_npiv) {
42632 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42633 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42634 + pax_open_kernel();
42635 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42636 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42637 + pax_close_kernel();
42638 }
42639 lpfc_transport_template =
42640 fc_attach_transport(&lpfc_transport_functions);
42641 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42642 index 8523b278e..ce1d812 100644
42643 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42644 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42645 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42646 uint32_t evt_posted;
42647
42648 spin_lock_irqsave(&phba->hbalock, flags);
42649 - atomic_inc(&phba->num_rsrc_err);
42650 + atomic_inc_unchecked(&phba->num_rsrc_err);
42651 phba->last_rsrc_error_time = jiffies;
42652
42653 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42654 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42655 unsigned long flags;
42656 struct lpfc_hba *phba = vport->phba;
42657 uint32_t evt_posted;
42658 - atomic_inc(&phba->num_cmd_success);
42659 + atomic_inc_unchecked(&phba->num_cmd_success);
42660
42661 if (vport->cfg_lun_queue_depth <= queue_depth)
42662 return;
42663 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42664 unsigned long num_rsrc_err, num_cmd_success;
42665 int i;
42666
42667 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42668 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42669 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42670 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42671
42672 /*
42673 * The error and success command counters are global per
42674 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42675 }
42676 }
42677 lpfc_destroy_vport_work_array(phba, vports);
42678 - atomic_set(&phba->num_rsrc_err, 0);
42679 - atomic_set(&phba->num_cmd_success, 0);
42680 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42681 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42682 }
42683
42684 /**
42685 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42686 }
42687 }
42688 lpfc_destroy_vport_work_array(phba, vports);
42689 - atomic_set(&phba->num_rsrc_err, 0);
42690 - atomic_set(&phba->num_cmd_success, 0);
42691 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42692 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42693 }
42694
42695 /**
42696 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42697 index 8e1b737..50ff510 100644
42698 --- a/drivers/scsi/pmcraid.c
42699 +++ b/drivers/scsi/pmcraid.c
42700 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42701 res->scsi_dev = scsi_dev;
42702 scsi_dev->hostdata = res;
42703 res->change_detected = 0;
42704 - atomic_set(&res->read_failures, 0);
42705 - atomic_set(&res->write_failures, 0);
42706 + atomic_set_unchecked(&res->read_failures, 0);
42707 + atomic_set_unchecked(&res->write_failures, 0);
42708 rc = 0;
42709 }
42710 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42711 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42712
42713 /* If this was a SCSI read/write command keep count of errors */
42714 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42715 - atomic_inc(&res->read_failures);
42716 + atomic_inc_unchecked(&res->read_failures);
42717 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42718 - atomic_inc(&res->write_failures);
42719 + atomic_inc_unchecked(&res->write_failures);
42720
42721 if (!RES_IS_GSCSI(res->cfg_entry) &&
42722 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42723 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42724 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42725 * hrrq_id assigned here in queuecommand
42726 */
42727 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42728 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42729 pinstance->num_hrrq;
42730 cmd->cmd_done = pmcraid_io_done;
42731
42732 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
42733 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42734 * hrrq_id assigned here in queuecommand
42735 */
42736 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42737 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42738 pinstance->num_hrrq;
42739
42740 if (request_size) {
42741 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42742
42743 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42744 /* add resources only after host is added into system */
42745 - if (!atomic_read(&pinstance->expose_resources))
42746 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42747 return;
42748
42749 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42750 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42751 init_waitqueue_head(&pinstance->reset_wait_q);
42752
42753 atomic_set(&pinstance->outstanding_cmds, 0);
42754 - atomic_set(&pinstance->last_message_id, 0);
42755 - atomic_set(&pinstance->expose_resources, 0);
42756 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42757 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42758
42759 INIT_LIST_HEAD(&pinstance->free_res_q);
42760 INIT_LIST_HEAD(&pinstance->used_res_q);
42761 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42762 /* Schedule worker thread to handle CCN and take care of adding and
42763 * removing devices to OS
42764 */
42765 - atomic_set(&pinstance->expose_resources, 1);
42766 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42767 schedule_work(&pinstance->worker_q);
42768 return rc;
42769
42770 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42771 index e1d150f..6c6df44 100644
42772 --- a/drivers/scsi/pmcraid.h
42773 +++ b/drivers/scsi/pmcraid.h
42774 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42775 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42776
42777 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42778 - atomic_t last_message_id;
42779 + atomic_unchecked_t last_message_id;
42780
42781 /* configuration table */
42782 struct pmcraid_config_table *cfg_table;
42783 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42784 atomic_t outstanding_cmds;
42785
42786 /* should add/delete resources to mid-layer now ?*/
42787 - atomic_t expose_resources;
42788 + atomic_unchecked_t expose_resources;
42789
42790
42791
42792 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42793 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42794 };
42795 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42796 - atomic_t read_failures; /* count of failed READ commands */
42797 - atomic_t write_failures; /* count of failed WRITE commands */
42798 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42799 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42800
42801 /* To indicate add/delete/modify during CCN */
42802 u8 change_detected;
42803 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42804 index bf60c63..74d4dce 100644
42805 --- a/drivers/scsi/qla2xxx/qla_attr.c
42806 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42807 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42808 return 0;
42809 }
42810
42811 -struct fc_function_template qla2xxx_transport_functions = {
42812 +fc_function_template_no_const qla2xxx_transport_functions = {
42813
42814 .show_host_node_name = 1,
42815 .show_host_port_name = 1,
42816 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42817 .bsg_timeout = qla24xx_bsg_timeout,
42818 };
42819
42820 -struct fc_function_template qla2xxx_transport_vport_functions = {
42821 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42822
42823 .show_host_node_name = 1,
42824 .show_host_port_name = 1,
42825 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42826 index 026bfde..90c4018 100644
42827 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42828 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42829 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42830 struct device_attribute;
42831 extern struct device_attribute *qla2x00_host_attrs[];
42832 struct fc_function_template;
42833 -extern struct fc_function_template qla2xxx_transport_functions;
42834 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42835 +extern fc_function_template_no_const qla2xxx_transport_functions;
42836 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42837 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42838 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42839 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42840 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42841 index ad72c1d..afc9a98 100644
42842 --- a/drivers/scsi/qla2xxx/qla_os.c
42843 +++ b/drivers/scsi/qla2xxx/qla_os.c
42844 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42845 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42846 /* Ok, a 64bit DMA mask is applicable. */
42847 ha->flags.enable_64bit_addressing = 1;
42848 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42849 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42850 + pax_open_kernel();
42851 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42852 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42853 + pax_close_kernel();
42854 return;
42855 }
42856 }
42857 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42858 index ddf16a8..80f4dd0 100644
42859 --- a/drivers/scsi/qla4xxx/ql4_def.h
42860 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42861 @@ -291,7 +291,7 @@ struct ddb_entry {
42862 * (4000 only) */
42863 atomic_t relogin_timer; /* Max Time to wait for
42864 * relogin to complete */
42865 - atomic_t relogin_retry_count; /* Num of times relogin has been
42866 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42867 * retried */
42868 uint32_t default_time2wait; /* Default Min time between
42869 * relogins (+aens) */
42870 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42871 index 4d231c1..2892c37 100644
42872 --- a/drivers/scsi/qla4xxx/ql4_os.c
42873 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42874 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42875 */
42876 if (!iscsi_is_session_online(cls_sess)) {
42877 /* Reset retry relogin timer */
42878 - atomic_inc(&ddb_entry->relogin_retry_count);
42879 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42880 DEBUG2(ql4_printk(KERN_INFO, ha,
42881 "%s: index[%d] relogin timed out-retrying"
42882 " relogin (%d), retry (%d)\n", __func__,
42883 ddb_entry->fw_ddb_index,
42884 - atomic_read(&ddb_entry->relogin_retry_count),
42885 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42886 ddb_entry->default_time2wait + 4));
42887 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42888 atomic_set(&ddb_entry->retry_relogin_timer,
42889 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42890
42891 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42892 atomic_set(&ddb_entry->relogin_timer, 0);
42893 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42894 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42895 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42896 ddb_entry->default_relogin_timeout =
42897 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42898 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42899 index 3b1ea34..1583a72 100644
42900 --- a/drivers/scsi/scsi.c
42901 +++ b/drivers/scsi/scsi.c
42902 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42903 unsigned long timeout;
42904 int rtn = 0;
42905
42906 - atomic_inc(&cmd->device->iorequest_cnt);
42907 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42908
42909 /* check if the device is still usable */
42910 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42911 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42912 index 86d5220..f22c51a 100644
42913 --- a/drivers/scsi/scsi_lib.c
42914 +++ b/drivers/scsi/scsi_lib.c
42915 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42916 shost = sdev->host;
42917 scsi_init_cmd_errh(cmd);
42918 cmd->result = DID_NO_CONNECT << 16;
42919 - atomic_inc(&cmd->device->iorequest_cnt);
42920 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42921
42922 /*
42923 * SCSI request completion path will do scsi_device_unbusy(),
42924 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
42925
42926 INIT_LIST_HEAD(&cmd->eh_entry);
42927
42928 - atomic_inc(&cmd->device->iodone_cnt);
42929 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42930 if (cmd->result)
42931 - atomic_inc(&cmd->device->ioerr_cnt);
42932 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42933
42934 disposition = scsi_decide_disposition(cmd);
42935 if (disposition != SUCCESS &&
42936 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42937 index 931a7d9..0c2a754 100644
42938 --- a/drivers/scsi/scsi_sysfs.c
42939 +++ b/drivers/scsi/scsi_sysfs.c
42940 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42941 char *buf) \
42942 { \
42943 struct scsi_device *sdev = to_scsi_device(dev); \
42944 - unsigned long long count = atomic_read(&sdev->field); \
42945 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42946 return snprintf(buf, 20, "0x%llx\n", count); \
42947 } \
42948 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42949 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42950 index 84a1fdf..693b0d6 100644
42951 --- a/drivers/scsi/scsi_tgt_lib.c
42952 +++ b/drivers/scsi/scsi_tgt_lib.c
42953 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42954 int err;
42955
42956 dprintk("%lx %u\n", uaddr, len);
42957 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42958 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42959 if (err) {
42960 /*
42961 * TODO: need to fixup sg_tablesize, max_segment_size,
42962 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42963 index e106c27..11a380e 100644
42964 --- a/drivers/scsi/scsi_transport_fc.c
42965 +++ b/drivers/scsi/scsi_transport_fc.c
42966 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42967 * Netlink Infrastructure
42968 */
42969
42970 -static atomic_t fc_event_seq;
42971 +static atomic_unchecked_t fc_event_seq;
42972
42973 /**
42974 * fc_get_event_number - Obtain the next sequential FC event number
42975 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
42976 u32
42977 fc_get_event_number(void)
42978 {
42979 - return atomic_add_return(1, &fc_event_seq);
42980 + return atomic_add_return_unchecked(1, &fc_event_seq);
42981 }
42982 EXPORT_SYMBOL(fc_get_event_number);
42983
42984 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
42985 {
42986 int error;
42987
42988 - atomic_set(&fc_event_seq, 0);
42989 + atomic_set_unchecked(&fc_event_seq, 0);
42990
42991 error = transport_class_register(&fc_host_class);
42992 if (error)
42993 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42994 char *cp;
42995
42996 *val = simple_strtoul(buf, &cp, 0);
42997 - if ((*cp && (*cp != '\n')) || (*val < 0))
42998 + if (*cp && (*cp != '\n'))
42999 return -EINVAL;
43000 /*
43001 * Check for overflow; dev_loss_tmo is u32
43002 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
43003 index 133926b..903000d 100644
43004 --- a/drivers/scsi/scsi_transport_iscsi.c
43005 +++ b/drivers/scsi/scsi_transport_iscsi.c
43006 @@ -80,7 +80,7 @@ struct iscsi_internal {
43007 struct transport_container session_cont;
43008 };
43009
43010 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
43011 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
43012 static struct workqueue_struct *iscsi_eh_timer_workq;
43013
43014 static DEFINE_IDA(iscsi_sess_ida);
43015 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
43016 int err;
43017
43018 ihost = shost->shost_data;
43019 - session->sid = atomic_add_return(1, &iscsi_session_nr);
43020 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
43021
43022 if (target_id == ISCSI_MAX_TARGET) {
43023 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
43024 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
43025 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
43026 ISCSI_TRANSPORT_VERSION);
43027
43028 - atomic_set(&iscsi_session_nr, 0);
43029 + atomic_set_unchecked(&iscsi_session_nr, 0);
43030
43031 err = class_register(&iscsi_transport_class);
43032 if (err)
43033 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
43034 index f379c7f..e8fc69c 100644
43035 --- a/drivers/scsi/scsi_transport_srp.c
43036 +++ b/drivers/scsi/scsi_transport_srp.c
43037 @@ -33,7 +33,7 @@
43038 #include "scsi_transport_srp_internal.h"
43039
43040 struct srp_host_attrs {
43041 - atomic_t next_port_id;
43042 + atomic_unchecked_t next_port_id;
43043 };
43044 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
43045
43046 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
43047 struct Scsi_Host *shost = dev_to_shost(dev);
43048 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
43049
43050 - atomic_set(&srp_host->next_port_id, 0);
43051 + atomic_set_unchecked(&srp_host->next_port_id, 0);
43052 return 0;
43053 }
43054
43055 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
43056 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
43057 rport->roles = ids->roles;
43058
43059 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
43060 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
43061 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
43062
43063 transport_setup_device(&rport->dev);
43064 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
43065 index 1b1125e..31a2019 100644
43066 --- a/drivers/scsi/sd.c
43067 +++ b/drivers/scsi/sd.c
43068 @@ -2936,7 +2936,7 @@ static int sd_probe(struct device *dev)
43069 sdkp->disk = gd;
43070 sdkp->index = index;
43071 atomic_set(&sdkp->openers, 0);
43072 - atomic_set(&sdkp->device->ioerr_cnt, 0);
43073 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
43074
43075 if (!sdp->request_queue->rq_timeout) {
43076 if (sdp->type != TYPE_MOD)
43077 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
43078 index df5e961..df6b97f 100644
43079 --- a/drivers/scsi/sg.c
43080 +++ b/drivers/scsi/sg.c
43081 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
43082 sdp->disk->disk_name,
43083 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
43084 NULL,
43085 - (char *)arg);
43086 + (char __user *)arg);
43087 case BLKTRACESTART:
43088 return blk_trace_startstop(sdp->device->request_queue, 1);
43089 case BLKTRACESTOP:
43090 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
43091 index 32b7bb1..2f1c4bd 100644
43092 --- a/drivers/spi/spi.c
43093 +++ b/drivers/spi/spi.c
43094 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
43095 EXPORT_SYMBOL_GPL(spi_bus_unlock);
43096
43097 /* portable code must never pass more than 32 bytes */
43098 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
43099 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
43100
43101 static u8 *buf;
43102
43103 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
43104 index 3675020..e80d92c 100644
43105 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
43106 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
43107 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
43108
43109 static int solo_sysfs_init(struct solo_dev *solo_dev)
43110 {
43111 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
43112 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
43113 struct device *dev = &solo_dev->dev;
43114 const char *driver;
43115 int i;
43116 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
43117 index 34afc16..ffe44dd 100644
43118 --- a/drivers/staging/octeon/ethernet-rx.c
43119 +++ b/drivers/staging/octeon/ethernet-rx.c
43120 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43121 /* Increment RX stats for virtual ports */
43122 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
43123 #ifdef CONFIG_64BIT
43124 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
43125 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
43126 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
43127 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
43128 #else
43129 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
43130 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
43131 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
43132 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
43133 #endif
43134 }
43135 netif_receive_skb(skb);
43136 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43137 dev->name);
43138 */
43139 #ifdef CONFIG_64BIT
43140 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
43141 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43142 #else
43143 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
43144 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
43145 #endif
43146 dev_kfree_skb_irq(skb);
43147 }
43148 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
43149 index c3a90e7..023619a 100644
43150 --- a/drivers/staging/octeon/ethernet.c
43151 +++ b/drivers/staging/octeon/ethernet.c
43152 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
43153 * since the RX tasklet also increments it.
43154 */
43155 #ifdef CONFIG_64BIT
43156 - atomic64_add(rx_status.dropped_packets,
43157 - (atomic64_t *)&priv->stats.rx_dropped);
43158 + atomic64_add_unchecked(rx_status.dropped_packets,
43159 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43160 #else
43161 - atomic_add(rx_status.dropped_packets,
43162 - (atomic_t *)&priv->stats.rx_dropped);
43163 + atomic_add_unchecked(rx_status.dropped_packets,
43164 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
43165 #endif
43166 }
43167
43168 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43169 index dc23395..cf7e9b1 100644
43170 --- a/drivers/staging/rtl8712/rtl871x_io.h
43171 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43172 @@ -108,7 +108,7 @@ struct _io_ops {
43173 u8 *pmem);
43174 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43175 u8 *pmem);
43176 -};
43177 +} __no_const;
43178
43179 struct io_req {
43180 struct list_head list;
43181 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43182 index 1f5088b..0e59820 100644
43183 --- a/drivers/staging/sbe-2t3e3/netdev.c
43184 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43185 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43186 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43187
43188 if (rlen)
43189 - if (copy_to_user(data, &resp, rlen))
43190 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43191 return -EFAULT;
43192
43193 return 0;
43194 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43195 index a863a98..d272795 100644
43196 --- a/drivers/staging/usbip/vhci.h
43197 +++ b/drivers/staging/usbip/vhci.h
43198 @@ -83,7 +83,7 @@ struct vhci_hcd {
43199 unsigned resuming:1;
43200 unsigned long re_timeout;
43201
43202 - atomic_t seqnum;
43203 + atomic_unchecked_t seqnum;
43204
43205 /*
43206 * NOTE:
43207 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43208 index d7974cb..d78076b 100644
43209 --- a/drivers/staging/usbip/vhci_hcd.c
43210 +++ b/drivers/staging/usbip/vhci_hcd.c
43211 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
43212
43213 spin_lock(&vdev->priv_lock);
43214
43215 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43216 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43217 if (priv->seqnum == 0xffff)
43218 dev_info(&urb->dev->dev, "seqnum max\n");
43219
43220 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43221 return -ENOMEM;
43222 }
43223
43224 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43225 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43226 if (unlink->seqnum == 0xffff)
43227 pr_info("seqnum max\n");
43228
43229 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
43230 vdev->rhport = rhport;
43231 }
43232
43233 - atomic_set(&vhci->seqnum, 0);
43234 + atomic_set_unchecked(&vhci->seqnum, 0);
43235 spin_lock_init(&vhci->lock);
43236
43237 hcd->power_budget = 0; /* no limit */
43238 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43239 index d07fcb5..358e1e1 100644
43240 --- a/drivers/staging/usbip/vhci_rx.c
43241 +++ b/drivers/staging/usbip/vhci_rx.c
43242 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43243 if (!urb) {
43244 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43245 pr_info("max seqnum %d\n",
43246 - atomic_read(&the_controller->seqnum));
43247 + atomic_read_unchecked(&the_controller->seqnum));
43248 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43249 return;
43250 }
43251 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43252 index 8417c2f..ef5ebd6 100644
43253 --- a/drivers/staging/vt6655/hostap.c
43254 +++ b/drivers/staging/vt6655/hostap.c
43255 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
43256 *
43257 */
43258
43259 +static net_device_ops_no_const apdev_netdev_ops;
43260 +
43261 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43262 {
43263 PSDevice apdev_priv;
43264 struct net_device *dev = pDevice->dev;
43265 int ret;
43266 - const struct net_device_ops apdev_netdev_ops = {
43267 - .ndo_start_xmit = pDevice->tx_80211,
43268 - };
43269
43270 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43271
43272 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43273 *apdev_priv = *pDevice;
43274 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43275
43276 + /* only half broken now */
43277 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43278 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43279
43280 pDevice->apdev->type = ARPHRD_IEEE80211;
43281 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43282 index c699a30..b90a5fd 100644
43283 --- a/drivers/staging/vt6656/hostap.c
43284 +++ b/drivers/staging/vt6656/hostap.c
43285 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43286 *
43287 */
43288
43289 +static net_device_ops_no_const apdev_netdev_ops;
43290 +
43291 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43292 {
43293 struct vnt_private *apdev_priv;
43294 struct net_device *dev = pDevice->dev;
43295 int ret;
43296 - const struct net_device_ops apdev_netdev_ops = {
43297 - .ndo_start_xmit = pDevice->tx_80211,
43298 - };
43299
43300 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43301
43302 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43303 *apdev_priv = *pDevice;
43304 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43305
43306 + /* only half broken now */
43307 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43308 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43309
43310 pDevice->apdev->type = ARPHRD_IEEE80211;
43311 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43312 index d7e51e4..d07eaab 100644
43313 --- a/drivers/staging/zcache/tmem.c
43314 +++ b/drivers/staging/zcache/tmem.c
43315 @@ -51,7 +51,7 @@
43316 * A tmem host implementation must use this function to register callbacks
43317 * for memory allocation.
43318 */
43319 -static struct tmem_hostops tmem_hostops;
43320 +static tmem_hostops_no_const tmem_hostops;
43321
43322 static void tmem_objnode_tree_init(void);
43323
43324 @@ -65,7 +65,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43325 * A tmem host implementation must use this function to register
43326 * callbacks for a page-accessible memory (PAM) implementation.
43327 */
43328 -static struct tmem_pamops tmem_pamops;
43329 +static tmem_pamops_no_const tmem_pamops;
43330
43331 void tmem_register_pamops(struct tmem_pamops *m)
43332 {
43333 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43334 index d128ce2..a43980c 100644
43335 --- a/drivers/staging/zcache/tmem.h
43336 +++ b/drivers/staging/zcache/tmem.h
43337 @@ -226,6 +226,7 @@ struct tmem_pamops {
43338 int (*replace_in_obj)(void *, struct tmem_obj *);
43339 #endif
43340 };
43341 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43342 extern void tmem_register_pamops(struct tmem_pamops *m);
43343
43344 /* memory allocation methods provided by the host implementation */
43345 @@ -235,6 +236,7 @@ struct tmem_hostops {
43346 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43347 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43348 };
43349 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43350 extern void tmem_register_hostops(struct tmem_hostops *m);
43351
43352 /* core tmem accessor functions */
43353 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43354 index 4630481..c26782a 100644
43355 --- a/drivers/target/target_core_device.c
43356 +++ b/drivers/target/target_core_device.c
43357 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43358 spin_lock_init(&dev->se_port_lock);
43359 spin_lock_init(&dev->se_tmr_lock);
43360 spin_lock_init(&dev->qf_cmd_lock);
43361 - atomic_set(&dev->dev_ordered_id, 0);
43362 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43363 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43364 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43365 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43366 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43367 index 21e3158..43c6004 100644
43368 --- a/drivers/target/target_core_transport.c
43369 +++ b/drivers/target/target_core_transport.c
43370 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43371 * Used to determine when ORDERED commands should go from
43372 * Dormant to Active status.
43373 */
43374 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43375 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43376 smp_mb__after_atomic_inc();
43377 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43378 cmd->se_ordered_id, cmd->sam_task_attr,
43379 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43380 index 33f83fe..d80f8e1 100644
43381 --- a/drivers/tty/cyclades.c
43382 +++ b/drivers/tty/cyclades.c
43383 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43384 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43385 info->port.count);
43386 #endif
43387 - info->port.count++;
43388 + atomic_inc(&info->port.count);
43389 #ifdef CY_DEBUG_COUNT
43390 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43391 - current->pid, info->port.count);
43392 + current->pid, atomic_read(&info->port.count));
43393 #endif
43394
43395 /*
43396 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43397 for (j = 0; j < cy_card[i].nports; j++) {
43398 info = &cy_card[i].ports[j];
43399
43400 - if (info->port.count) {
43401 + if (atomic_read(&info->port.count)) {
43402 /* XXX is the ldisc num worth this? */
43403 struct tty_struct *tty;
43404 struct tty_ldisc *ld;
43405 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43406 index eb255e8..f637a57 100644
43407 --- a/drivers/tty/hvc/hvc_console.c
43408 +++ b/drivers/tty/hvc/hvc_console.c
43409 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43410
43411 spin_lock_irqsave(&hp->port.lock, flags);
43412 /* Check and then increment for fast path open. */
43413 - if (hp->port.count++ > 0) {
43414 + if (atomic_inc_return(&hp->port.count) > 1) {
43415 spin_unlock_irqrestore(&hp->port.lock, flags);
43416 hvc_kick();
43417 return 0;
43418 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43419
43420 spin_lock_irqsave(&hp->port.lock, flags);
43421
43422 - if (--hp->port.count == 0) {
43423 + if (atomic_dec_return(&hp->port.count) == 0) {
43424 spin_unlock_irqrestore(&hp->port.lock, flags);
43425 /* We are done with the tty pointer now. */
43426 tty_port_tty_set(&hp->port, NULL);
43427 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43428 */
43429 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43430 } else {
43431 - if (hp->port.count < 0)
43432 + if (atomic_read(&hp->port.count) < 0)
43433 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43434 - hp->vtermno, hp->port.count);
43435 + hp->vtermno, atomic_read(&hp->port.count));
43436 spin_unlock_irqrestore(&hp->port.lock, flags);
43437 }
43438 }
43439 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43440 * open->hangup case this can be called after the final close so prevent
43441 * that from happening for now.
43442 */
43443 - if (hp->port.count <= 0) {
43444 + if (atomic_read(&hp->port.count) <= 0) {
43445 spin_unlock_irqrestore(&hp->port.lock, flags);
43446 return;
43447 }
43448
43449 - hp->port.count = 0;
43450 + atomic_set(&hp->port.count, 0);
43451 spin_unlock_irqrestore(&hp->port.lock, flags);
43452 tty_port_tty_set(&hp->port, NULL);
43453
43454 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43455 return -EPIPE;
43456
43457 /* FIXME what's this (unprotected) check for? */
43458 - if (hp->port.count <= 0)
43459 + if (atomic_read(&hp->port.count) <= 0)
43460 return -EIO;
43461
43462 spin_lock_irqsave(&hp->lock, flags);
43463 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43464 index 81e939e..95ead10 100644
43465 --- a/drivers/tty/hvc/hvcs.c
43466 +++ b/drivers/tty/hvc/hvcs.c
43467 @@ -83,6 +83,7 @@
43468 #include <asm/hvcserver.h>
43469 #include <asm/uaccess.h>
43470 #include <asm/vio.h>
43471 +#include <asm/local.h>
43472
43473 /*
43474 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43475 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43476
43477 spin_lock_irqsave(&hvcsd->lock, flags);
43478
43479 - if (hvcsd->port.count > 0) {
43480 + if (atomic_read(&hvcsd->port.count) > 0) {
43481 spin_unlock_irqrestore(&hvcsd->lock, flags);
43482 printk(KERN_INFO "HVCS: vterm state unchanged. "
43483 "The hvcs device node is still in use.\n");
43484 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43485 }
43486 }
43487
43488 - hvcsd->port.count = 0;
43489 + atomic_set(&hvcsd->port.count, 0);
43490 hvcsd->port.tty = tty;
43491 tty->driver_data = hvcsd;
43492
43493 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43494 unsigned long flags;
43495
43496 spin_lock_irqsave(&hvcsd->lock, flags);
43497 - hvcsd->port.count++;
43498 + atomic_inc(&hvcsd->port.count);
43499 hvcsd->todo_mask |= HVCS_SCHED_READ;
43500 spin_unlock_irqrestore(&hvcsd->lock, flags);
43501
43502 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43503 hvcsd = tty->driver_data;
43504
43505 spin_lock_irqsave(&hvcsd->lock, flags);
43506 - if (--hvcsd->port.count == 0) {
43507 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43508
43509 vio_disable_interrupts(hvcsd->vdev);
43510
43511 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43512
43513 free_irq(irq, hvcsd);
43514 return;
43515 - } else if (hvcsd->port.count < 0) {
43516 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43517 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43518 " is missmanaged.\n",
43519 - hvcsd->vdev->unit_address, hvcsd->port.count);
43520 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43521 }
43522
43523 spin_unlock_irqrestore(&hvcsd->lock, flags);
43524 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43525
43526 spin_lock_irqsave(&hvcsd->lock, flags);
43527 /* Preserve this so that we know how many kref refs to put */
43528 - temp_open_count = hvcsd->port.count;
43529 + temp_open_count = atomic_read(&hvcsd->port.count);
43530
43531 /*
43532 * Don't kref put inside the spinlock because the destruction
43533 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43534 tty->driver_data = NULL;
43535 hvcsd->port.tty = NULL;
43536
43537 - hvcsd->port.count = 0;
43538 + atomic_set(&hvcsd->port.count, 0);
43539
43540 /* This will drop any buffered data on the floor which is OK in a hangup
43541 * scenario. */
43542 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
43543 * the middle of a write operation? This is a crummy place to do this
43544 * but we want to keep it all in the spinlock.
43545 */
43546 - if (hvcsd->port.count <= 0) {
43547 + if (atomic_read(&hvcsd->port.count) <= 0) {
43548 spin_unlock_irqrestore(&hvcsd->lock, flags);
43549 return -ENODEV;
43550 }
43551 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43552 {
43553 struct hvcs_struct *hvcsd = tty->driver_data;
43554
43555 - if (!hvcsd || hvcsd->port.count <= 0)
43556 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43557 return 0;
43558
43559 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43560 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43561 index 8fd72ff..34a0bed 100644
43562 --- a/drivers/tty/ipwireless/tty.c
43563 +++ b/drivers/tty/ipwireless/tty.c
43564 @@ -29,6 +29,7 @@
43565 #include <linux/tty_driver.h>
43566 #include <linux/tty_flip.h>
43567 #include <linux/uaccess.h>
43568 +#include <asm/local.h>
43569
43570 #include "tty.h"
43571 #include "network.h"
43572 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43573 mutex_unlock(&tty->ipw_tty_mutex);
43574 return -ENODEV;
43575 }
43576 - if (tty->port.count == 0)
43577 + if (atomic_read(&tty->port.count) == 0)
43578 tty->tx_bytes_queued = 0;
43579
43580 - tty->port.count++;
43581 + atomic_inc(&tty->port.count);
43582
43583 tty->port.tty = linux_tty;
43584 linux_tty->driver_data = tty;
43585 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43586
43587 static void do_ipw_close(struct ipw_tty *tty)
43588 {
43589 - tty->port.count--;
43590 -
43591 - if (tty->port.count == 0) {
43592 + if (atomic_dec_return(&tty->port.count) == 0) {
43593 struct tty_struct *linux_tty = tty->port.tty;
43594
43595 if (linux_tty != NULL) {
43596 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43597 return;
43598
43599 mutex_lock(&tty->ipw_tty_mutex);
43600 - if (tty->port.count == 0) {
43601 + if (atomic_read(&tty->port.count) == 0) {
43602 mutex_unlock(&tty->ipw_tty_mutex);
43603 return;
43604 }
43605 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43606
43607 mutex_lock(&tty->ipw_tty_mutex);
43608
43609 - if (!tty->port.count) {
43610 + if (!atomic_read(&tty->port.count)) {
43611 mutex_unlock(&tty->ipw_tty_mutex);
43612 return;
43613 }
43614 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43615 return -ENODEV;
43616
43617 mutex_lock(&tty->ipw_tty_mutex);
43618 - if (!tty->port.count) {
43619 + if (!atomic_read(&tty->port.count)) {
43620 mutex_unlock(&tty->ipw_tty_mutex);
43621 return -EINVAL;
43622 }
43623 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43624 if (!tty)
43625 return -ENODEV;
43626
43627 - if (!tty->port.count)
43628 + if (!atomic_read(&tty->port.count))
43629 return -EINVAL;
43630
43631 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43632 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43633 if (!tty)
43634 return 0;
43635
43636 - if (!tty->port.count)
43637 + if (!atomic_read(&tty->port.count))
43638 return 0;
43639
43640 return tty->tx_bytes_queued;
43641 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43642 if (!tty)
43643 return -ENODEV;
43644
43645 - if (!tty->port.count)
43646 + if (!atomic_read(&tty->port.count))
43647 return -EINVAL;
43648
43649 return get_control_lines(tty);
43650 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43651 if (!tty)
43652 return -ENODEV;
43653
43654 - if (!tty->port.count)
43655 + if (!atomic_read(&tty->port.count))
43656 return -EINVAL;
43657
43658 return set_control_lines(tty, set, clear);
43659 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43660 if (!tty)
43661 return -ENODEV;
43662
43663 - if (!tty->port.count)
43664 + if (!atomic_read(&tty->port.count))
43665 return -EINVAL;
43666
43667 /* FIXME: Exactly how is the tty object locked here .. */
43668 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43669 * are gone */
43670 mutex_lock(&ttyj->ipw_tty_mutex);
43671 }
43672 - while (ttyj->port.count)
43673 + while (atomic_read(&ttyj->port.count))
43674 do_ipw_close(ttyj);
43675 ipwireless_disassociate_network_ttys(network,
43676 ttyj->channel_idx);
43677 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43678 index 1deaca4..c8582d4 100644
43679 --- a/drivers/tty/moxa.c
43680 +++ b/drivers/tty/moxa.c
43681 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43682 }
43683
43684 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43685 - ch->port.count++;
43686 + atomic_inc(&ch->port.count);
43687 tty->driver_data = ch;
43688 tty_port_tty_set(&ch->port, tty);
43689 mutex_lock(&ch->port.mutex);
43690 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43691 index 6422390..49003ac8 100644
43692 --- a/drivers/tty/n_gsm.c
43693 +++ b/drivers/tty/n_gsm.c
43694 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43695 spin_lock_init(&dlci->lock);
43696 mutex_init(&dlci->mutex);
43697 dlci->fifo = &dlci->_fifo;
43698 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43699 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43700 kfree(dlci);
43701 return NULL;
43702 }
43703 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43704 struct gsm_dlci *dlci = tty->driver_data;
43705 struct tty_port *port = &dlci->port;
43706
43707 - port->count++;
43708 + atomic_inc(&port->count);
43709 dlci_get(dlci);
43710 dlci_get(dlci->gsm->dlci[0]);
43711 mux_get(dlci->gsm);
43712 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43713 index 6c7fe90..9241dab 100644
43714 --- a/drivers/tty/n_tty.c
43715 +++ b/drivers/tty/n_tty.c
43716 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43717 {
43718 *ops = tty_ldisc_N_TTY;
43719 ops->owner = NULL;
43720 - ops->refcount = ops->flags = 0;
43721 + atomic_set(&ops->refcount, 0);
43722 + ops->flags = 0;
43723 }
43724 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43725 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43726 index abfd990..5ab5da9 100644
43727 --- a/drivers/tty/pty.c
43728 +++ b/drivers/tty/pty.c
43729 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
43730 panic("Couldn't register Unix98 pts driver");
43731
43732 /* Now create the /dev/ptmx special device */
43733 + pax_open_kernel();
43734 tty_default_fops(&ptmx_fops);
43735 - ptmx_fops.open = ptmx_open;
43736 + *(void **)&ptmx_fops.open = ptmx_open;
43737 + pax_close_kernel();
43738
43739 cdev_init(&ptmx_cdev, &ptmx_fops);
43740 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43741 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43742 index 354564e..fe50d9a 100644
43743 --- a/drivers/tty/rocket.c
43744 +++ b/drivers/tty/rocket.c
43745 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43746 tty->driver_data = info;
43747 tty_port_tty_set(port, tty);
43748
43749 - if (port->count++ == 0) {
43750 + if (atomic_inc_return(&port->count) == 1) {
43751 atomic_inc(&rp_num_ports_open);
43752
43753 #ifdef ROCKET_DEBUG_OPEN
43754 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43755 #endif
43756 }
43757 #ifdef ROCKET_DEBUG_OPEN
43758 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43759 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43760 #endif
43761
43762 /*
43763 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
43764 spin_unlock_irqrestore(&info->port.lock, flags);
43765 return;
43766 }
43767 - if (info->port.count)
43768 + if (atomic_read(&info->port.count))
43769 atomic_dec(&rp_num_ports_open);
43770 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43771 spin_unlock_irqrestore(&info->port.lock, flags);
43772 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43773 index 1002054..dd644a8 100644
43774 --- a/drivers/tty/serial/kgdboc.c
43775 +++ b/drivers/tty/serial/kgdboc.c
43776 @@ -24,8 +24,9 @@
43777 #define MAX_CONFIG_LEN 40
43778
43779 static struct kgdb_io kgdboc_io_ops;
43780 +static struct kgdb_io kgdboc_io_ops_console;
43781
43782 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43783 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43784 static int configured = -1;
43785
43786 static char config[MAX_CONFIG_LEN];
43787 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43788 kgdboc_unregister_kbd();
43789 if (configured == 1)
43790 kgdb_unregister_io_module(&kgdboc_io_ops);
43791 + else if (configured == 2)
43792 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43793 }
43794
43795 static int configure_kgdboc(void)
43796 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43797 int err;
43798 char *cptr = config;
43799 struct console *cons;
43800 + int is_console = 0;
43801
43802 err = kgdboc_option_setup(config);
43803 if (err || !strlen(config) || isspace(config[0]))
43804 goto noconfig;
43805
43806 err = -ENODEV;
43807 - kgdboc_io_ops.is_console = 0;
43808 kgdb_tty_driver = NULL;
43809
43810 kgdboc_use_kms = 0;
43811 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43812 int idx;
43813 if (cons->device && cons->device(cons, &idx) == p &&
43814 idx == tty_line) {
43815 - kgdboc_io_ops.is_console = 1;
43816 + is_console = 1;
43817 break;
43818 }
43819 cons = cons->next;
43820 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43821 kgdb_tty_line = tty_line;
43822
43823 do_register:
43824 - err = kgdb_register_io_module(&kgdboc_io_ops);
43825 + if (is_console) {
43826 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43827 + configured = 2;
43828 + } else {
43829 + err = kgdb_register_io_module(&kgdboc_io_ops);
43830 + configured = 1;
43831 + }
43832 if (err)
43833 goto noconfig;
43834
43835 @@ -205,8 +214,6 @@ do_register:
43836 if (err)
43837 goto nmi_con_failed;
43838
43839 - configured = 1;
43840 -
43841 return 0;
43842
43843 nmi_con_failed:
43844 @@ -223,7 +230,7 @@ noconfig:
43845 static int __init init_kgdboc(void)
43846 {
43847 /* Already configured? */
43848 - if (configured == 1)
43849 + if (configured >= 1)
43850 return 0;
43851
43852 return configure_kgdboc();
43853 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43854 if (config[len - 1] == '\n')
43855 config[len - 1] = '\0';
43856
43857 - if (configured == 1)
43858 + if (configured >= 1)
43859 cleanup_kgdboc();
43860
43861 /* Go and configure with the new params. */
43862 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43863 .post_exception = kgdboc_post_exp_handler,
43864 };
43865
43866 +static struct kgdb_io kgdboc_io_ops_console = {
43867 + .name = "kgdboc",
43868 + .read_char = kgdboc_get_char,
43869 + .write_char = kgdboc_put_char,
43870 + .pre_exception = kgdboc_pre_exp_handler,
43871 + .post_exception = kgdboc_post_exp_handler,
43872 + .is_console = 1
43873 +};
43874 +
43875 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43876 /* This is only available if kgdboc is a built in for early debugging */
43877 static int __init kgdboc_early_init(char *opt)
43878 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43879 index 0c8a9fa..234a95f 100644
43880 --- a/drivers/tty/serial/samsung.c
43881 +++ b/drivers/tty/serial/samsung.c
43882 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43883 }
43884 }
43885
43886 +static int s3c64xx_serial_startup(struct uart_port *port);
43887 static int s3c24xx_serial_startup(struct uart_port *port)
43888 {
43889 struct s3c24xx_uart_port *ourport = to_ourport(port);
43890 int ret;
43891
43892 + /* Startup sequence is different for s3c64xx and higher SoC's */
43893 + if (s3c24xx_serial_has_interrupt_mask(port))
43894 + return s3c64xx_serial_startup(port);
43895 +
43896 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43897 port->mapbase, port->membase);
43898
43899 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43900 /* setup info for port */
43901 port->dev = &platdev->dev;
43902
43903 - /* Startup sequence is different for s3c64xx and higher SoC's */
43904 - if (s3c24xx_serial_has_interrupt_mask(port))
43905 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43906 -
43907 port->uartclk = 1;
43908
43909 if (cfg->uart_flags & UPF_CONS_FLOW) {
43910 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43911 index f87dbfd..42ad4b1 100644
43912 --- a/drivers/tty/serial/serial_core.c
43913 +++ b/drivers/tty/serial/serial_core.c
43914 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43915 uart_flush_buffer(tty);
43916 uart_shutdown(tty, state);
43917 spin_lock_irqsave(&port->lock, flags);
43918 - port->count = 0;
43919 + atomic_set(&port->count, 0);
43920 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43921 spin_unlock_irqrestore(&port->lock, flags);
43922 tty_port_tty_set(port, NULL);
43923 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43924 goto end;
43925 }
43926
43927 - port->count++;
43928 + atomic_inc(&port->count);
43929 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43930 retval = -ENXIO;
43931 goto err_dec_count;
43932 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43933 /*
43934 * Make sure the device is in D0 state.
43935 */
43936 - if (port->count == 1)
43937 + if (atomic_read(&port->count) == 1)
43938 uart_change_pm(state, UART_PM_STATE_ON);
43939
43940 /*
43941 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43942 end:
43943 return retval;
43944 err_dec_count:
43945 - port->count--;
43946 + atomic_inc(&port->count);
43947 mutex_unlock(&port->mutex);
43948 goto end;
43949 }
43950 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43951 index 8eaf1ab..85c030d 100644
43952 --- a/drivers/tty/synclink.c
43953 +++ b/drivers/tty/synclink.c
43954 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43955
43956 if (debug_level >= DEBUG_LEVEL_INFO)
43957 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43958 - __FILE__,__LINE__, info->device_name, info->port.count);
43959 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43960
43961 if (tty_port_close_start(&info->port, tty, filp) == 0)
43962 goto cleanup;
43963 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43964 cleanup:
43965 if (debug_level >= DEBUG_LEVEL_INFO)
43966 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43967 - tty->driver->name, info->port.count);
43968 + tty->driver->name, atomic_read(&info->port.count));
43969
43970 } /* end of mgsl_close() */
43971
43972 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43973
43974 mgsl_flush_buffer(tty);
43975 shutdown(info);
43976 -
43977 - info->port.count = 0;
43978 +
43979 + atomic_set(&info->port.count, 0);
43980 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43981 info->port.tty = NULL;
43982
43983 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43984
43985 if (debug_level >= DEBUG_LEVEL_INFO)
43986 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43987 - __FILE__,__LINE__, tty->driver->name, port->count );
43988 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43989
43990 spin_lock_irqsave(&info->irq_spinlock, flags);
43991 if (!tty_hung_up_p(filp)) {
43992 extra_count = true;
43993 - port->count--;
43994 + atomic_dec(&port->count);
43995 }
43996 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43997 port->blocked_open++;
43998 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43999
44000 if (debug_level >= DEBUG_LEVEL_INFO)
44001 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
44002 - __FILE__,__LINE__, tty->driver->name, port->count );
44003 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44004
44005 tty_unlock(tty);
44006 schedule();
44007 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44008
44009 /* FIXME: Racy on hangup during close wait */
44010 if (extra_count)
44011 - port->count++;
44012 + atomic_inc(&port->count);
44013 port->blocked_open--;
44014
44015 if (debug_level >= DEBUG_LEVEL_INFO)
44016 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
44017 - __FILE__,__LINE__, tty->driver->name, port->count );
44018 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44019
44020 if (!retval)
44021 port->flags |= ASYNC_NORMAL_ACTIVE;
44022 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44023
44024 if (debug_level >= DEBUG_LEVEL_INFO)
44025 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
44026 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44027 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44028
44029 /* If port is closing, signal caller to try again */
44030 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44031 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44032 spin_unlock_irqrestore(&info->netlock, flags);
44033 goto cleanup;
44034 }
44035 - info->port.count++;
44036 + atomic_inc(&info->port.count);
44037 spin_unlock_irqrestore(&info->netlock, flags);
44038
44039 - if (info->port.count == 1) {
44040 + if (atomic_read(&info->port.count) == 1) {
44041 /* 1st open on this device, init hardware */
44042 retval = startup(info);
44043 if (retval < 0)
44044 @@ -3446,8 +3446,8 @@ cleanup:
44045 if (retval) {
44046 if (tty->count == 1)
44047 info->port.tty = NULL; /* tty layer will release tty struct */
44048 - if(info->port.count)
44049 - info->port.count--;
44050 + if (atomic_read(&info->port.count))
44051 + atomic_dec(&info->port.count);
44052 }
44053
44054 return retval;
44055 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44056 unsigned short new_crctype;
44057
44058 /* return error if TTY interface open */
44059 - if (info->port.count)
44060 + if (atomic_read(&info->port.count))
44061 return -EBUSY;
44062
44063 switch (encoding)
44064 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
44065
44066 /* arbitrate between network and tty opens */
44067 spin_lock_irqsave(&info->netlock, flags);
44068 - if (info->port.count != 0 || info->netcount != 0) {
44069 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44070 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44071 spin_unlock_irqrestore(&info->netlock, flags);
44072 return -EBUSY;
44073 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44074 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44075
44076 /* return error if TTY interface open */
44077 - if (info->port.count)
44078 + if (atomic_read(&info->port.count))
44079 return -EBUSY;
44080
44081 if (cmd != SIOCWANDEV)
44082 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44083 index 1abf946..1ee34fc 100644
44084 --- a/drivers/tty/synclink_gt.c
44085 +++ b/drivers/tty/synclink_gt.c
44086 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44087 tty->driver_data = info;
44088 info->port.tty = tty;
44089
44090 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44091 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44092
44093 /* If port is closing, signal caller to try again */
44094 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44095 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44096 mutex_unlock(&info->port.mutex);
44097 goto cleanup;
44098 }
44099 - info->port.count++;
44100 + atomic_inc(&info->port.count);
44101 spin_unlock_irqrestore(&info->netlock, flags);
44102
44103 - if (info->port.count == 1) {
44104 + if (atomic_read(&info->port.count) == 1) {
44105 /* 1st open on this device, init hardware */
44106 retval = startup(info);
44107 if (retval < 0) {
44108 @@ -715,8 +715,8 @@ cleanup:
44109 if (retval) {
44110 if (tty->count == 1)
44111 info->port.tty = NULL; /* tty layer will release tty struct */
44112 - if(info->port.count)
44113 - info->port.count--;
44114 + if(atomic_read(&info->port.count))
44115 + atomic_dec(&info->port.count);
44116 }
44117
44118 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44119 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44120
44121 if (sanity_check(info, tty->name, "close"))
44122 return;
44123 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44124 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44125
44126 if (tty_port_close_start(&info->port, tty, filp) == 0)
44127 goto cleanup;
44128 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44129 tty_port_close_end(&info->port, tty);
44130 info->port.tty = NULL;
44131 cleanup:
44132 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44133 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44134 }
44135
44136 static void hangup(struct tty_struct *tty)
44137 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
44138 shutdown(info);
44139
44140 spin_lock_irqsave(&info->port.lock, flags);
44141 - info->port.count = 0;
44142 + atomic_set(&info->port.count, 0);
44143 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44144 info->port.tty = NULL;
44145 spin_unlock_irqrestore(&info->port.lock, flags);
44146 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44147 unsigned short new_crctype;
44148
44149 /* return error if TTY interface open */
44150 - if (info->port.count)
44151 + if (atomic_read(&info->port.count))
44152 return -EBUSY;
44153
44154 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44155 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
44156
44157 /* arbitrate between network and tty opens */
44158 spin_lock_irqsave(&info->netlock, flags);
44159 - if (info->port.count != 0 || info->netcount != 0) {
44160 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44161 DBGINFO(("%s hdlc_open busy\n", dev->name));
44162 spin_unlock_irqrestore(&info->netlock, flags);
44163 return -EBUSY;
44164 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44165 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44166
44167 /* return error if TTY interface open */
44168 - if (info->port.count)
44169 + if (atomic_read(&info->port.count))
44170 return -EBUSY;
44171
44172 if (cmd != SIOCWANDEV)
44173 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44174 if (port == NULL)
44175 continue;
44176 spin_lock(&port->lock);
44177 - if ((port->port.count || port->netcount) &&
44178 + if ((atomic_read(&port->port.count) || port->netcount) &&
44179 port->pending_bh && !port->bh_running &&
44180 !port->bh_requested) {
44181 DBGISR(("%s bh queued\n", port->device_name));
44182 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44183 spin_lock_irqsave(&info->lock, flags);
44184 if (!tty_hung_up_p(filp)) {
44185 extra_count = true;
44186 - port->count--;
44187 + atomic_dec(&port->count);
44188 }
44189 spin_unlock_irqrestore(&info->lock, flags);
44190 port->blocked_open++;
44191 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44192 remove_wait_queue(&port->open_wait, &wait);
44193
44194 if (extra_count)
44195 - port->count++;
44196 + atomic_inc(&port->count);
44197 port->blocked_open--;
44198
44199 if (!retval)
44200 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44201 index ff17138..e38b41e 100644
44202 --- a/drivers/tty/synclinkmp.c
44203 +++ b/drivers/tty/synclinkmp.c
44204 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44205
44206 if (debug_level >= DEBUG_LEVEL_INFO)
44207 printk("%s(%d):%s open(), old ref count = %d\n",
44208 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44209 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44210
44211 /* If port is closing, signal caller to try again */
44212 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44213 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44214 spin_unlock_irqrestore(&info->netlock, flags);
44215 goto cleanup;
44216 }
44217 - info->port.count++;
44218 + atomic_inc(&info->port.count);
44219 spin_unlock_irqrestore(&info->netlock, flags);
44220
44221 - if (info->port.count == 1) {
44222 + if (atomic_read(&info->port.count) == 1) {
44223 /* 1st open on this device, init hardware */
44224 retval = startup(info);
44225 if (retval < 0)
44226 @@ -796,8 +796,8 @@ cleanup:
44227 if (retval) {
44228 if (tty->count == 1)
44229 info->port.tty = NULL; /* tty layer will release tty struct */
44230 - if(info->port.count)
44231 - info->port.count--;
44232 + if(atomic_read(&info->port.count))
44233 + atomic_dec(&info->port.count);
44234 }
44235
44236 return retval;
44237 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44238
44239 if (debug_level >= DEBUG_LEVEL_INFO)
44240 printk("%s(%d):%s close() entry, count=%d\n",
44241 - __FILE__,__LINE__, info->device_name, info->port.count);
44242 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44243
44244 if (tty_port_close_start(&info->port, tty, filp) == 0)
44245 goto cleanup;
44246 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44247 cleanup:
44248 if (debug_level >= DEBUG_LEVEL_INFO)
44249 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44250 - tty->driver->name, info->port.count);
44251 + tty->driver->name, atomic_read(&info->port.count));
44252 }
44253
44254 /* Called by tty_hangup() when a hangup is signaled.
44255 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
44256 shutdown(info);
44257
44258 spin_lock_irqsave(&info->port.lock, flags);
44259 - info->port.count = 0;
44260 + atomic_set(&info->port.count, 0);
44261 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44262 info->port.tty = NULL;
44263 spin_unlock_irqrestore(&info->port.lock, flags);
44264 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44265 unsigned short new_crctype;
44266
44267 /* return error if TTY interface open */
44268 - if (info->port.count)
44269 + if (atomic_read(&info->port.count))
44270 return -EBUSY;
44271
44272 switch (encoding)
44273 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
44274
44275 /* arbitrate between network and tty opens */
44276 spin_lock_irqsave(&info->netlock, flags);
44277 - if (info->port.count != 0 || info->netcount != 0) {
44278 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44279 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44280 spin_unlock_irqrestore(&info->netlock, flags);
44281 return -EBUSY;
44282 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44283 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44284
44285 /* return error if TTY interface open */
44286 - if (info->port.count)
44287 + if (atomic_read(&info->port.count))
44288 return -EBUSY;
44289
44290 if (cmd != SIOCWANDEV)
44291 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44292 * do not request bottom half processing if the
44293 * device is not open in a normal mode.
44294 */
44295 - if ( port && (port->port.count || port->netcount) &&
44296 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44297 port->pending_bh && !port->bh_running &&
44298 !port->bh_requested ) {
44299 if ( debug_level >= DEBUG_LEVEL_ISR )
44300 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44301
44302 if (debug_level >= DEBUG_LEVEL_INFO)
44303 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44304 - __FILE__,__LINE__, tty->driver->name, port->count );
44305 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44306
44307 spin_lock_irqsave(&info->lock, flags);
44308 if (!tty_hung_up_p(filp)) {
44309 extra_count = true;
44310 - port->count--;
44311 + atomic_dec(&port->count);
44312 }
44313 spin_unlock_irqrestore(&info->lock, flags);
44314 port->blocked_open++;
44315 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44316
44317 if (debug_level >= DEBUG_LEVEL_INFO)
44318 printk("%s(%d):%s block_til_ready() count=%d\n",
44319 - __FILE__,__LINE__, tty->driver->name, port->count );
44320 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44321
44322 tty_unlock(tty);
44323 schedule();
44324 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44325 remove_wait_queue(&port->open_wait, &wait);
44326
44327 if (extra_count)
44328 - port->count++;
44329 + atomic_inc(&port->count);
44330 port->blocked_open--;
44331
44332 if (debug_level >= DEBUG_LEVEL_INFO)
44333 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44334 - __FILE__,__LINE__, tty->driver->name, port->count );
44335 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44336
44337 if (!retval)
44338 port->flags |= ASYNC_NORMAL_ACTIVE;
44339 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44340 index b51c154..17d55d1 100644
44341 --- a/drivers/tty/sysrq.c
44342 +++ b/drivers/tty/sysrq.c
44343 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44344 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44345 size_t count, loff_t *ppos)
44346 {
44347 - if (count) {
44348 + if (count && capable(CAP_SYS_ADMIN)) {
44349 char c;
44350
44351 if (get_user(c, buf))
44352 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44353 index 4476682..d77e748 100644
44354 --- a/drivers/tty/tty_io.c
44355 +++ b/drivers/tty/tty_io.c
44356 @@ -3466,7 +3466,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44357
44358 void tty_default_fops(struct file_operations *fops)
44359 {
44360 - *fops = tty_fops;
44361 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44362 }
44363
44364 /*
44365 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44366 index 1afe192..73d2c20 100644
44367 --- a/drivers/tty/tty_ldisc.c
44368 +++ b/drivers/tty/tty_ldisc.c
44369 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44370 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44371 tty_ldiscs[disc] = new_ldisc;
44372 new_ldisc->num = disc;
44373 - new_ldisc->refcount = 0;
44374 + atomic_set(&new_ldisc->refcount, 0);
44375 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44376
44377 return ret;
44378 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
44379 return -EINVAL;
44380
44381 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44382 - if (tty_ldiscs[disc]->refcount)
44383 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44384 ret = -EBUSY;
44385 else
44386 tty_ldiscs[disc] = NULL;
44387 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44388 if (ldops) {
44389 ret = ERR_PTR(-EAGAIN);
44390 if (try_module_get(ldops->owner)) {
44391 - ldops->refcount++;
44392 + atomic_inc(&ldops->refcount);
44393 ret = ldops;
44394 }
44395 }
44396 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44397 unsigned long flags;
44398
44399 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44400 - ldops->refcount--;
44401 + atomic_dec(&ldops->refcount);
44402 module_put(ldops->owner);
44403 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44404 }
44405 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
44406 /* unreleased reader reference(s) will cause this WARN */
44407 WARN_ON(!atomic_dec_and_test(&ld->users));
44408
44409 - ld->ops->refcount--;
44410 + atomic_dec(&ld->ops->refcount);
44411 module_put(ld->ops->owner);
44412 kfree(ld);
44413 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44414 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44415 index 121aeb9..0d2c4b9 100644
44416 --- a/drivers/tty/tty_port.c
44417 +++ b/drivers/tty/tty_port.c
44418 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
44419 unsigned long flags;
44420
44421 spin_lock_irqsave(&port->lock, flags);
44422 - port->count = 0;
44423 + atomic_set(&port->count, 0);
44424 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44425 tty = port->tty;
44426 if (tty)
44427 @@ -391,7 +391,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44428 /* The port lock protects the port counts */
44429 spin_lock_irqsave(&port->lock, flags);
44430 if (!tty_hung_up_p(filp))
44431 - port->count--;
44432 + atomic_dec(&port->count);
44433 port->blocked_open++;
44434 spin_unlock_irqrestore(&port->lock, flags);
44435
44436 @@ -433,7 +433,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44437 we must not mess that up further */
44438 spin_lock_irqsave(&port->lock, flags);
44439 if (!tty_hung_up_p(filp))
44440 - port->count++;
44441 + atomic_inc(&port->count);
44442 port->blocked_open--;
44443 if (retval == 0)
44444 port->flags |= ASYNC_NORMAL_ACTIVE;
44445 @@ -467,19 +467,19 @@ int tty_port_close_start(struct tty_port *port,
44446 return 0;
44447 }
44448
44449 - if (tty->count == 1 && port->count != 1) {
44450 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44451 printk(KERN_WARNING
44452 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44453 - port->count);
44454 - port->count = 1;
44455 + atomic_read(&port->count));
44456 + atomic_set(&port->count, 1);
44457 }
44458 - if (--port->count < 0) {
44459 + if (atomic_dec_return(&port->count) < 0) {
44460 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44461 - port->count);
44462 - port->count = 0;
44463 + atomic_read(&port->count));
44464 + atomic_set(&port->count, 0);
44465 }
44466
44467 - if (port->count) {
44468 + if (atomic_read(&port->count)) {
44469 spin_unlock_irqrestore(&port->lock, flags);
44470 if (port->ops->drop)
44471 port->ops->drop(port);
44472 @@ -565,7 +565,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44473 {
44474 spin_lock_irq(&port->lock);
44475 if (!tty_hung_up_p(filp))
44476 - ++port->count;
44477 + atomic_inc(&port->count);
44478 spin_unlock_irq(&port->lock);
44479 tty_port_tty_set(port, tty);
44480
44481 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44482 index a9af1b9a..1e08e7f 100644
44483 --- a/drivers/tty/vt/keyboard.c
44484 +++ b/drivers/tty/vt/keyboard.c
44485 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44486 kbd->kbdmode == VC_OFF) &&
44487 value != KVAL(K_SAK))
44488 return; /* SAK is allowed even in raw mode */
44489 +
44490 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44491 + {
44492 + void *func = fn_handler[value];
44493 + if (func == fn_show_state || func == fn_show_ptregs ||
44494 + func == fn_show_mem)
44495 + return;
44496 + }
44497 +#endif
44498 +
44499 fn_handler[value](vc);
44500 }
44501
44502 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44503 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44504 return -EFAULT;
44505
44506 - if (!capable(CAP_SYS_TTY_CONFIG))
44507 - perm = 0;
44508 -
44509 switch (cmd) {
44510 case KDGKBENT:
44511 /* Ensure another thread doesn't free it under us */
44512 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44513 spin_unlock_irqrestore(&kbd_event_lock, flags);
44514 return put_user(val, &user_kbe->kb_value);
44515 case KDSKBENT:
44516 + if (!capable(CAP_SYS_TTY_CONFIG))
44517 + perm = 0;
44518 +
44519 if (!perm)
44520 return -EPERM;
44521 if (!i && v == K_NOSUCHMAP) {
44522 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44523 int i, j, k;
44524 int ret;
44525
44526 - if (!capable(CAP_SYS_TTY_CONFIG))
44527 - perm = 0;
44528 -
44529 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44530 if (!kbs) {
44531 ret = -ENOMEM;
44532 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44533 kfree(kbs);
44534 return ((p && *p) ? -EOVERFLOW : 0);
44535 case KDSKBSENT:
44536 + if (!capable(CAP_SYS_TTY_CONFIG))
44537 + perm = 0;
44538 +
44539 if (!perm) {
44540 ret = -EPERM;
44541 goto reterr;
44542 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44543 index b645c47..a55c182 100644
44544 --- a/drivers/uio/uio.c
44545 +++ b/drivers/uio/uio.c
44546 @@ -25,6 +25,7 @@
44547 #include <linux/kobject.h>
44548 #include <linux/cdev.h>
44549 #include <linux/uio_driver.h>
44550 +#include <asm/local.h>
44551
44552 #define UIO_MAX_DEVICES (1U << MINORBITS)
44553
44554 @@ -32,10 +33,10 @@ struct uio_device {
44555 struct module *owner;
44556 struct device *dev;
44557 int minor;
44558 - atomic_t event;
44559 + atomic_unchecked_t event;
44560 struct fasync_struct *async_queue;
44561 wait_queue_head_t wait;
44562 - int vma_count;
44563 + local_t vma_count;
44564 struct uio_info *info;
44565 struct kobject *map_dir;
44566 struct kobject *portio_dir;
44567 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44568 struct device_attribute *attr, char *buf)
44569 {
44570 struct uio_device *idev = dev_get_drvdata(dev);
44571 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44572 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44573 }
44574
44575 static struct device_attribute uio_class_attributes[] = {
44576 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
44577 {
44578 struct uio_device *idev = info->uio_dev;
44579
44580 - atomic_inc(&idev->event);
44581 + atomic_inc_unchecked(&idev->event);
44582 wake_up_interruptible(&idev->wait);
44583 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44584 }
44585 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44586 }
44587
44588 listener->dev = idev;
44589 - listener->event_count = atomic_read(&idev->event);
44590 + listener->event_count = atomic_read_unchecked(&idev->event);
44591 filep->private_data = listener;
44592
44593 if (idev->info->open) {
44594 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44595 return -EIO;
44596
44597 poll_wait(filep, &idev->wait, wait);
44598 - if (listener->event_count != atomic_read(&idev->event))
44599 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44600 return POLLIN | POLLRDNORM;
44601 return 0;
44602 }
44603 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44604 do {
44605 set_current_state(TASK_INTERRUPTIBLE);
44606
44607 - event_count = atomic_read(&idev->event);
44608 + event_count = atomic_read_unchecked(&idev->event);
44609 if (event_count != listener->event_count) {
44610 if (copy_to_user(buf, &event_count, count))
44611 retval = -EFAULT;
44612 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44613 static void uio_vma_open(struct vm_area_struct *vma)
44614 {
44615 struct uio_device *idev = vma->vm_private_data;
44616 - idev->vma_count++;
44617 + local_inc(&idev->vma_count);
44618 }
44619
44620 static void uio_vma_close(struct vm_area_struct *vma)
44621 {
44622 struct uio_device *idev = vma->vm_private_data;
44623 - idev->vma_count--;
44624 + local_dec(&idev->vma_count);
44625 }
44626
44627 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44628 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
44629 idev->owner = owner;
44630 idev->info = info;
44631 init_waitqueue_head(&idev->wait);
44632 - atomic_set(&idev->event, 0);
44633 + atomic_set_unchecked(&idev->event, 0);
44634
44635 ret = uio_get_minor(idev);
44636 if (ret)
44637 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44638 index 8a7eb77..c00402f 100644
44639 --- a/drivers/usb/atm/cxacru.c
44640 +++ b/drivers/usb/atm/cxacru.c
44641 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44642 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44643 if (ret < 2)
44644 return -EINVAL;
44645 - if (index < 0 || index > 0x7f)
44646 + if (index > 0x7f)
44647 return -EINVAL;
44648 pos += tmp;
44649
44650 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44651 index d3527dd..26effa2 100644
44652 --- a/drivers/usb/atm/usbatm.c
44653 +++ b/drivers/usb/atm/usbatm.c
44654 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44655 if (printk_ratelimit())
44656 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44657 __func__, vpi, vci);
44658 - atomic_inc(&vcc->stats->rx_err);
44659 + atomic_inc_unchecked(&vcc->stats->rx_err);
44660 return;
44661 }
44662
44663 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44664 if (length > ATM_MAX_AAL5_PDU) {
44665 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44666 __func__, length, vcc);
44667 - atomic_inc(&vcc->stats->rx_err);
44668 + atomic_inc_unchecked(&vcc->stats->rx_err);
44669 goto out;
44670 }
44671
44672 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44673 if (sarb->len < pdu_length) {
44674 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44675 __func__, pdu_length, sarb->len, vcc);
44676 - atomic_inc(&vcc->stats->rx_err);
44677 + atomic_inc_unchecked(&vcc->stats->rx_err);
44678 goto out;
44679 }
44680
44681 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44682 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44683 __func__, vcc);
44684 - atomic_inc(&vcc->stats->rx_err);
44685 + atomic_inc_unchecked(&vcc->stats->rx_err);
44686 goto out;
44687 }
44688
44689 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44690 if (printk_ratelimit())
44691 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44692 __func__, length);
44693 - atomic_inc(&vcc->stats->rx_drop);
44694 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44695 goto out;
44696 }
44697
44698 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44699
44700 vcc->push(vcc, skb);
44701
44702 - atomic_inc(&vcc->stats->rx);
44703 + atomic_inc_unchecked(&vcc->stats->rx);
44704 out:
44705 skb_trim(sarb, 0);
44706 }
44707 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44708 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44709
44710 usbatm_pop(vcc, skb);
44711 - atomic_inc(&vcc->stats->tx);
44712 + atomic_inc_unchecked(&vcc->stats->tx);
44713
44714 skb = skb_dequeue(&instance->sndqueue);
44715 }
44716 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44717 if (!left--)
44718 return sprintf(page,
44719 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44720 - atomic_read(&atm_dev->stats.aal5.tx),
44721 - atomic_read(&atm_dev->stats.aal5.tx_err),
44722 - atomic_read(&atm_dev->stats.aal5.rx),
44723 - atomic_read(&atm_dev->stats.aal5.rx_err),
44724 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44725 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44726 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44727 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44728 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44729 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44730
44731 if (!left--) {
44732 if (instance->disconnected)
44733 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44734 index 2a3bbdf..91d72cf 100644
44735 --- a/drivers/usb/core/devices.c
44736 +++ b/drivers/usb/core/devices.c
44737 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44738 * time it gets called.
44739 */
44740 static struct device_connect_event {
44741 - atomic_t count;
44742 + atomic_unchecked_t count;
44743 wait_queue_head_t wait;
44744 } device_event = {
44745 .count = ATOMIC_INIT(1),
44746 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44747
44748 void usbfs_conn_disc_event(void)
44749 {
44750 - atomic_add(2, &device_event.count);
44751 + atomic_add_unchecked(2, &device_event.count);
44752 wake_up(&device_event.wait);
44753 }
44754
44755 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44756
44757 poll_wait(file, &device_event.wait, wait);
44758
44759 - event_count = atomic_read(&device_event.count);
44760 + event_count = atomic_read_unchecked(&device_event.count);
44761 if (file->f_version != event_count) {
44762 file->f_version = event_count;
44763 return POLLIN | POLLRDNORM;
44764 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44765 index d53547d..6a22d02 100644
44766 --- a/drivers/usb/core/hcd.c
44767 +++ b/drivers/usb/core/hcd.c
44768 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44769 */
44770 usb_get_urb(urb);
44771 atomic_inc(&urb->use_count);
44772 - atomic_inc(&urb->dev->urbnum);
44773 + atomic_inc_unchecked(&urb->dev->urbnum);
44774 usbmon_urb_submit(&hcd->self, urb);
44775
44776 /* NOTE requirements on root-hub callers (usbfs and the hub
44777 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44778 urb->hcpriv = NULL;
44779 INIT_LIST_HEAD(&urb->urb_list);
44780 atomic_dec(&urb->use_count);
44781 - atomic_dec(&urb->dev->urbnum);
44782 + atomic_dec_unchecked(&urb->dev->urbnum);
44783 if (atomic_read(&urb->reject))
44784 wake_up(&usb_kill_urb_queue);
44785 usb_put_urb(urb);
44786 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44787 index 444d30e..f15c850 100644
44788 --- a/drivers/usb/core/message.c
44789 +++ b/drivers/usb/core/message.c
44790 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44791 * method can wait for it to complete. Since you don't have a handle on the
44792 * URB used, you can't cancel the request.
44793 */
44794 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44795 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44796 __u8 requesttype, __u16 value, __u16 index, void *data,
44797 __u16 size, int timeout)
44798 {
44799 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44800 index aa38db4..0a08682 100644
44801 --- a/drivers/usb/core/sysfs.c
44802 +++ b/drivers/usb/core/sysfs.c
44803 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44804 struct usb_device *udev;
44805
44806 udev = to_usb_device(dev);
44807 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44808 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44809 }
44810 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44811
44812 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44813 index b10da72..43aa0b2 100644
44814 --- a/drivers/usb/core/usb.c
44815 +++ b/drivers/usb/core/usb.c
44816 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44817 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44818 dev->state = USB_STATE_ATTACHED;
44819 dev->lpm_disable_count = 1;
44820 - atomic_set(&dev->urbnum, 0);
44821 + atomic_set_unchecked(&dev->urbnum, 0);
44822
44823 INIT_LIST_HEAD(&dev->ep0.urb_list);
44824 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44825 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44826 index 5e29dde..eca992f 100644
44827 --- a/drivers/usb/early/ehci-dbgp.c
44828 +++ b/drivers/usb/early/ehci-dbgp.c
44829 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44830
44831 #ifdef CONFIG_KGDB
44832 static struct kgdb_io kgdbdbgp_io_ops;
44833 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44834 +static struct kgdb_io kgdbdbgp_io_ops_console;
44835 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44836 #else
44837 #define dbgp_kgdb_mode (0)
44838 #endif
44839 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44840 .write_char = kgdbdbgp_write_char,
44841 };
44842
44843 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44844 + .name = "kgdbdbgp",
44845 + .read_char = kgdbdbgp_read_char,
44846 + .write_char = kgdbdbgp_write_char,
44847 + .is_console = 1
44848 +};
44849 +
44850 static int kgdbdbgp_wait_time;
44851
44852 static int __init kgdbdbgp_parse_config(char *str)
44853 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44854 ptr++;
44855 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44856 }
44857 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44858 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44859 + if (early_dbgp_console.index != -1)
44860 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44861 + else
44862 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44863
44864 return 0;
44865 }
44866 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44867 index b369292..9f3ba40 100644
44868 --- a/drivers/usb/gadget/u_serial.c
44869 +++ b/drivers/usb/gadget/u_serial.c
44870 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44871 spin_lock_irq(&port->port_lock);
44872
44873 /* already open? Great. */
44874 - if (port->port.count) {
44875 + if (atomic_read(&port->port.count)) {
44876 status = 0;
44877 - port->port.count++;
44878 + atomic_inc(&port->port.count);
44879
44880 /* currently opening/closing? wait ... */
44881 } else if (port->openclose) {
44882 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44883 tty->driver_data = port;
44884 port->port.tty = tty;
44885
44886 - port->port.count = 1;
44887 + atomic_set(&port->port.count, 1);
44888 port->openclose = false;
44889
44890 /* if connected, start the I/O stream */
44891 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44892
44893 spin_lock_irq(&port->port_lock);
44894
44895 - if (port->port.count != 1) {
44896 - if (port->port.count == 0)
44897 + if (atomic_read(&port->port.count) != 1) {
44898 + if (atomic_read(&port->port.count) == 0)
44899 WARN_ON(1);
44900 else
44901 - --port->port.count;
44902 + atomic_dec(&port->port.count);
44903 goto exit;
44904 }
44905
44906 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44907 * and sleep if necessary
44908 */
44909 port->openclose = true;
44910 - port->port.count = 0;
44911 + atomic_set(&port->port.count, 0);
44912
44913 gser = port->port_usb;
44914 if (gser && gser->disconnect)
44915 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44916 int cond;
44917
44918 spin_lock_irq(&port->port_lock);
44919 - cond = (port->port.count == 0) && !port->openclose;
44920 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44921 spin_unlock_irq(&port->port_lock);
44922 return cond;
44923 }
44924 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44925 /* if it's already open, start I/O ... and notify the serial
44926 * protocol about open/close status (connect/disconnect).
44927 */
44928 - if (port->port.count) {
44929 + if (atomic_read(&port->port.count)) {
44930 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44931 gs_start_io(port);
44932 if (gser->connect)
44933 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44934
44935 port->port_usb = NULL;
44936 gser->ioport = NULL;
44937 - if (port->port.count > 0 || port->openclose) {
44938 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44939 wake_up_interruptible(&port->drain_wait);
44940 if (port->port.tty)
44941 tty_hangup(port->port.tty);
44942 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44943
44944 /* finally, free any unused/unusable I/O buffers */
44945 spin_lock_irqsave(&port->port_lock, flags);
44946 - if (port->port.count == 0 && !port->openclose)
44947 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44948 gs_buf_free(&port->port_write_buf);
44949 gs_free_requests(gser->out, &port->read_pool, NULL);
44950 gs_free_requests(gser->out, &port->read_queue, NULL);
44951 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44952 index 5f3bcd3..bfca43f 100644
44953 --- a/drivers/usb/serial/console.c
44954 +++ b/drivers/usb/serial/console.c
44955 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44956
44957 info->port = port;
44958
44959 - ++port->port.count;
44960 + atomic_inc(&port->port.count);
44961 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44962 if (serial->type->set_termios) {
44963 /*
44964 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44965 }
44966 /* Now that any required fake tty operations are completed restore
44967 * the tty port count */
44968 - --port->port.count;
44969 + atomic_dec(&port->port.count);
44970 /* The console is special in terms of closing the device so
44971 * indicate this port is now acting as a system console. */
44972 port->port.console = 1;
44973 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44974 free_tty:
44975 kfree(tty);
44976 reset_open_count:
44977 - port->port.count = 0;
44978 + atomic_set(&port->port.count, 0);
44979 usb_autopm_put_interface(serial->interface);
44980 error_get_interface:
44981 usb_serial_put(serial);
44982 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44983 index 75f70f0..d467e1a 100644
44984 --- a/drivers/usb/storage/usb.h
44985 +++ b/drivers/usb/storage/usb.h
44986 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44987 __u8 useProtocol;
44988 __u8 useTransport;
44989 int (*initFunction)(struct us_data *);
44990 -};
44991 +} __do_const;
44992
44993
44994 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44995 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44996 index d6bea3e..60b250e 100644
44997 --- a/drivers/usb/wusbcore/wa-hc.h
44998 +++ b/drivers/usb/wusbcore/wa-hc.h
44999 @@ -192,7 +192,7 @@ struct wahc {
45000 struct list_head xfer_delayed_list;
45001 spinlock_t xfer_list_lock;
45002 struct work_struct xfer_work;
45003 - atomic_t xfer_id_count;
45004 + atomic_unchecked_t xfer_id_count;
45005 };
45006
45007
45008 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
45009 INIT_LIST_HEAD(&wa->xfer_delayed_list);
45010 spin_lock_init(&wa->xfer_list_lock);
45011 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
45012 - atomic_set(&wa->xfer_id_count, 1);
45013 + atomic_set_unchecked(&wa->xfer_id_count, 1);
45014 }
45015
45016 /**
45017 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
45018 index 6ef94bc..1b41265 100644
45019 --- a/drivers/usb/wusbcore/wa-xfer.c
45020 +++ b/drivers/usb/wusbcore/wa-xfer.c
45021 @@ -296,7 +296,7 @@ out:
45022 */
45023 static void wa_xfer_id_init(struct wa_xfer *xfer)
45024 {
45025 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
45026 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
45027 }
45028
45029 /*
45030 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
45031 index 5174eba..86e764a 100644
45032 --- a/drivers/vhost/vringh.c
45033 +++ b/drivers/vhost/vringh.c
45034 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
45035
45036 static inline int putu16_kern(u16 *p, u16 val)
45037 {
45038 - ACCESS_ONCE(*p) = val;
45039 + ACCESS_ONCE_RW(*p) = val;
45040 return 0;
45041 }
45042
45043 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45044 index 8c55011..eed4ae1a 100644
45045 --- a/drivers/video/aty/aty128fb.c
45046 +++ b/drivers/video/aty/aty128fb.c
45047 @@ -149,7 +149,7 @@ enum {
45048 };
45049
45050 /* Must match above enum */
45051 -static char * const r128_family[] = {
45052 +static const char * const r128_family[] = {
45053 "AGP",
45054 "PCI",
45055 "PRO AGP",
45056 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45057 index 4f27fdc..d3537e6 100644
45058 --- a/drivers/video/aty/atyfb_base.c
45059 +++ b/drivers/video/aty/atyfb_base.c
45060 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45061 par->accel_flags = var->accel_flags; /* hack */
45062
45063 if (var->accel_flags) {
45064 - info->fbops->fb_sync = atyfb_sync;
45065 + pax_open_kernel();
45066 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45067 + pax_close_kernel();
45068 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45069 } else {
45070 - info->fbops->fb_sync = NULL;
45071 + pax_open_kernel();
45072 + *(void **)&info->fbops->fb_sync = NULL;
45073 + pax_close_kernel();
45074 info->flags |= FBINFO_HWACCEL_DISABLED;
45075 }
45076
45077 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45078 index 95ec042..e6affdd 100644
45079 --- a/drivers/video/aty/mach64_cursor.c
45080 +++ b/drivers/video/aty/mach64_cursor.c
45081 @@ -7,6 +7,7 @@
45082 #include <linux/string.h>
45083
45084 #include <asm/io.h>
45085 +#include <asm/pgtable.h>
45086
45087 #ifdef __sparc__
45088 #include <asm/fbio.h>
45089 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45090 info->sprite.buf_align = 16; /* and 64 lines tall. */
45091 info->sprite.flags = FB_PIXMAP_IO;
45092
45093 - info->fbops->fb_cursor = atyfb_cursor;
45094 + pax_open_kernel();
45095 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45096 + pax_close_kernel();
45097
45098 return 0;
45099 }
45100 diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
45101 index c74e7aa..e3c2790 100644
45102 --- a/drivers/video/backlight/backlight.c
45103 +++ b/drivers/video/backlight/backlight.c
45104 @@ -304,7 +304,7 @@ struct backlight_device *backlight_device_register(const char *name,
45105 new_bd->dev.class = backlight_class;
45106 new_bd->dev.parent = parent;
45107 new_bd->dev.release = bl_device_release;
45108 - dev_set_name(&new_bd->dev, name);
45109 + dev_set_name(&new_bd->dev, "%s", name);
45110 dev_set_drvdata(&new_bd->dev, devdata);
45111
45112 /* Set default properties */
45113 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45114 index bca6ccc..252107e 100644
45115 --- a/drivers/video/backlight/kb3886_bl.c
45116 +++ b/drivers/video/backlight/kb3886_bl.c
45117 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45118 static unsigned long kb3886bl_flags;
45119 #define KB3886BL_SUSPENDED 0x01
45120
45121 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45122 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45123 {
45124 .ident = "Sahara Touch-iT",
45125 .matches = {
45126 diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
45127 index 34fb6bd..3649fd9 100644
45128 --- a/drivers/video/backlight/lcd.c
45129 +++ b/drivers/video/backlight/lcd.c
45130 @@ -219,7 +219,7 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
45131 new_ld->dev.class = lcd_class;
45132 new_ld->dev.parent = parent;
45133 new_ld->dev.release = lcd_device_release;
45134 - dev_set_name(&new_ld->dev, name);
45135 + dev_set_name(&new_ld->dev, "%s", name);
45136 dev_set_drvdata(&new_ld->dev, devdata);
45137
45138 rc = device_register(&new_ld->dev);
45139 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45140 index 900aa4e..6d49418 100644
45141 --- a/drivers/video/fb_defio.c
45142 +++ b/drivers/video/fb_defio.c
45143 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45144
45145 BUG_ON(!fbdefio);
45146 mutex_init(&fbdefio->lock);
45147 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45148 + pax_open_kernel();
45149 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45150 + pax_close_kernel();
45151 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45152 INIT_LIST_HEAD(&fbdefio->pagelist);
45153 if (fbdefio->delay == 0) /* set a default of 1 s */
45154 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45155 page->mapping = NULL;
45156 }
45157
45158 - info->fbops->fb_mmap = NULL;
45159 + *(void **)&info->fbops->fb_mmap = NULL;
45160 mutex_destroy(&fbdefio->lock);
45161 }
45162 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45163 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45164 index 5c3960d..15cf8fc 100644
45165 --- a/drivers/video/fbcmap.c
45166 +++ b/drivers/video/fbcmap.c
45167 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45168 rc = -ENODEV;
45169 goto out;
45170 }
45171 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45172 - !info->fbops->fb_setcmap)) {
45173 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45174 rc = -EINVAL;
45175 goto out1;
45176 }
45177 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45178 index 098bfc6..796841d 100644
45179 --- a/drivers/video/fbmem.c
45180 +++ b/drivers/video/fbmem.c
45181 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45182 image->dx += image->width + 8;
45183 }
45184 } else if (rotate == FB_ROTATE_UD) {
45185 - for (x = 0; x < num && image->dx >= 0; x++) {
45186 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45187 info->fbops->fb_imageblit(info, image);
45188 image->dx -= image->width + 8;
45189 }
45190 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45191 image->dy += image->height + 8;
45192 }
45193 } else if (rotate == FB_ROTATE_CCW) {
45194 - for (x = 0; x < num && image->dy >= 0; x++) {
45195 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45196 info->fbops->fb_imageblit(info, image);
45197 image->dy -= image->height + 8;
45198 }
45199 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45200 return -EFAULT;
45201 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45202 return -EINVAL;
45203 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45204 + if (con2fb.framebuffer >= FB_MAX)
45205 return -EINVAL;
45206 if (!registered_fb[con2fb.framebuffer])
45207 request_module("fb%d", con2fb.framebuffer);
45208 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45209 index 7672d2e..b56437f 100644
45210 --- a/drivers/video/i810/i810_accel.c
45211 +++ b/drivers/video/i810/i810_accel.c
45212 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45213 }
45214 }
45215 printk("ringbuffer lockup!!!\n");
45216 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45217 i810_report_error(mmio);
45218 par->dev_flags |= LOCKUP;
45219 info->pixmap.scan_align = 1;
45220 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45221 index 3c14e43..eafa544 100644
45222 --- a/drivers/video/logo/logo_linux_clut224.ppm
45223 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45224 @@ -1,1604 +1,1123 @@
45225 P3
45226 -# Standard 224-color Linux logo
45227 80 80
45228 255
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 0 0 0
45237 - 0 0 0 0 0 0 0 0 0 0 0 0
45238 - 6 6 6 6 6 6 10 10 10 10 10 10
45239 - 10 10 10 6 6 6 6 6 6 6 6 6
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 0 0 0 0 0 0 0 0 0 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 0 0 0
45250 - 0 0 0 0 0 0 0 0 0 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 0 0 0
45256 - 0 0 0 0 0 0 0 0 0 0 0 0
45257 - 0 0 0 6 6 6 10 10 10 14 14 14
45258 - 22 22 22 26 26 26 30 30 30 34 34 34
45259 - 30 30 30 30 30 30 26 26 26 18 18 18
45260 - 14 14 14 10 10 10 6 6 6 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 0 0 0 0 0 0
45267 - 0 0 0 0 0 0 0 0 0 0 0 0
45268 - 0 0 0 0 0 0 0 0 0 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 0 0 0
45270 - 0 0 0 0 0 1 0 0 1 0 0 0
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 0 0 0 0 0 0 0 0 0 0
45277 - 6 6 6 14 14 14 26 26 26 42 42 42
45278 - 54 54 54 66 66 66 78 78 78 78 78 78
45279 - 78 78 78 74 74 74 66 66 66 54 54 54
45280 - 42 42 42 26 26 26 18 18 18 10 10 10
45281 - 6 6 6 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 1 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 0 0 0 0 0 0 0 0 0 10 10 10
45297 - 22 22 22 42 42 42 66 66 66 86 86 86
45298 - 66 66 66 38 38 38 38 38 38 22 22 22
45299 - 26 26 26 34 34 34 54 54 54 66 66 66
45300 - 86 86 86 70 70 70 46 46 46 26 26 26
45301 - 14 14 14 6 6 6 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 1 0 0 1 0 0 1 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 0 0 0 0 0 0 10 10 10 26 26 26
45317 - 50 50 50 82 82 82 58 58 58 6 6 6
45318 - 2 2 6 2 2 6 2 2 6 2 2 6
45319 - 2 2 6 2 2 6 2 2 6 2 2 6
45320 - 6 6 6 54 54 54 86 86 86 66 66 66
45321 - 38 38 38 18 18 18 6 6 6 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 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 0 0 0
45336 - 0 0 0 6 6 6 22 22 22 50 50 50
45337 - 78 78 78 34 34 34 2 2 6 2 2 6
45338 - 2 2 6 2 2 6 2 2 6 2 2 6
45339 - 2 2 6 2 2 6 2 2 6 2 2 6
45340 - 2 2 6 2 2 6 6 6 6 70 70 70
45341 - 78 78 78 46 46 46 22 22 22 6 6 6
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 0 0 0 0
45347 - 0 0 0 0 0 0 0 0 0 0 0 0
45348 - 0 0 0 0 0 0 0 0 0 0 0 0
45349 - 0 0 0 0 0 0 0 0 0 0 0 0
45350 - 0 0 1 0 0 1 0 0 1 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 6 6 6 18 18 18 42 42 42 82 82 82
45357 - 26 26 26 2 2 6 2 2 6 2 2 6
45358 - 2 2 6 2 2 6 2 2 6 2 2 6
45359 - 2 2 6 2 2 6 2 2 6 14 14 14
45360 - 46 46 46 34 34 34 6 6 6 2 2 6
45361 - 42 42 42 78 78 78 42 42 42 18 18 18
45362 - 6 6 6 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 0 0 0 0 0 0 0
45367 - 0 0 0 0 0 0 0 0 0 0 0 0
45368 - 0 0 0 0 0 0 0 0 0 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 1 0 0 0 0 0 1 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 0 0 0 0 0 0 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 0 0 0
45376 - 10 10 10 30 30 30 66 66 66 58 58 58
45377 - 2 2 6 2 2 6 2 2 6 2 2 6
45378 - 2 2 6 2 2 6 2 2 6 2 2 6
45379 - 2 2 6 2 2 6 2 2 6 26 26 26
45380 - 86 86 86 101 101 101 46 46 46 10 10 10
45381 - 2 2 6 58 58 58 70 70 70 34 34 34
45382 - 10 10 10 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 1 0 0 1 0 0 1 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 14 14 14 42 42 42 86 86 86 10 10 10
45397 - 2 2 6 2 2 6 2 2 6 2 2 6
45398 - 2 2 6 2 2 6 2 2 6 2 2 6
45399 - 2 2 6 2 2 6 2 2 6 30 30 30
45400 - 94 94 94 94 94 94 58 58 58 26 26 26
45401 - 2 2 6 6 6 6 78 78 78 54 54 54
45402 - 22 22 22 6 6 6 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 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 0 0 0
45414 - 0 0 0 0 0 0 0 0 0 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 6 6 6
45416 - 22 22 22 62 62 62 62 62 62 2 2 6
45417 - 2 2 6 2 2 6 2 2 6 2 2 6
45418 - 2 2 6 2 2 6 2 2 6 2 2 6
45419 - 2 2 6 2 2 6 2 2 6 26 26 26
45420 - 54 54 54 38 38 38 18 18 18 10 10 10
45421 - 2 2 6 2 2 6 34 34 34 82 82 82
45422 - 38 38 38 14 14 14 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 1 0 0 1 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 0 0 0 0 0 0 0 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 0 0 0
45434 - 0 0 0 0 0 0 0 0 0 0 0 0
45435 - 0 0 0 0 0 0 0 0 0 6 6 6
45436 - 30 30 30 78 78 78 30 30 30 2 2 6
45437 - 2 2 6 2 2 6 2 2 6 2 2 6
45438 - 2 2 6 2 2 6 2 2 6 2 2 6
45439 - 2 2 6 2 2 6 2 2 6 10 10 10
45440 - 10 10 10 2 2 6 2 2 6 2 2 6
45441 - 2 2 6 2 2 6 2 2 6 78 78 78
45442 - 50 50 50 18 18 18 6 6 6 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 1 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 0 0 0 0 0 0 0 0 0 10 10 10
45456 - 38 38 38 86 86 86 14 14 14 2 2 6
45457 - 2 2 6 2 2 6 2 2 6 2 2 6
45458 - 2 2 6 2 2 6 2 2 6 2 2 6
45459 - 2 2 6 2 2 6 2 2 6 2 2 6
45460 - 2 2 6 2 2 6 2 2 6 2 2 6
45461 - 2 2 6 2 2 6 2 2 6 54 54 54
45462 - 66 66 66 26 26 26 6 6 6 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 1 0 0 1 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 0 0 0 0 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 0 0 0
45475 - 0 0 0 0 0 0 0 0 0 14 14 14
45476 - 42 42 42 82 82 82 2 2 6 2 2 6
45477 - 2 2 6 6 6 6 10 10 10 2 2 6
45478 - 2 2 6 2 2 6 2 2 6 2 2 6
45479 - 2 2 6 2 2 6 2 2 6 6 6 6
45480 - 14 14 14 10 10 10 2 2 6 2 2 6
45481 - 2 2 6 2 2 6 2 2 6 18 18 18
45482 - 82 82 82 34 34 34 10 10 10 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 1 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 0 0 0
45495 - 0 0 0 0 0 0 0 0 0 14 14 14
45496 - 46 46 46 86 86 86 2 2 6 2 2 6
45497 - 6 6 6 6 6 6 22 22 22 34 34 34
45498 - 6 6 6 2 2 6 2 2 6 2 2 6
45499 - 2 2 6 2 2 6 18 18 18 34 34 34
45500 - 10 10 10 50 50 50 22 22 22 2 2 6
45501 - 2 2 6 2 2 6 2 2 6 10 10 10
45502 - 86 86 86 42 42 42 14 14 14 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 1 0 0 1 0 0 1 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 0 0 0 0 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 0 0 0
45514 - 0 0 0 0 0 0 0 0 0 0 0 0
45515 - 0 0 0 0 0 0 0 0 0 14 14 14
45516 - 46 46 46 86 86 86 2 2 6 2 2 6
45517 - 38 38 38 116 116 116 94 94 94 22 22 22
45518 - 22 22 22 2 2 6 2 2 6 2 2 6
45519 - 14 14 14 86 86 86 138 138 138 162 162 162
45520 -154 154 154 38 38 38 26 26 26 6 6 6
45521 - 2 2 6 2 2 6 2 2 6 2 2 6
45522 - 86 86 86 46 46 46 14 14 14 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 0 0 0
45533 - 0 0 0 0 0 0 0 0 0 0 0 0
45534 - 0 0 0 0 0 0 0 0 0 0 0 0
45535 - 0 0 0 0 0 0 0 0 0 14 14 14
45536 - 46 46 46 86 86 86 2 2 6 14 14 14
45537 -134 134 134 198 198 198 195 195 195 116 116 116
45538 - 10 10 10 2 2 6 2 2 6 6 6 6
45539 -101 98 89 187 187 187 210 210 210 218 218 218
45540 -214 214 214 134 134 134 14 14 14 6 6 6
45541 - 2 2 6 2 2 6 2 2 6 2 2 6
45542 - 86 86 86 50 50 50 18 18 18 6 6 6
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 1 0 0 0
45550 - 0 0 1 0 0 1 0 0 1 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 0 0 0 0 0 0 0 0 0 0
45553 - 0 0 0 0 0 0 0 0 0 0 0 0
45554 - 0 0 0 0 0 0 0 0 0 0 0 0
45555 - 0 0 0 0 0 0 0 0 0 14 14 14
45556 - 46 46 46 86 86 86 2 2 6 54 54 54
45557 -218 218 218 195 195 195 226 226 226 246 246 246
45558 - 58 58 58 2 2 6 2 2 6 30 30 30
45559 -210 210 210 253 253 253 174 174 174 123 123 123
45560 -221 221 221 234 234 234 74 74 74 2 2 6
45561 - 2 2 6 2 2 6 2 2 6 2 2 6
45562 - 70 70 70 58 58 58 22 22 22 6 6 6
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 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 0 0 0 0 0 0 0 0 0 0 0 0
45575 - 0 0 0 0 0 0 0 0 0 14 14 14
45576 - 46 46 46 82 82 82 2 2 6 106 106 106
45577 -170 170 170 26 26 26 86 86 86 226 226 226
45578 -123 123 123 10 10 10 14 14 14 46 46 46
45579 -231 231 231 190 190 190 6 6 6 70 70 70
45580 - 90 90 90 238 238 238 158 158 158 2 2 6
45581 - 2 2 6 2 2 6 2 2 6 2 2 6
45582 - 70 70 70 58 58 58 22 22 22 6 6 6
45583 - 0 0 0 0 0 0 0 0 0 0 0 0
45584 - 0 0 0 0 0 0 0 0 0 0 0 0
45585 - 0 0 0 0 0 0 0 0 0 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 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 1 0 0 0
45590 - 0 0 1 0 0 1 0 0 1 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 0 0 0 0 0 0 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 0 0 0 0 0 0 0 0 0 0 0 0
45595 - 0 0 0 0 0 0 0 0 0 14 14 14
45596 - 42 42 42 86 86 86 6 6 6 116 116 116
45597 -106 106 106 6 6 6 70 70 70 149 149 149
45598 -128 128 128 18 18 18 38 38 38 54 54 54
45599 -221 221 221 106 106 106 2 2 6 14 14 14
45600 - 46 46 46 190 190 190 198 198 198 2 2 6
45601 - 2 2 6 2 2 6 2 2 6 2 2 6
45602 - 74 74 74 62 62 62 22 22 22 6 6 6
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 1 0 0 0
45610 - 0 0 1 0 0 0 0 0 1 0 0 0
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 0 0 0
45614 - 0 0 0 0 0 0 0 0 0 0 0 0
45615 - 0 0 0 0 0 0 0 0 0 14 14 14
45616 - 42 42 42 94 94 94 14 14 14 101 101 101
45617 -128 128 128 2 2 6 18 18 18 116 116 116
45618 -118 98 46 121 92 8 121 92 8 98 78 10
45619 -162 162 162 106 106 106 2 2 6 2 2 6
45620 - 2 2 6 195 195 195 195 195 195 6 6 6
45621 - 2 2 6 2 2 6 2 2 6 2 2 6
45622 - 74 74 74 62 62 62 22 22 22 6 6 6
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 1 0 0 1
45630 - 0 0 1 0 0 0 0 0 1 0 0 0
45631 - 0 0 0 0 0 0 0 0 0 0 0 0
45632 - 0 0 0 0 0 0 0 0 0 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 0 0 0
45634 - 0 0 0 0 0 0 0 0 0 0 0 0
45635 - 0 0 0 0 0 0 0 0 0 10 10 10
45636 - 38 38 38 90 90 90 14 14 14 58 58 58
45637 -210 210 210 26 26 26 54 38 6 154 114 10
45638 -226 170 11 236 186 11 225 175 15 184 144 12
45639 -215 174 15 175 146 61 37 26 9 2 2 6
45640 - 70 70 70 246 246 246 138 138 138 2 2 6
45641 - 2 2 6 2 2 6 2 2 6 2 2 6
45642 - 70 70 70 66 66 66 26 26 26 6 6 6
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 0 0 0
45652 - 0 0 0 0 0 0 0 0 0 0 0 0
45653 - 0 0 0 0 0 0 0 0 0 0 0 0
45654 - 0 0 0 0 0 0 0 0 0 0 0 0
45655 - 0 0 0 0 0 0 0 0 0 10 10 10
45656 - 38 38 38 86 86 86 14 14 14 10 10 10
45657 -195 195 195 188 164 115 192 133 9 225 175 15
45658 -239 182 13 234 190 10 232 195 16 232 200 30
45659 -245 207 45 241 208 19 232 195 16 184 144 12
45660 -218 194 134 211 206 186 42 42 42 2 2 6
45661 - 2 2 6 2 2 6 2 2 6 2 2 6
45662 - 50 50 50 74 74 74 30 30 30 6 6 6
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 0 0 0 0 0 0
45672 - 0 0 0 0 0 0 0 0 0 0 0 0
45673 - 0 0 0 0 0 0 0 0 0 0 0 0
45674 - 0 0 0 0 0 0 0 0 0 0 0 0
45675 - 0 0 0 0 0 0 0 0 0 10 10 10
45676 - 34 34 34 86 86 86 14 14 14 2 2 6
45677 -121 87 25 192 133 9 219 162 10 239 182 13
45678 -236 186 11 232 195 16 241 208 19 244 214 54
45679 -246 218 60 246 218 38 246 215 20 241 208 19
45680 -241 208 19 226 184 13 121 87 25 2 2 6
45681 - 2 2 6 2 2 6 2 2 6 2 2 6
45682 - 50 50 50 82 82 82 34 34 34 10 10 10
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 0 0 0 0 0 0 0 0 0
45692 - 0 0 0 0 0 0 0 0 0 0 0 0
45693 - 0 0 0 0 0 0 0 0 0 0 0 0
45694 - 0 0 0 0 0 0 0 0 0 0 0 0
45695 - 0 0 0 0 0 0 0 0 0 10 10 10
45696 - 34 34 34 82 82 82 30 30 30 61 42 6
45697 -180 123 7 206 145 10 230 174 11 239 182 13
45698 -234 190 10 238 202 15 241 208 19 246 218 74
45699 -246 218 38 246 215 20 246 215 20 246 215 20
45700 -226 184 13 215 174 15 184 144 12 6 6 6
45701 - 2 2 6 2 2 6 2 2 6 2 2 6
45702 - 26 26 26 94 94 94 42 42 42 14 14 14
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 - 0 0 0 0 0 0 0 0 0 0 0 0
45712 - 0 0 0 0 0 0 0 0 0 0 0 0
45713 - 0 0 0 0 0 0 0 0 0 0 0 0
45714 - 0 0 0 0 0 0 0 0 0 0 0 0
45715 - 0 0 0 0 0 0 0 0 0 10 10 10
45716 - 30 30 30 78 78 78 50 50 50 104 69 6
45717 -192 133 9 216 158 10 236 178 12 236 186 11
45718 -232 195 16 241 208 19 244 214 54 245 215 43
45719 -246 215 20 246 215 20 241 208 19 198 155 10
45720 -200 144 11 216 158 10 156 118 10 2 2 6
45721 - 2 2 6 2 2 6 2 2 6 2 2 6
45722 - 6 6 6 90 90 90 54 54 54 18 18 18
45723 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
45733 - 0 0 0 0 0 0 0 0 0 0 0 0
45734 - 0 0 0 0 0 0 0 0 0 0 0 0
45735 - 0 0 0 0 0 0 0 0 0 10 10 10
45736 - 30 30 30 78 78 78 46 46 46 22 22 22
45737 -137 92 6 210 162 10 239 182 13 238 190 10
45738 -238 202 15 241 208 19 246 215 20 246 215 20
45739 -241 208 19 203 166 17 185 133 11 210 150 10
45740 -216 158 10 210 150 10 102 78 10 2 2 6
45741 - 6 6 6 54 54 54 14 14 14 2 2 6
45742 - 2 2 6 62 62 62 74 74 74 30 30 30
45743 - 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 0 0 0 0 0 0 0 0 0 0 0 0
45754 - 0 0 0 0 0 0 0 0 0 0 0 0
45755 - 0 0 0 0 0 0 0 0 0 10 10 10
45756 - 34 34 34 78 78 78 50 50 50 6 6 6
45757 - 94 70 30 139 102 15 190 146 13 226 184 13
45758 -232 200 30 232 195 16 215 174 15 190 146 13
45759 -168 122 10 192 133 9 210 150 10 213 154 11
45760 -202 150 34 182 157 106 101 98 89 2 2 6
45761 - 2 2 6 78 78 78 116 116 116 58 58 58
45762 - 2 2 6 22 22 22 90 90 90 46 46 46
45763 - 18 18 18 6 6 6 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 0 0 0
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 0 0 0 0 0 0 0 0 0
45774 - 0 0 0 0 0 0 0 0 0 0 0 0
45775 - 0 0 0 0 0 0 0 0 0 10 10 10
45776 - 38 38 38 86 86 86 50 50 50 6 6 6
45777 -128 128 128 174 154 114 156 107 11 168 122 10
45778 -198 155 10 184 144 12 197 138 11 200 144 11
45779 -206 145 10 206 145 10 197 138 11 188 164 115
45780 -195 195 195 198 198 198 174 174 174 14 14 14
45781 - 2 2 6 22 22 22 116 116 116 116 116 116
45782 - 22 22 22 2 2 6 74 74 74 70 70 70
45783 - 30 30 30 10 10 10 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 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 0 0 0 0 0 0
45794 - 0 0 0 0 0 0 0 0 0 0 0 0
45795 - 0 0 0 0 0 0 6 6 6 18 18 18
45796 - 50 50 50 101 101 101 26 26 26 10 10 10
45797 -138 138 138 190 190 190 174 154 114 156 107 11
45798 -197 138 11 200 144 11 197 138 11 192 133 9
45799 -180 123 7 190 142 34 190 178 144 187 187 187
45800 -202 202 202 221 221 221 214 214 214 66 66 66
45801 - 2 2 6 2 2 6 50 50 50 62 62 62
45802 - 6 6 6 2 2 6 10 10 10 90 90 90
45803 - 50 50 50 18 18 18 6 6 6 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 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 0 0 0 0 0 0 0 0 0
45815 - 0 0 0 0 0 0 10 10 10 34 34 34
45816 - 74 74 74 74 74 74 2 2 6 6 6 6
45817 -144 144 144 198 198 198 190 190 190 178 166 146
45818 -154 121 60 156 107 11 156 107 11 168 124 44
45819 -174 154 114 187 187 187 190 190 190 210 210 210
45820 -246 246 246 253 253 253 253 253 253 182 182 182
45821 - 6 6 6 2 2 6 2 2 6 2 2 6
45822 - 2 2 6 2 2 6 2 2 6 62 62 62
45823 - 74 74 74 34 34 34 14 14 14 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 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 0 0 0 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 0 0 0 0 0 0
45835 - 0 0 0 10 10 10 22 22 22 54 54 54
45836 - 94 94 94 18 18 18 2 2 6 46 46 46
45837 -234 234 234 221 221 221 190 190 190 190 190 190
45838 -190 190 190 187 187 187 187 187 187 190 190 190
45839 -190 190 190 195 195 195 214 214 214 242 242 242
45840 -253 253 253 253 253 253 253 253 253 253 253 253
45841 - 82 82 82 2 2 6 2 2 6 2 2 6
45842 - 2 2 6 2 2 6 2 2 6 14 14 14
45843 - 86 86 86 54 54 54 22 22 22 6 6 6
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 0 0 0 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 0 0 0
45853 - 0 0 0 0 0 0 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 0 0 0 0 0 0
45855 - 6 6 6 18 18 18 46 46 46 90 90 90
45856 - 46 46 46 18 18 18 6 6 6 182 182 182
45857 -253 253 253 246 246 246 206 206 206 190 190 190
45858 -190 190 190 190 190 190 190 190 190 190 190 190
45859 -206 206 206 231 231 231 250 250 250 253 253 253
45860 -253 253 253 253 253 253 253 253 253 253 253 253
45861 -202 202 202 14 14 14 2 2 6 2 2 6
45862 - 2 2 6 2 2 6 2 2 6 2 2 6
45863 - 42 42 42 86 86 86 42 42 42 18 18 18
45864 - 6 6 6 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 0 0 0 0 0 0 0 0 0
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 0 0 0
45873 - 0 0 0 0 0 0 0 0 0 0 0 0
45874 - 0 0 0 0 0 0 0 0 0 6 6 6
45875 - 14 14 14 38 38 38 74 74 74 66 66 66
45876 - 2 2 6 6 6 6 90 90 90 250 250 250
45877 -253 253 253 253 253 253 238 238 238 198 198 198
45878 -190 190 190 190 190 190 195 195 195 221 221 221
45879 -246 246 246 253 253 253 253 253 253 253 253 253
45880 -253 253 253 253 253 253 253 253 253 253 253 253
45881 -253 253 253 82 82 82 2 2 6 2 2 6
45882 - 2 2 6 2 2 6 2 2 6 2 2 6
45883 - 2 2 6 78 78 78 70 70 70 34 34 34
45884 - 14 14 14 6 6 6 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 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 0 0 0 0 0 0 0 0 0 0 0 0
45894 - 0 0 0 0 0 0 0 0 0 14 14 14
45895 - 34 34 34 66 66 66 78 78 78 6 6 6
45896 - 2 2 6 18 18 18 218 218 218 253 253 253
45897 -253 253 253 253 253 253 253 253 253 246 246 246
45898 -226 226 226 231 231 231 246 246 246 253 253 253
45899 -253 253 253 253 253 253 253 253 253 253 253 253
45900 -253 253 253 253 253 253 253 253 253 253 253 253
45901 -253 253 253 178 178 178 2 2 6 2 2 6
45902 - 2 2 6 2 2 6 2 2 6 2 2 6
45903 - 2 2 6 18 18 18 90 90 90 62 62 62
45904 - 30 30 30 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 0 0 0 0 0 0 0 0 0
45914 - 0 0 0 0 0 0 10 10 10 26 26 26
45915 - 58 58 58 90 90 90 18 18 18 2 2 6
45916 - 2 2 6 110 110 110 253 253 253 253 253 253
45917 -253 253 253 253 253 253 253 253 253 253 253 253
45918 -250 250 250 253 253 253 253 253 253 253 253 253
45919 -253 253 253 253 253 253 253 253 253 253 253 253
45920 -253 253 253 253 253 253 253 253 253 253 253 253
45921 -253 253 253 231 231 231 18 18 18 2 2 6
45922 - 2 2 6 2 2 6 2 2 6 2 2 6
45923 - 2 2 6 2 2 6 18 18 18 94 94 94
45924 - 54 54 54 26 26 26 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45931 - 0 0 0 0 0 0 0 0 0 0 0 0
45932 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 - 0 0 0 0 0 0 0 0 0 0 0 0
45934 - 0 0 0 6 6 6 22 22 22 50 50 50
45935 - 90 90 90 26 26 26 2 2 6 2 2 6
45936 - 14 14 14 195 195 195 250 250 250 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 253 253 253 253 253 253
45940 -253 253 253 253 253 253 253 253 253 253 253 253
45941 -250 250 250 242 242 242 54 54 54 2 2 6
45942 - 2 2 6 2 2 6 2 2 6 2 2 6
45943 - 2 2 6 2 2 6 2 2 6 38 38 38
45944 - 86 86 86 50 50 50 22 22 22 6 6 6
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 0 0 0
45950 - 0 0 0 0 0 0 0 0 0 0 0 0
45951 - 0 0 0 0 0 0 0 0 0 0 0 0
45952 - 0 0 0 0 0 0 0 0 0 0 0 0
45953 - 0 0 0 0 0 0 0 0 0 0 0 0
45954 - 6 6 6 14 14 14 38 38 38 82 82 82
45955 - 34 34 34 2 2 6 2 2 6 2 2 6
45956 - 42 42 42 195 195 195 246 246 246 253 253 253
45957 -253 253 253 253 253 253 253 253 253 250 250 250
45958 -242 242 242 242 242 242 250 250 250 253 253 253
45959 -253 253 253 253 253 253 253 253 253 253 253 253
45960 -253 253 253 250 250 250 246 246 246 238 238 238
45961 -226 226 226 231 231 231 101 101 101 6 6 6
45962 - 2 2 6 2 2 6 2 2 6 2 2 6
45963 - 2 2 6 2 2 6 2 2 6 2 2 6
45964 - 38 38 38 82 82 82 42 42 42 14 14 14
45965 - 6 6 6 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 0 0 0
45970 - 0 0 0 0 0 0 0 0 0 0 0 0
45971 - 0 0 0 0 0 0 0 0 0 0 0 0
45972 - 0 0 0 0 0 0 0 0 0 0 0 0
45973 - 0 0 0 0 0 0 0 0 0 0 0 0
45974 - 10 10 10 26 26 26 62 62 62 66 66 66
45975 - 2 2 6 2 2 6 2 2 6 6 6 6
45976 - 70 70 70 170 170 170 206 206 206 234 234 234
45977 -246 246 246 250 250 250 250 250 250 238 238 238
45978 -226 226 226 231 231 231 238 238 238 250 250 250
45979 -250 250 250 250 250 250 246 246 246 231 231 231
45980 -214 214 214 206 206 206 202 202 202 202 202 202
45981 -198 198 198 202 202 202 182 182 182 18 18 18
45982 - 2 2 6 2 2 6 2 2 6 2 2 6
45983 - 2 2 6 2 2 6 2 2 6 2 2 6
45984 - 2 2 6 62 62 62 66 66 66 30 30 30
45985 - 10 10 10 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 0 0 0
45990 - 0 0 0 0 0 0 0 0 0 0 0 0
45991 - 0 0 0 0 0 0 0 0 0 0 0 0
45992 - 0 0 0 0 0 0 0 0 0 0 0 0
45993 - 0 0 0 0 0 0 0 0 0 0 0 0
45994 - 14 14 14 42 42 42 82 82 82 18 18 18
45995 - 2 2 6 2 2 6 2 2 6 10 10 10
45996 - 94 94 94 182 182 182 218 218 218 242 242 242
45997 -250 250 250 253 253 253 253 253 253 250 250 250
45998 -234 234 234 253 253 253 253 253 253 253 253 253
45999 -253 253 253 253 253 253 253 253 253 246 246 246
46000 -238 238 238 226 226 226 210 210 210 202 202 202
46001 -195 195 195 195 195 195 210 210 210 158 158 158
46002 - 6 6 6 14 14 14 50 50 50 14 14 14
46003 - 2 2 6 2 2 6 2 2 6 2 2 6
46004 - 2 2 6 6 6 6 86 86 86 46 46 46
46005 - 18 18 18 6 6 6 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 0 0 0 0 0 0
46010 - 0 0 0 0 0 0 0 0 0 0 0 0
46011 - 0 0 0 0 0 0 0 0 0 0 0 0
46012 - 0 0 0 0 0 0 0 0 0 0 0 0
46013 - 0 0 0 0 0 0 0 0 0 6 6 6
46014 - 22 22 22 54 54 54 70 70 70 2 2 6
46015 - 2 2 6 10 10 10 2 2 6 22 22 22
46016 -166 166 166 231 231 231 250 250 250 253 253 253
46017 -253 253 253 253 253 253 253 253 253 250 250 250
46018 -242 242 242 253 253 253 253 253 253 253 253 253
46019 -253 253 253 253 253 253 253 253 253 253 253 253
46020 -253 253 253 253 253 253 253 253 253 246 246 246
46021 -231 231 231 206 206 206 198 198 198 226 226 226
46022 - 94 94 94 2 2 6 6 6 6 38 38 38
46023 - 30 30 30 2 2 6 2 2 6 2 2 6
46024 - 2 2 6 2 2 6 62 62 62 66 66 66
46025 - 26 26 26 10 10 10 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 0 0 0 0 0 0
46030 - 0 0 0 0 0 0 0 0 0 0 0 0
46031 - 0 0 0 0 0 0 0 0 0 0 0 0
46032 - 0 0 0 0 0 0 0 0 0 0 0 0
46033 - 0 0 0 0 0 0 0 0 0 10 10 10
46034 - 30 30 30 74 74 74 50 50 50 2 2 6
46035 - 26 26 26 26 26 26 2 2 6 106 106 106
46036 -238 238 238 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 253 253 253 253 253 253
46040 -253 253 253 253 253 253 253 253 253 253 253 253
46041 -253 253 253 246 246 246 218 218 218 202 202 202
46042 -210 210 210 14 14 14 2 2 6 2 2 6
46043 - 30 30 30 22 22 22 2 2 6 2 2 6
46044 - 2 2 6 2 2 6 18 18 18 86 86 86
46045 - 42 42 42 14 14 14 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 0 0 0 0 0 0
46050 - 0 0 0 0 0 0 0 0 0 0 0 0
46051 - 0 0 0 0 0 0 0 0 0 0 0 0
46052 - 0 0 0 0 0 0 0 0 0 0 0 0
46053 - 0 0 0 0 0 0 0 0 0 14 14 14
46054 - 42 42 42 90 90 90 22 22 22 2 2 6
46055 - 42 42 42 2 2 6 18 18 18 218 218 218
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 253 253 253 253 253 253
46060 -253 253 253 253 253 253 253 253 253 253 253 253
46061 -253 253 253 253 253 253 250 250 250 221 221 221
46062 -218 218 218 101 101 101 2 2 6 14 14 14
46063 - 18 18 18 38 38 38 10 10 10 2 2 6
46064 - 2 2 6 2 2 6 2 2 6 78 78 78
46065 - 58 58 58 22 22 22 6 6 6 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 0 0 0 0 0 0
46070 - 0 0 0 0 0 0 0 0 0 0 0 0
46071 - 0 0 0 0 0 0 0 0 0 0 0 0
46072 - 0 0 0 0 0 0 0 0 0 0 0 0
46073 - 0 0 0 0 0 0 6 6 6 18 18 18
46074 - 54 54 54 82 82 82 2 2 6 26 26 26
46075 - 22 22 22 2 2 6 123 123 123 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 253 253 253 253 253 253
46080 -253 253 253 253 253 253 253 253 253 253 253 253
46081 -253 253 253 253 253 253 253 253 253 250 250 250
46082 -238 238 238 198 198 198 6 6 6 38 38 38
46083 - 58 58 58 26 26 26 38 38 38 2 2 6
46084 - 2 2 6 2 2 6 2 2 6 46 46 46
46085 - 78 78 78 30 30 30 10 10 10 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 0 0 0
46089 - 0 0 0 0 0 0 0 0 0 0 0 0
46090 - 0 0 0 0 0 0 0 0 0 0 0 0
46091 - 0 0 0 0 0 0 0 0 0 0 0 0
46092 - 0 0 0 0 0 0 0 0 0 0 0 0
46093 - 0 0 0 0 0 0 10 10 10 30 30 30
46094 - 74 74 74 58 58 58 2 2 6 42 42 42
46095 - 2 2 6 22 22 22 231 231 231 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 250 250 250
46098 -253 253 253 253 253 253 253 253 253 253 253 253
46099 -253 253 253 253 253 253 253 253 253 253 253 253
46100 -253 253 253 253 253 253 253 253 253 253 253 253
46101 -253 253 253 253 253 253 253 253 253 253 253 253
46102 -253 253 253 246 246 246 46 46 46 38 38 38
46103 - 42 42 42 14 14 14 38 38 38 14 14 14
46104 - 2 2 6 2 2 6 2 2 6 6 6 6
46105 - 86 86 86 46 46 46 14 14 14 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 0 0 0 0 0 0 0 0 0
46109 - 0 0 0 0 0 0 0 0 0 0 0 0
46110 - 0 0 0 0 0 0 0 0 0 0 0 0
46111 - 0 0 0 0 0 0 0 0 0 0 0 0
46112 - 0 0 0 0 0 0 0 0 0 0 0 0
46113 - 0 0 0 6 6 6 14 14 14 42 42 42
46114 - 90 90 90 18 18 18 18 18 18 26 26 26
46115 - 2 2 6 116 116 116 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 250 250 250 238 238 238
46118 -253 253 253 253 253 253 253 253 253 253 253 253
46119 -253 253 253 253 253 253 253 253 253 253 253 253
46120 -253 253 253 253 253 253 253 253 253 253 253 253
46121 -253 253 253 253 253 253 253 253 253 253 253 253
46122 -253 253 253 253 253 253 94 94 94 6 6 6
46123 - 2 2 6 2 2 6 10 10 10 34 34 34
46124 - 2 2 6 2 2 6 2 2 6 2 2 6
46125 - 74 74 74 58 58 58 22 22 22 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
46129 - 0 0 0 0 0 0 0 0 0 0 0 0
46130 - 0 0 0 0 0 0 0 0 0 0 0 0
46131 - 0 0 0 0 0 0 0 0 0 0 0 0
46132 - 0 0 0 0 0 0 0 0 0 0 0 0
46133 - 0 0 0 10 10 10 26 26 26 66 66 66
46134 - 82 82 82 2 2 6 38 38 38 6 6 6
46135 - 14 14 14 210 210 210 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 246 246 246 242 242 242
46138 -253 253 253 253 253 253 253 253 253 253 253 253
46139 -253 253 253 253 253 253 253 253 253 253 253 253
46140 -253 253 253 253 253 253 253 253 253 253 253 253
46141 -253 253 253 253 253 253 253 253 253 253 253 253
46142 -253 253 253 253 253 253 144 144 144 2 2 6
46143 - 2 2 6 2 2 6 2 2 6 46 46 46
46144 - 2 2 6 2 2 6 2 2 6 2 2 6
46145 - 42 42 42 74 74 74 30 30 30 10 10 10
46146 - 0 0 0 0 0 0 0 0 0 0 0 0
46147 - 0 0 0 0 0 0 0 0 0 0 0 0
46148 - 0 0 0 0 0 0 0 0 0 0 0 0
46149 - 0 0 0 0 0 0 0 0 0 0 0 0
46150 - 0 0 0 0 0 0 0 0 0 0 0 0
46151 - 0 0 0 0 0 0 0 0 0 0 0 0
46152 - 0 0 0 0 0 0 0 0 0 0 0 0
46153 - 6 6 6 14 14 14 42 42 42 90 90 90
46154 - 26 26 26 6 6 6 42 42 42 2 2 6
46155 - 74 74 74 250 250 250 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 242 242 242 242 242 242
46158 -253 253 253 253 253 253 253 253 253 253 253 253
46159 -253 253 253 253 253 253 253 253 253 253 253 253
46160 -253 253 253 253 253 253 253 253 253 253 253 253
46161 -253 253 253 253 253 253 253 253 253 253 253 253
46162 -253 253 253 253 253 253 182 182 182 2 2 6
46163 - 2 2 6 2 2 6 2 2 6 46 46 46
46164 - 2 2 6 2 2 6 2 2 6 2 2 6
46165 - 10 10 10 86 86 86 38 38 38 10 10 10
46166 - 0 0 0 0 0 0 0 0 0 0 0 0
46167 - 0 0 0 0 0 0 0 0 0 0 0 0
46168 - 0 0 0 0 0 0 0 0 0 0 0 0
46169 - 0 0 0 0 0 0 0 0 0 0 0 0
46170 - 0 0 0 0 0 0 0 0 0 0 0 0
46171 - 0 0 0 0 0 0 0 0 0 0 0 0
46172 - 0 0 0 0 0 0 0 0 0 0 0 0
46173 - 10 10 10 26 26 26 66 66 66 82 82 82
46174 - 2 2 6 22 22 22 18 18 18 2 2 6
46175 -149 149 149 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 234 234 234 242 242 242
46178 -253 253 253 253 253 253 253 253 253 253 253 253
46179 -253 253 253 253 253 253 253 253 253 253 253 253
46180 -253 253 253 253 253 253 253 253 253 253 253 253
46181 -253 253 253 253 253 253 253 253 253 253 253 253
46182 -253 253 253 253 253 253 206 206 206 2 2 6
46183 - 2 2 6 2 2 6 2 2 6 38 38 38
46184 - 2 2 6 2 2 6 2 2 6 2 2 6
46185 - 6 6 6 86 86 86 46 46 46 14 14 14
46186 - 0 0 0 0 0 0 0 0 0 0 0 0
46187 - 0 0 0 0 0 0 0 0 0 0 0 0
46188 - 0 0 0 0 0 0 0 0 0 0 0 0
46189 - 0 0 0 0 0 0 0 0 0 0 0 0
46190 - 0 0 0 0 0 0 0 0 0 0 0 0
46191 - 0 0 0 0 0 0 0 0 0 0 0 0
46192 - 0 0 0 0 0 0 0 0 0 6 6 6
46193 - 18 18 18 46 46 46 86 86 86 18 18 18
46194 - 2 2 6 34 34 34 10 10 10 6 6 6
46195 -210 210 210 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 234 234 234 242 242 242
46198 -253 253 253 253 253 253 253 253 253 253 253 253
46199 -253 253 253 253 253 253 253 253 253 253 253 253
46200 -253 253 253 253 253 253 253 253 253 253 253 253
46201 -253 253 253 253 253 253 253 253 253 253 253 253
46202 -253 253 253 253 253 253 221 221 221 6 6 6
46203 - 2 2 6 2 2 6 6 6 6 30 30 30
46204 - 2 2 6 2 2 6 2 2 6 2 2 6
46205 - 2 2 6 82 82 82 54 54 54 18 18 18
46206 - 6 6 6 0 0 0 0 0 0 0 0 0
46207 - 0 0 0 0 0 0 0 0 0 0 0 0
46208 - 0 0 0 0 0 0 0 0 0 0 0 0
46209 - 0 0 0 0 0 0 0 0 0 0 0 0
46210 - 0 0 0 0 0 0 0 0 0 0 0 0
46211 - 0 0 0 0 0 0 0 0 0 0 0 0
46212 - 0 0 0 0 0 0 0 0 0 10 10 10
46213 - 26 26 26 66 66 66 62 62 62 2 2 6
46214 - 2 2 6 38 38 38 10 10 10 26 26 26
46215 -238 238 238 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 231 231 231 238 238 238
46218 -253 253 253 253 253 253 253 253 253 253 253 253
46219 -253 253 253 253 253 253 253 253 253 253 253 253
46220 -253 253 253 253 253 253 253 253 253 253 253 253
46221 -253 253 253 253 253 253 253 253 253 253 253 253
46222 -253 253 253 253 253 253 231 231 231 6 6 6
46223 - 2 2 6 2 2 6 10 10 10 30 30 30
46224 - 2 2 6 2 2 6 2 2 6 2 2 6
46225 - 2 2 6 66 66 66 58 58 58 22 22 22
46226 - 6 6 6 0 0 0 0 0 0 0 0 0
46227 - 0 0 0 0 0 0 0 0 0 0 0 0
46228 - 0 0 0 0 0 0 0 0 0 0 0 0
46229 - 0 0 0 0 0 0 0 0 0 0 0 0
46230 - 0 0 0 0 0 0 0 0 0 0 0 0
46231 - 0 0 0 0 0 0 0 0 0 0 0 0
46232 - 0 0 0 0 0 0 0 0 0 10 10 10
46233 - 38 38 38 78 78 78 6 6 6 2 2 6
46234 - 2 2 6 46 46 46 14 14 14 42 42 42
46235 -246 246 246 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 231 231 231 242 242 242
46238 -253 253 253 253 253 253 253 253 253 253 253 253
46239 -253 253 253 253 253 253 253 253 253 253 253 253
46240 -253 253 253 253 253 253 253 253 253 253 253 253
46241 -253 253 253 253 253 253 253 253 253 253 253 253
46242 -253 253 253 253 253 253 234 234 234 10 10 10
46243 - 2 2 6 2 2 6 22 22 22 14 14 14
46244 - 2 2 6 2 2 6 2 2 6 2 2 6
46245 - 2 2 6 66 66 66 62 62 62 22 22 22
46246 - 6 6 6 0 0 0 0 0 0 0 0 0
46247 - 0 0 0 0 0 0 0 0 0 0 0 0
46248 - 0 0 0 0 0 0 0 0 0 0 0 0
46249 - 0 0 0 0 0 0 0 0 0 0 0 0
46250 - 0 0 0 0 0 0 0 0 0 0 0 0
46251 - 0 0 0 0 0 0 0 0 0 0 0 0
46252 - 0 0 0 0 0 0 6 6 6 18 18 18
46253 - 50 50 50 74 74 74 2 2 6 2 2 6
46254 - 14 14 14 70 70 70 34 34 34 62 62 62
46255 -250 250 250 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 231 231 231 246 246 246
46258 -253 253 253 253 253 253 253 253 253 253 253 253
46259 -253 253 253 253 253 253 253 253 253 253 253 253
46260 -253 253 253 253 253 253 253 253 253 253 253 253
46261 -253 253 253 253 253 253 253 253 253 253 253 253
46262 -253 253 253 253 253 253 234 234 234 14 14 14
46263 - 2 2 6 2 2 6 30 30 30 2 2 6
46264 - 2 2 6 2 2 6 2 2 6 2 2 6
46265 - 2 2 6 66 66 66 62 62 62 22 22 22
46266 - 6 6 6 0 0 0 0 0 0 0 0 0
46267 - 0 0 0 0 0 0 0 0 0 0 0 0
46268 - 0 0 0 0 0 0 0 0 0 0 0 0
46269 - 0 0 0 0 0 0 0 0 0 0 0 0
46270 - 0 0 0 0 0 0 0 0 0 0 0 0
46271 - 0 0 0 0 0 0 0 0 0 0 0 0
46272 - 0 0 0 0 0 0 6 6 6 18 18 18
46273 - 54 54 54 62 62 62 2 2 6 2 2 6
46274 - 2 2 6 30 30 30 46 46 46 70 70 70
46275 -250 250 250 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 231 231 231 246 246 246
46278 -253 253 253 253 253 253 253 253 253 253 253 253
46279 -253 253 253 253 253 253 253 253 253 253 253 253
46280 -253 253 253 253 253 253 253 253 253 253 253 253
46281 -253 253 253 253 253 253 253 253 253 253 253 253
46282 -253 253 253 253 253 253 226 226 226 10 10 10
46283 - 2 2 6 6 6 6 30 30 30 2 2 6
46284 - 2 2 6 2 2 6 2 2 6 2 2 6
46285 - 2 2 6 66 66 66 58 58 58 22 22 22
46286 - 6 6 6 0 0 0 0 0 0 0 0 0
46287 - 0 0 0 0 0 0 0 0 0 0 0 0
46288 - 0 0 0 0 0 0 0 0 0 0 0 0
46289 - 0 0 0 0 0 0 0 0 0 0 0 0
46290 - 0 0 0 0 0 0 0 0 0 0 0 0
46291 - 0 0 0 0 0 0 0 0 0 0 0 0
46292 - 0 0 0 0 0 0 6 6 6 22 22 22
46293 - 58 58 58 62 62 62 2 2 6 2 2 6
46294 - 2 2 6 2 2 6 30 30 30 78 78 78
46295 -250 250 250 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 231 231 231 246 246 246
46298 -253 253 253 253 253 253 253 253 253 253 253 253
46299 -253 253 253 253 253 253 253 253 253 253 253 253
46300 -253 253 253 253 253 253 253 253 253 253 253 253
46301 -253 253 253 253 253 253 253 253 253 253 253 253
46302 -253 253 253 253 253 253 206 206 206 2 2 6
46303 - 22 22 22 34 34 34 18 14 6 22 22 22
46304 - 26 26 26 18 18 18 6 6 6 2 2 6
46305 - 2 2 6 82 82 82 54 54 54 18 18 18
46306 - 6 6 6 0 0 0 0 0 0 0 0 0
46307 - 0 0 0 0 0 0 0 0 0 0 0 0
46308 - 0 0 0 0 0 0 0 0 0 0 0 0
46309 - 0 0 0 0 0 0 0 0 0 0 0 0
46310 - 0 0 0 0 0 0 0 0 0 0 0 0
46311 - 0 0 0 0 0 0 0 0 0 0 0 0
46312 - 0 0 0 0 0 0 6 6 6 26 26 26
46313 - 62 62 62 106 106 106 74 54 14 185 133 11
46314 -210 162 10 121 92 8 6 6 6 62 62 62
46315 -238 238 238 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 231 231 231 246 246 246
46318 -253 253 253 253 253 253 253 253 253 253 253 253
46319 -253 253 253 253 253 253 253 253 253 253 253 253
46320 -253 253 253 253 253 253 253 253 253 253 253 253
46321 -253 253 253 253 253 253 253 253 253 253 253 253
46322 -253 253 253 253 253 253 158 158 158 18 18 18
46323 - 14 14 14 2 2 6 2 2 6 2 2 6
46324 - 6 6 6 18 18 18 66 66 66 38 38 38
46325 - 6 6 6 94 94 94 50 50 50 18 18 18
46326 - 6 6 6 0 0 0 0 0 0 0 0 0
46327 - 0 0 0 0 0 0 0 0 0 0 0 0
46328 - 0 0 0 0 0 0 0 0 0 0 0 0
46329 - 0 0 0 0 0 0 0 0 0 0 0 0
46330 - 0 0 0 0 0 0 0 0 0 0 0 0
46331 - 0 0 0 0 0 0 0 0 0 6 6 6
46332 - 10 10 10 10 10 10 18 18 18 38 38 38
46333 - 78 78 78 142 134 106 216 158 10 242 186 14
46334 -246 190 14 246 190 14 156 118 10 10 10 10
46335 - 90 90 90 238 238 238 253 253 253 253 253 253
46336 -253 253 253 253 253 253 253 253 253 253 253 253
46337 -253 253 253 253 253 253 231 231 231 250 250 250
46338 -253 253 253 253 253 253 253 253 253 253 253 253
46339 -253 253 253 253 253 253 253 253 253 253 253 253
46340 -253 253 253 253 253 253 253 253 253 253 253 253
46341 -253 253 253 253 253 253 253 253 253 246 230 190
46342 -238 204 91 238 204 91 181 142 44 37 26 9
46343 - 2 2 6 2 2 6 2 2 6 2 2 6
46344 - 2 2 6 2 2 6 38 38 38 46 46 46
46345 - 26 26 26 106 106 106 54 54 54 18 18 18
46346 - 6 6 6 0 0 0 0 0 0 0 0 0
46347 - 0 0 0 0 0 0 0 0 0 0 0 0
46348 - 0 0 0 0 0 0 0 0 0 0 0 0
46349 - 0 0 0 0 0 0 0 0 0 0 0 0
46350 - 0 0 0 0 0 0 0 0 0 0 0 0
46351 - 0 0 0 6 6 6 14 14 14 22 22 22
46352 - 30 30 30 38 38 38 50 50 50 70 70 70
46353 -106 106 106 190 142 34 226 170 11 242 186 14
46354 -246 190 14 246 190 14 246 190 14 154 114 10
46355 - 6 6 6 74 74 74 226 226 226 253 253 253
46356 -253 253 253 253 253 253 253 253 253 253 253 253
46357 -253 253 253 253 253 253 231 231 231 250 250 250
46358 -253 253 253 253 253 253 253 253 253 253 253 253
46359 -253 253 253 253 253 253 253 253 253 253 253 253
46360 -253 253 253 253 253 253 253 253 253 253 253 253
46361 -253 253 253 253 253 253 253 253 253 228 184 62
46362 -241 196 14 241 208 19 232 195 16 38 30 10
46363 - 2 2 6 2 2 6 2 2 6 2 2 6
46364 - 2 2 6 6 6 6 30 30 30 26 26 26
46365 -203 166 17 154 142 90 66 66 66 26 26 26
46366 - 6 6 6 0 0 0 0 0 0 0 0 0
46367 - 0 0 0 0 0 0 0 0 0 0 0 0
46368 - 0 0 0 0 0 0 0 0 0 0 0 0
46369 - 0 0 0 0 0 0 0 0 0 0 0 0
46370 - 0 0 0 0 0 0 0 0 0 0 0 0
46371 - 6 6 6 18 18 18 38 38 38 58 58 58
46372 - 78 78 78 86 86 86 101 101 101 123 123 123
46373 -175 146 61 210 150 10 234 174 13 246 186 14
46374 -246 190 14 246 190 14 246 190 14 238 190 10
46375 -102 78 10 2 2 6 46 46 46 198 198 198
46376 -253 253 253 253 253 253 253 253 253 253 253 253
46377 -253 253 253 253 253 253 234 234 234 242 242 242
46378 -253 253 253 253 253 253 253 253 253 253 253 253
46379 -253 253 253 253 253 253 253 253 253 253 253 253
46380 -253 253 253 253 253 253 253 253 253 253 253 253
46381 -253 253 253 253 253 253 253 253 253 224 178 62
46382 -242 186 14 241 196 14 210 166 10 22 18 6
46383 - 2 2 6 2 2 6 2 2 6 2 2 6
46384 - 2 2 6 2 2 6 6 6 6 121 92 8
46385 -238 202 15 232 195 16 82 82 82 34 34 34
46386 - 10 10 10 0 0 0 0 0 0 0 0 0
46387 - 0 0 0 0 0 0 0 0 0 0 0 0
46388 - 0 0 0 0 0 0 0 0 0 0 0 0
46389 - 0 0 0 0 0 0 0 0 0 0 0 0
46390 - 0 0 0 0 0 0 0 0 0 0 0 0
46391 - 14 14 14 38 38 38 70 70 70 154 122 46
46392 -190 142 34 200 144 11 197 138 11 197 138 11
46393 -213 154 11 226 170 11 242 186 14 246 190 14
46394 -246 190 14 246 190 14 246 190 14 246 190 14
46395 -225 175 15 46 32 6 2 2 6 22 22 22
46396 -158 158 158 250 250 250 253 253 253 253 253 253
46397 -253 253 253 253 253 253 253 253 253 253 253 253
46398 -253 253 253 253 253 253 253 253 253 253 253 253
46399 -253 253 253 253 253 253 253 253 253 253 253 253
46400 -253 253 253 253 253 253 253 253 253 253 253 253
46401 -253 253 253 250 250 250 242 242 242 224 178 62
46402 -239 182 13 236 186 11 213 154 11 46 32 6
46403 - 2 2 6 2 2 6 2 2 6 2 2 6
46404 - 2 2 6 2 2 6 61 42 6 225 175 15
46405 -238 190 10 236 186 11 112 100 78 42 42 42
46406 - 14 14 14 0 0 0 0 0 0 0 0 0
46407 - 0 0 0 0 0 0 0 0 0 0 0 0
46408 - 0 0 0 0 0 0 0 0 0 0 0 0
46409 - 0 0 0 0 0 0 0 0 0 0 0 0
46410 - 0 0 0 0 0 0 0 0 0 6 6 6
46411 - 22 22 22 54 54 54 154 122 46 213 154 11
46412 -226 170 11 230 174 11 226 170 11 226 170 11
46413 -236 178 12 242 186 14 246 190 14 246 190 14
46414 -246 190 14 246 190 14 246 190 14 246 190 14
46415 -241 196 14 184 144 12 10 10 10 2 2 6
46416 - 6 6 6 116 116 116 242 242 242 253 253 253
46417 -253 253 253 253 253 253 253 253 253 253 253 253
46418 -253 253 253 253 253 253 253 253 253 253 253 253
46419 -253 253 253 253 253 253 253 253 253 253 253 253
46420 -253 253 253 253 253 253 253 253 253 253 253 253
46421 -253 253 253 231 231 231 198 198 198 214 170 54
46422 -236 178 12 236 178 12 210 150 10 137 92 6
46423 - 18 14 6 2 2 6 2 2 6 2 2 6
46424 - 6 6 6 70 47 6 200 144 11 236 178 12
46425 -239 182 13 239 182 13 124 112 88 58 58 58
46426 - 22 22 22 6 6 6 0 0 0 0 0 0
46427 - 0 0 0 0 0 0 0 0 0 0 0 0
46428 - 0 0 0 0 0 0 0 0 0 0 0 0
46429 - 0 0 0 0 0 0 0 0 0 0 0 0
46430 - 0 0 0 0 0 0 0 0 0 10 10 10
46431 - 30 30 30 70 70 70 180 133 36 226 170 11
46432 -239 182 13 242 186 14 242 186 14 246 186 14
46433 -246 190 14 246 190 14 246 190 14 246 190 14
46434 -246 190 14 246 190 14 246 190 14 246 190 14
46435 -246 190 14 232 195 16 98 70 6 2 2 6
46436 - 2 2 6 2 2 6 66 66 66 221 221 221
46437 -253 253 253 253 253 253 253 253 253 253 253 253
46438 -253 253 253 253 253 253 253 253 253 253 253 253
46439 -253 253 253 253 253 253 253 253 253 253 253 253
46440 -253 253 253 253 253 253 253 253 253 253 253 253
46441 -253 253 253 206 206 206 198 198 198 214 166 58
46442 -230 174 11 230 174 11 216 158 10 192 133 9
46443 -163 110 8 116 81 8 102 78 10 116 81 8
46444 -167 114 7 197 138 11 226 170 11 239 182 13
46445 -242 186 14 242 186 14 162 146 94 78 78 78
46446 - 34 34 34 14 14 14 6 6 6 0 0 0
46447 - 0 0 0 0 0 0 0 0 0 0 0 0
46448 - 0 0 0 0 0 0 0 0 0 0 0 0
46449 - 0 0 0 0 0 0 0 0 0 0 0 0
46450 - 0 0 0 0 0 0 0 0 0 6 6 6
46451 - 30 30 30 78 78 78 190 142 34 226 170 11
46452 -239 182 13 246 190 14 246 190 14 246 190 14
46453 -246 190 14 246 190 14 246 190 14 246 190 14
46454 -246 190 14 246 190 14 246 190 14 246 190 14
46455 -246 190 14 241 196 14 203 166 17 22 18 6
46456 - 2 2 6 2 2 6 2 2 6 38 38 38
46457 -218 218 218 253 253 253 253 253 253 253 253 253
46458 -253 253 253 253 253 253 253 253 253 253 253 253
46459 -253 253 253 253 253 253 253 253 253 253 253 253
46460 -253 253 253 253 253 253 253 253 253 253 253 253
46461 -250 250 250 206 206 206 198 198 198 202 162 69
46462 -226 170 11 236 178 12 224 166 10 210 150 10
46463 -200 144 11 197 138 11 192 133 9 197 138 11
46464 -210 150 10 226 170 11 242 186 14 246 190 14
46465 -246 190 14 246 186 14 225 175 15 124 112 88
46466 - 62 62 62 30 30 30 14 14 14 6 6 6
46467 - 0 0 0 0 0 0 0 0 0 0 0 0
46468 - 0 0 0 0 0 0 0 0 0 0 0 0
46469 - 0 0 0 0 0 0 0 0 0 0 0 0
46470 - 0 0 0 0 0 0 0 0 0 10 10 10
46471 - 30 30 30 78 78 78 174 135 50 224 166 10
46472 -239 182 13 246 190 14 246 190 14 246 190 14
46473 -246 190 14 246 190 14 246 190 14 246 190 14
46474 -246 190 14 246 190 14 246 190 14 246 190 14
46475 -246 190 14 246 190 14 241 196 14 139 102 15
46476 - 2 2 6 2 2 6 2 2 6 2 2 6
46477 - 78 78 78 250 250 250 253 253 253 253 253 253
46478 -253 253 253 253 253 253 253 253 253 253 253 253
46479 -253 253 253 253 253 253 253 253 253 253 253 253
46480 -253 253 253 253 253 253 253 253 253 253 253 253
46481 -250 250 250 214 214 214 198 198 198 190 150 46
46482 -219 162 10 236 178 12 234 174 13 224 166 10
46483 -216 158 10 213 154 11 213 154 11 216 158 10
46484 -226 170 11 239 182 13 246 190 14 246 190 14
46485 -246 190 14 246 190 14 242 186 14 206 162 42
46486 -101 101 101 58 58 58 30 30 30 14 14 14
46487 - 6 6 6 0 0 0 0 0 0 0 0 0
46488 - 0 0 0 0 0 0 0 0 0 0 0 0
46489 - 0 0 0 0 0 0 0 0 0 0 0 0
46490 - 0 0 0 0 0 0 0 0 0 10 10 10
46491 - 30 30 30 74 74 74 174 135 50 216 158 10
46492 -236 178 12 246 190 14 246 190 14 246 190 14
46493 -246 190 14 246 190 14 246 190 14 246 190 14
46494 -246 190 14 246 190 14 246 190 14 246 190 14
46495 -246 190 14 246 190 14 241 196 14 226 184 13
46496 - 61 42 6 2 2 6 2 2 6 2 2 6
46497 - 22 22 22 238 238 238 253 253 253 253 253 253
46498 -253 253 253 253 253 253 253 253 253 253 253 253
46499 -253 253 253 253 253 253 253 253 253 253 253 253
46500 -253 253 253 253 253 253 253 253 253 253 253 253
46501 -253 253 253 226 226 226 187 187 187 180 133 36
46502 -216 158 10 236 178 12 239 182 13 236 178 12
46503 -230 174 11 226 170 11 226 170 11 230 174 11
46504 -236 178 12 242 186 14 246 190 14 246 190 14
46505 -246 190 14 246 190 14 246 186 14 239 182 13
46506 -206 162 42 106 106 106 66 66 66 34 34 34
46507 - 14 14 14 6 6 6 0 0 0 0 0 0
46508 - 0 0 0 0 0 0 0 0 0 0 0 0
46509 - 0 0 0 0 0 0 0 0 0 0 0 0
46510 - 0 0 0 0 0 0 0 0 0 6 6 6
46511 - 26 26 26 70 70 70 163 133 67 213 154 11
46512 -236 178 12 246 190 14 246 190 14 246 190 14
46513 -246 190 14 246 190 14 246 190 14 246 190 14
46514 -246 190 14 246 190 14 246 190 14 246 190 14
46515 -246 190 14 246 190 14 246 190 14 241 196 14
46516 -190 146 13 18 14 6 2 2 6 2 2 6
46517 - 46 46 46 246 246 246 253 253 253 253 253 253
46518 -253 253 253 253 253 253 253 253 253 253 253 253
46519 -253 253 253 253 253 253 253 253 253 253 253 253
46520 -253 253 253 253 253 253 253 253 253 253 253 253
46521 -253 253 253 221 221 221 86 86 86 156 107 11
46522 -216 158 10 236 178 12 242 186 14 246 186 14
46523 -242 186 14 239 182 13 239 182 13 242 186 14
46524 -242 186 14 246 186 14 246 190 14 246 190 14
46525 -246 190 14 246 190 14 246 190 14 246 190 14
46526 -242 186 14 225 175 15 142 122 72 66 66 66
46527 - 30 30 30 10 10 10 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 0 0 0 0 0 0 6 6 6
46531 - 26 26 26 70 70 70 163 133 67 210 150 10
46532 -236 178 12 246 190 14 246 190 14 246 190 14
46533 -246 190 14 246 190 14 246 190 14 246 190 14
46534 -246 190 14 246 190 14 246 190 14 246 190 14
46535 -246 190 14 246 190 14 246 190 14 246 190 14
46536 -232 195 16 121 92 8 34 34 34 106 106 106
46537 -221 221 221 253 253 253 253 253 253 253 253 253
46538 -253 253 253 253 253 253 253 253 253 253 253 253
46539 -253 253 253 253 253 253 253 253 253 253 253 253
46540 -253 253 253 253 253 253 253 253 253 253 253 253
46541 -242 242 242 82 82 82 18 14 6 163 110 8
46542 -216 158 10 236 178 12 242 186 14 246 190 14
46543 -246 190 14 246 190 14 246 190 14 246 190 14
46544 -246 190 14 246 190 14 246 190 14 246 190 14
46545 -246 190 14 246 190 14 246 190 14 246 190 14
46546 -246 190 14 246 190 14 242 186 14 163 133 67
46547 - 46 46 46 18 18 18 6 6 6 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 10 10 10
46551 - 30 30 30 78 78 78 163 133 67 210 150 10
46552 -236 178 12 246 186 14 246 190 14 246 190 14
46553 -246 190 14 246 190 14 246 190 14 246 190 14
46554 -246 190 14 246 190 14 246 190 14 246 190 14
46555 -246 190 14 246 190 14 246 190 14 246 190 14
46556 -241 196 14 215 174 15 190 178 144 253 253 253
46557 -253 253 253 253 253 253 253 253 253 253 253 253
46558 -253 253 253 253 253 253 253 253 253 253 253 253
46559 -253 253 253 253 253 253 253 253 253 253 253 253
46560 -253 253 253 253 253 253 253 253 253 218 218 218
46561 - 58 58 58 2 2 6 22 18 6 167 114 7
46562 -216 158 10 236 178 12 246 186 14 246 190 14
46563 -246 190 14 246 190 14 246 190 14 246 190 14
46564 -246 190 14 246 190 14 246 190 14 246 190 14
46565 -246 190 14 246 190 14 246 190 14 246 190 14
46566 -246 190 14 246 186 14 242 186 14 190 150 46
46567 - 54 54 54 22 22 22 6 6 6 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 14 14 14
46571 - 38 38 38 86 86 86 180 133 36 213 154 11
46572 -236 178 12 246 186 14 246 190 14 246 190 14
46573 -246 190 14 246 190 14 246 190 14 246 190 14
46574 -246 190 14 246 190 14 246 190 14 246 190 14
46575 -246 190 14 246 190 14 246 190 14 246 190 14
46576 -246 190 14 232 195 16 190 146 13 214 214 214
46577 -253 253 253 253 253 253 253 253 253 253 253 253
46578 -253 253 253 253 253 253 253 253 253 253 253 253
46579 -253 253 253 253 253 253 253 253 253 253 253 253
46580 -253 253 253 250 250 250 170 170 170 26 26 26
46581 - 2 2 6 2 2 6 37 26 9 163 110 8
46582 -219 162 10 239 182 13 246 186 14 246 190 14
46583 -246 190 14 246 190 14 246 190 14 246 190 14
46584 -246 190 14 246 190 14 246 190 14 246 190 14
46585 -246 190 14 246 190 14 246 190 14 246 190 14
46586 -246 186 14 236 178 12 224 166 10 142 122 72
46587 - 46 46 46 18 18 18 6 6 6 0 0 0
46588 - 0 0 0 0 0 0 0 0 0 0 0 0
46589 - 0 0 0 0 0 0 0 0 0 0 0 0
46590 - 0 0 0 0 0 0 6 6 6 18 18 18
46591 - 50 50 50 109 106 95 192 133 9 224 166 10
46592 -242 186 14 246 190 14 246 190 14 246 190 14
46593 -246 190 14 246 190 14 246 190 14 246 190 14
46594 -246 190 14 246 190 14 246 190 14 246 190 14
46595 -246 190 14 246 190 14 246 190 14 246 190 14
46596 -242 186 14 226 184 13 210 162 10 142 110 46
46597 -226 226 226 253 253 253 253 253 253 253 253 253
46598 -253 253 253 253 253 253 253 253 253 253 253 253
46599 -253 253 253 253 253 253 253 253 253 253 253 253
46600 -198 198 198 66 66 66 2 2 6 2 2 6
46601 - 2 2 6 2 2 6 50 34 6 156 107 11
46602 -219 162 10 239 182 13 246 186 14 246 190 14
46603 -246 190 14 246 190 14 246 190 14 246 190 14
46604 -246 190 14 246 190 14 246 190 14 246 190 14
46605 -246 190 14 246 190 14 246 190 14 242 186 14
46606 -234 174 13 213 154 11 154 122 46 66 66 66
46607 - 30 30 30 10 10 10 0 0 0 0 0 0
46608 - 0 0 0 0 0 0 0 0 0 0 0 0
46609 - 0 0 0 0 0 0 0 0 0 0 0 0
46610 - 0 0 0 0 0 0 6 6 6 22 22 22
46611 - 58 58 58 154 121 60 206 145 10 234 174 13
46612 -242 186 14 246 186 14 246 190 14 246 190 14
46613 -246 190 14 246 190 14 246 190 14 246 190 14
46614 -246 190 14 246 190 14 246 190 14 246 190 14
46615 -246 190 14 246 190 14 246 190 14 246 190 14
46616 -246 186 14 236 178 12 210 162 10 163 110 8
46617 - 61 42 6 138 138 138 218 218 218 250 250 250
46618 -253 253 253 253 253 253 253 253 253 250 250 250
46619 -242 242 242 210 210 210 144 144 144 66 66 66
46620 - 6 6 6 2 2 6 2 2 6 2 2 6
46621 - 2 2 6 2 2 6 61 42 6 163 110 8
46622 -216 158 10 236 178 12 246 190 14 246 190 14
46623 -246 190 14 246 190 14 246 190 14 246 190 14
46624 -246 190 14 246 190 14 246 190 14 246 190 14
46625 -246 190 14 239 182 13 230 174 11 216 158 10
46626 -190 142 34 124 112 88 70 70 70 38 38 38
46627 - 18 18 18 6 6 6 0 0 0 0 0 0
46628 - 0 0 0 0 0 0 0 0 0 0 0 0
46629 - 0 0 0 0 0 0 0 0 0 0 0 0
46630 - 0 0 0 0 0 0 6 6 6 22 22 22
46631 - 62 62 62 168 124 44 206 145 10 224 166 10
46632 -236 178 12 239 182 13 242 186 14 242 186 14
46633 -246 186 14 246 190 14 246 190 14 246 190 14
46634 -246 190 14 246 190 14 246 190 14 246 190 14
46635 -246 190 14 246 190 14 246 190 14 246 190 14
46636 -246 190 14 236 178 12 216 158 10 175 118 6
46637 - 80 54 7 2 2 6 6 6 6 30 30 30
46638 - 54 54 54 62 62 62 50 50 50 38 38 38
46639 - 14 14 14 2 2 6 2 2 6 2 2 6
46640 - 2 2 6 2 2 6 2 2 6 2 2 6
46641 - 2 2 6 6 6 6 80 54 7 167 114 7
46642 -213 154 11 236 178 12 246 190 14 246 190 14
46643 -246 190 14 246 190 14 246 190 14 246 190 14
46644 -246 190 14 242 186 14 239 182 13 239 182 13
46645 -230 174 11 210 150 10 174 135 50 124 112 88
46646 - 82 82 82 54 54 54 34 34 34 18 18 18
46647 - 6 6 6 0 0 0 0 0 0 0 0 0
46648 - 0 0 0 0 0 0 0 0 0 0 0 0
46649 - 0 0 0 0 0 0 0 0 0 0 0 0
46650 - 0 0 0 0 0 0 6 6 6 18 18 18
46651 - 50 50 50 158 118 36 192 133 9 200 144 11
46652 -216 158 10 219 162 10 224 166 10 226 170 11
46653 -230 174 11 236 178 12 239 182 13 239 182 13
46654 -242 186 14 246 186 14 246 190 14 246 190 14
46655 -246 190 14 246 190 14 246 190 14 246 190 14
46656 -246 186 14 230 174 11 210 150 10 163 110 8
46657 -104 69 6 10 10 10 2 2 6 2 2 6
46658 - 2 2 6 2 2 6 2 2 6 2 2 6
46659 - 2 2 6 2 2 6 2 2 6 2 2 6
46660 - 2 2 6 2 2 6 2 2 6 2 2 6
46661 - 2 2 6 6 6 6 91 60 6 167 114 7
46662 -206 145 10 230 174 11 242 186 14 246 190 14
46663 -246 190 14 246 190 14 246 186 14 242 186 14
46664 -239 182 13 230 174 11 224 166 10 213 154 11
46665 -180 133 36 124 112 88 86 86 86 58 58 58
46666 - 38 38 38 22 22 22 10 10 10 6 6 6
46667 - 0 0 0 0 0 0 0 0 0 0 0 0
46668 - 0 0 0 0 0 0 0 0 0 0 0 0
46669 - 0 0 0 0 0 0 0 0 0 0 0 0
46670 - 0 0 0 0 0 0 0 0 0 14 14 14
46671 - 34 34 34 70 70 70 138 110 50 158 118 36
46672 -167 114 7 180 123 7 192 133 9 197 138 11
46673 -200 144 11 206 145 10 213 154 11 219 162 10
46674 -224 166 10 230 174 11 239 182 13 242 186 14
46675 -246 186 14 246 186 14 246 186 14 246 186 14
46676 -239 182 13 216 158 10 185 133 11 152 99 6
46677 -104 69 6 18 14 6 2 2 6 2 2 6
46678 - 2 2 6 2 2 6 2 2 6 2 2 6
46679 - 2 2 6 2 2 6 2 2 6 2 2 6
46680 - 2 2 6 2 2 6 2 2 6 2 2 6
46681 - 2 2 6 6 6 6 80 54 7 152 99 6
46682 -192 133 9 219 162 10 236 178 12 239 182 13
46683 -246 186 14 242 186 14 239 182 13 236 178 12
46684 -224 166 10 206 145 10 192 133 9 154 121 60
46685 - 94 94 94 62 62 62 42 42 42 22 22 22
46686 - 14 14 14 6 6 6 0 0 0 0 0 0
46687 - 0 0 0 0 0 0 0 0 0 0 0 0
46688 - 0 0 0 0 0 0 0 0 0 0 0 0
46689 - 0 0 0 0 0 0 0 0 0 0 0 0
46690 - 0 0 0 0 0 0 0 0 0 6 6 6
46691 - 18 18 18 34 34 34 58 58 58 78 78 78
46692 -101 98 89 124 112 88 142 110 46 156 107 11
46693 -163 110 8 167 114 7 175 118 6 180 123 7
46694 -185 133 11 197 138 11 210 150 10 219 162 10
46695 -226 170 11 236 178 12 236 178 12 234 174 13
46696 -219 162 10 197 138 11 163 110 8 130 83 6
46697 - 91 60 6 10 10 10 2 2 6 2 2 6
46698 - 18 18 18 38 38 38 38 38 38 38 38 38
46699 - 38 38 38 38 38 38 38 38 38 38 38 38
46700 - 38 38 38 38 38 38 26 26 26 2 2 6
46701 - 2 2 6 6 6 6 70 47 6 137 92 6
46702 -175 118 6 200 144 11 219 162 10 230 174 11
46703 -234 174 13 230 174 11 219 162 10 210 150 10
46704 -192 133 9 163 110 8 124 112 88 82 82 82
46705 - 50 50 50 30 30 30 14 14 14 6 6 6
46706 - 0 0 0 0 0 0 0 0 0 0 0 0
46707 - 0 0 0 0 0 0 0 0 0 0 0 0
46708 - 0 0 0 0 0 0 0 0 0 0 0 0
46709 - 0 0 0 0 0 0 0 0 0 0 0 0
46710 - 0 0 0 0 0 0 0 0 0 0 0 0
46711 - 6 6 6 14 14 14 22 22 22 34 34 34
46712 - 42 42 42 58 58 58 74 74 74 86 86 86
46713 -101 98 89 122 102 70 130 98 46 121 87 25
46714 -137 92 6 152 99 6 163 110 8 180 123 7
46715 -185 133 11 197 138 11 206 145 10 200 144 11
46716 -180 123 7 156 107 11 130 83 6 104 69 6
46717 - 50 34 6 54 54 54 110 110 110 101 98 89
46718 - 86 86 86 82 82 82 78 78 78 78 78 78
46719 - 78 78 78 78 78 78 78 78 78 78 78 78
46720 - 78 78 78 82 82 82 86 86 86 94 94 94
46721 -106 106 106 101 101 101 86 66 34 124 80 6
46722 -156 107 11 180 123 7 192 133 9 200 144 11
46723 -206 145 10 200 144 11 192 133 9 175 118 6
46724 -139 102 15 109 106 95 70 70 70 42 42 42
46725 - 22 22 22 10 10 10 0 0 0 0 0 0
46726 - 0 0 0 0 0 0 0 0 0 0 0 0
46727 - 0 0 0 0 0 0 0 0 0 0 0 0
46728 - 0 0 0 0 0 0 0 0 0 0 0 0
46729 - 0 0 0 0 0 0 0 0 0 0 0 0
46730 - 0 0 0 0 0 0 0 0 0 0 0 0
46731 - 0 0 0 0 0 0 6 6 6 10 10 10
46732 - 14 14 14 22 22 22 30 30 30 38 38 38
46733 - 50 50 50 62 62 62 74 74 74 90 90 90
46734 -101 98 89 112 100 78 121 87 25 124 80 6
46735 -137 92 6 152 99 6 152 99 6 152 99 6
46736 -138 86 6 124 80 6 98 70 6 86 66 30
46737 -101 98 89 82 82 82 58 58 58 46 46 46
46738 - 38 38 38 34 34 34 34 34 34 34 34 34
46739 - 34 34 34 34 34 34 34 34 34 34 34 34
46740 - 34 34 34 34 34 34 38 38 38 42 42 42
46741 - 54 54 54 82 82 82 94 86 76 91 60 6
46742 -134 86 6 156 107 11 167 114 7 175 118 6
46743 -175 118 6 167 114 7 152 99 6 121 87 25
46744 -101 98 89 62 62 62 34 34 34 18 18 18
46745 - 6 6 6 0 0 0 0 0 0 0 0 0
46746 - 0 0 0 0 0 0 0 0 0 0 0 0
46747 - 0 0 0 0 0 0 0 0 0 0 0 0
46748 - 0 0 0 0 0 0 0 0 0 0 0 0
46749 - 0 0 0 0 0 0 0 0 0 0 0 0
46750 - 0 0 0 0 0 0 0 0 0 0 0 0
46751 - 0 0 0 0 0 0 0 0 0 0 0 0
46752 - 0 0 0 6 6 6 6 6 6 10 10 10
46753 - 18 18 18 22 22 22 30 30 30 42 42 42
46754 - 50 50 50 66 66 66 86 86 86 101 98 89
46755 -106 86 58 98 70 6 104 69 6 104 69 6
46756 -104 69 6 91 60 6 82 62 34 90 90 90
46757 - 62 62 62 38 38 38 22 22 22 14 14 14
46758 - 10 10 10 10 10 10 10 10 10 10 10 10
46759 - 10 10 10 10 10 10 6 6 6 10 10 10
46760 - 10 10 10 10 10 10 10 10 10 14 14 14
46761 - 22 22 22 42 42 42 70 70 70 89 81 66
46762 - 80 54 7 104 69 6 124 80 6 137 92 6
46763 -134 86 6 116 81 8 100 82 52 86 86 86
46764 - 58 58 58 30 30 30 14 14 14 6 6 6
46765 - 0 0 0 0 0 0 0 0 0 0 0 0
46766 - 0 0 0 0 0 0 0 0 0 0 0 0
46767 - 0 0 0 0 0 0 0 0 0 0 0 0
46768 - 0 0 0 0 0 0 0 0 0 0 0 0
46769 - 0 0 0 0 0 0 0 0 0 0 0 0
46770 - 0 0 0 0 0 0 0 0 0 0 0 0
46771 - 0 0 0 0 0 0 0 0 0 0 0 0
46772 - 0 0 0 0 0 0 0 0 0 0 0 0
46773 - 0 0 0 6 6 6 10 10 10 14 14 14
46774 - 18 18 18 26 26 26 38 38 38 54 54 54
46775 - 70 70 70 86 86 86 94 86 76 89 81 66
46776 - 89 81 66 86 86 86 74 74 74 50 50 50
46777 - 30 30 30 14 14 14 6 6 6 0 0 0
46778 - 0 0 0 0 0 0 0 0 0 0 0 0
46779 - 0 0 0 0 0 0 0 0 0 0 0 0
46780 - 0 0 0 0 0 0 0 0 0 0 0 0
46781 - 6 6 6 18 18 18 34 34 34 58 58 58
46782 - 82 82 82 89 81 66 89 81 66 89 81 66
46783 - 94 86 66 94 86 76 74 74 74 50 50 50
46784 - 26 26 26 14 14 14 6 6 6 0 0 0
46785 - 0 0 0 0 0 0 0 0 0 0 0 0
46786 - 0 0 0 0 0 0 0 0 0 0 0 0
46787 - 0 0 0 0 0 0 0 0 0 0 0 0
46788 - 0 0 0 0 0 0 0 0 0 0 0 0
46789 - 0 0 0 0 0 0 0 0 0 0 0 0
46790 - 0 0 0 0 0 0 0 0 0 0 0 0
46791 - 0 0 0 0 0 0 0 0 0 0 0 0
46792 - 0 0 0 0 0 0 0 0 0 0 0 0
46793 - 0 0 0 0 0 0 0 0 0 0 0 0
46794 - 6 6 6 6 6 6 14 14 14 18 18 18
46795 - 30 30 30 38 38 38 46 46 46 54 54 54
46796 - 50 50 50 42 42 42 30 30 30 18 18 18
46797 - 10 10 10 0 0 0 0 0 0 0 0 0
46798 - 0 0 0 0 0 0 0 0 0 0 0 0
46799 - 0 0 0 0 0 0 0 0 0 0 0 0
46800 - 0 0 0 0 0 0 0 0 0 0 0 0
46801 - 0 0 0 6 6 6 14 14 14 26 26 26
46802 - 38 38 38 50 50 50 58 58 58 58 58 58
46803 - 54 54 54 42 42 42 30 30 30 18 18 18
46804 - 10 10 10 0 0 0 0 0 0 0 0 0
46805 - 0 0 0 0 0 0 0 0 0 0 0 0
46806 - 0 0 0 0 0 0 0 0 0 0 0 0
46807 - 0 0 0 0 0 0 0 0 0 0 0 0
46808 - 0 0 0 0 0 0 0 0 0 0 0 0
46809 - 0 0 0 0 0 0 0 0 0 0 0 0
46810 - 0 0 0 0 0 0 0 0 0 0 0 0
46811 - 0 0 0 0 0 0 0 0 0 0 0 0
46812 - 0 0 0 0 0 0 0 0 0 0 0 0
46813 - 0 0 0 0 0 0 0 0 0 0 0 0
46814 - 0 0 0 0 0 0 0 0 0 6 6 6
46815 - 6 6 6 10 10 10 14 14 14 18 18 18
46816 - 18 18 18 14 14 14 10 10 10 6 6 6
46817 - 0 0 0 0 0 0 0 0 0 0 0 0
46818 - 0 0 0 0 0 0 0 0 0 0 0 0
46819 - 0 0 0 0 0 0 0 0 0 0 0 0
46820 - 0 0 0 0 0 0 0 0 0 0 0 0
46821 - 0 0 0 0 0 0 0 0 0 6 6 6
46822 - 14 14 14 18 18 18 22 22 22 22 22 22
46823 - 18 18 18 14 14 14 10 10 10 6 6 6
46824 - 0 0 0 0 0 0 0 0 0 0 0 0
46825 - 0 0 0 0 0 0 0 0 0 0 0 0
46826 - 0 0 0 0 0 0 0 0 0 0 0 0
46827 - 0 0 0 0 0 0 0 0 0 0 0 0
46828 - 0 0 0 0 0 0 0 0 0 0 0 0
46829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46842 +4 4 4 4 4 4
46843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46856 +4 4 4 4 4 4
46857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46870 +4 4 4 4 4 4
46871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46884 +4 4 4 4 4 4
46885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46898 +4 4 4 4 4 4
46899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46912 +4 4 4 4 4 4
46913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46917 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46918 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46923 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46924 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46926 +4 4 4 4 4 4
46927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46928 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46931 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46932 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46933 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46936 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46937 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46938 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46939 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46940 +4 4 4 4 4 4
46941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46945 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46946 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46947 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46950 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46951 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46952 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46953 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46954 +4 4 4 4 4 4
46955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46958 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46959 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46960 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46961 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46963 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46964 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46965 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46966 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46967 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46968 +4 4 4 4 4 4
46969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46972 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46973 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46974 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46975 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46976 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46977 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46978 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46979 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46980 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46981 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46982 +4 4 4 4 4 4
46983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46986 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46987 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46988 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46989 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46990 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46991 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46992 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46993 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46994 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46995 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46996 +4 4 4 4 4 4
46997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46999 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
47000 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
47001 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
47002 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
47003 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
47004 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
47005 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
47006 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
47007 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
47008 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
47009 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
47010 +4 4 4 4 4 4
47011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
47014 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
47015 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
47016 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
47017 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
47018 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
47019 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
47020 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
47021 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
47022 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
47023 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
47024 +4 4 4 4 4 4
47025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47027 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
47028 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
47029 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
47030 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
47031 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
47032 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
47033 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
47034 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
47035 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
47036 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
47037 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
47038 +4 4 4 4 4 4
47039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47041 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
47042 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
47043 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
47044 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
47045 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
47046 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
47047 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
47048 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
47049 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
47050 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
47051 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
47052 +4 4 4 4 4 4
47053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47054 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
47055 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
47056 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
47057 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
47058 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
47059 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
47060 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
47061 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47062 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47063 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47064 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47065 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47066 +4 4 4 4 4 4
47067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47068 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47069 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47070 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47071 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47072 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47073 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47074 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47075 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47076 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47077 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47078 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47079 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47080 +0 0 0 4 4 4
47081 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47082 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47083 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47084 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47085 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47086 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47087 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47088 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47089 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47090 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47091 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47092 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47093 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47094 +2 0 0 0 0 0
47095 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47096 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47097 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47098 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47099 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47100 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47101 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47102 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47103 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47104 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47105 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47106 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47107 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47108 +37 38 37 0 0 0
47109 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47110 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47111 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47112 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47113 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47114 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47115 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47116 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47117 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47118 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47119 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47120 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47121 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47122 +85 115 134 4 0 0
47123 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47124 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47125 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47126 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47127 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47128 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47129 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47130 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47131 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47132 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47133 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47134 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47135 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47136 +60 73 81 4 0 0
47137 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47138 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47139 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47140 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47141 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47142 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47143 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47144 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47145 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47146 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47147 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47148 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47149 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47150 +16 19 21 4 0 0
47151 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47152 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47153 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47154 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47155 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47156 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47157 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47158 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47159 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47160 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47161 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47162 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47163 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47164 +4 0 0 4 3 3
47165 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47166 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47167 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47168 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47169 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47170 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47171 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47172 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47173 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47174 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47175 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47176 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47177 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47178 +3 2 2 4 4 4
47179 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47180 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47181 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47182 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47183 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47184 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47185 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47186 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47187 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47188 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47189 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47190 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47191 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47192 +4 4 4 4 4 4
47193 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47194 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47195 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47196 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47197 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47198 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47199 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47200 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47201 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47202 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47203 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47204 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47205 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47206 +4 4 4 4 4 4
47207 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47208 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47209 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47210 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47211 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47212 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47213 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47214 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47215 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47216 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47217 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47218 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47219 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47220 +5 5 5 5 5 5
47221 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47222 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47223 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47224 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47225 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47226 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47227 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47228 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47229 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47230 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47231 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47232 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47233 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47234 +5 5 5 4 4 4
47235 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47236 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47237 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47238 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47239 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47240 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47241 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47242 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47243 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47244 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47245 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47246 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47248 +4 4 4 4 4 4
47249 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47250 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47251 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47252 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47253 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47254 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47255 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47256 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47257 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47258 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47259 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47260 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47262 +4 4 4 4 4 4
47263 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47264 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47265 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47266 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47267 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47268 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47269 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47270 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47271 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47272 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47273 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47276 +4 4 4 4 4 4
47277 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47278 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47279 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47280 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47281 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47282 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47283 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47284 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47285 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47286 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47287 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47290 +4 4 4 4 4 4
47291 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47292 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47293 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47294 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47295 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47296 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47297 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47298 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47299 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47300 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47301 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47304 +4 4 4 4 4 4
47305 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47306 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47307 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47308 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47309 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47310 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47311 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47312 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47313 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47314 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47315 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47318 +4 4 4 4 4 4
47319 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47320 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47321 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47322 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47323 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47324 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47325 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47326 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47327 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47328 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47329 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47332 +4 4 4 4 4 4
47333 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47334 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47335 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47336 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47337 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47338 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47339 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47340 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47341 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47342 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47343 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47346 +4 4 4 4 4 4
47347 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47348 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47349 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47350 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47351 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47352 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47353 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47354 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47355 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47356 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47357 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47360 +4 4 4 4 4 4
47361 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47362 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47363 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47364 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47365 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47366 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47367 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47368 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47369 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47370 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47371 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47374 +4 4 4 4 4 4
47375 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47376 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47377 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47378 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47379 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47380 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47381 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47382 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47383 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47384 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47385 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47388 +4 4 4 4 4 4
47389 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47390 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47391 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47392 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47393 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47394 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47395 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47396 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47397 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47398 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47399 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47402 +4 4 4 4 4 4
47403 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47404 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47405 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47406 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47407 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47408 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47409 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47410 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47411 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47412 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47413 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47416 +4 4 4 4 4 4
47417 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47418 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47419 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47420 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47421 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47422 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47423 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47424 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47425 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47426 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47427 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47430 +4 4 4 4 4 4
47431 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47432 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47433 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47434 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47435 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47436 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47437 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47438 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47439 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47440 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47441 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47444 +4 4 4 4 4 4
47445 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47446 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47447 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47448 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47449 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47450 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47451 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47452 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47453 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47454 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47455 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47458 +4 4 4 4 4 4
47459 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47460 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47461 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47462 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47463 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47464 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47465 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47466 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47467 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47468 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47469 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47472 +4 4 4 4 4 4
47473 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47474 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47475 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47476 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47477 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47478 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47479 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47480 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47481 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47482 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47483 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47486 +4 4 4 4 4 4
47487 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47488 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47489 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47490 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47491 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47492 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47493 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47494 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47495 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47496 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47497 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47500 +4 4 4 4 4 4
47501 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47502 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47503 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47504 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47505 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47506 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47507 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47508 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47509 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47510 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47511 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47514 +4 4 4 4 4 4
47515 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47516 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47517 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47518 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47519 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47520 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47521 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47522 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47523 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47524 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47525 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47528 +4 4 4 4 4 4
47529 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47530 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47531 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47532 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47533 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47534 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47535 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47536 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47537 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47538 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47539 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47542 +4 4 4 4 4 4
47543 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47544 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47545 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47546 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47547 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47548 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47549 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47550 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47551 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47552 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47553 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47556 +4 4 4 4 4 4
47557 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47558 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47559 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47560 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47561 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47562 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47563 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47564 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47565 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47566 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47567 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47570 +4 4 4 4 4 4
47571 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47572 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47573 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47574 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47575 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47576 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47577 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47578 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47579 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47580 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47581 +0 0 0 3 3 3 5 5 5 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 4 4 4
47583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47584 +4 4 4 4 4 4
47585 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47586 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47587 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47588 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47589 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47590 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47591 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47592 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47593 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47594 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47595 +0 0 0 3 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47598 +4 4 4 4 4 4
47599 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47600 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47601 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47602 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47603 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47604 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47605 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47606 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47607 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47608 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47609 +0 0 0 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 4 4 4 4 4 4 4 4 4 4 4 4
47612 +4 4 4 4 4 4
47613 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47614 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47615 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47616 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47617 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47618 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47619 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47620 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47621 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47622 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47623 +4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4
47626 +4 4 4 4 4 4
47627 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47628 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47629 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47630 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47631 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47632 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47633 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47634 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47635 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47636 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47637 +5 5 5 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 4 4 4
47640 +4 4 4 4 4 4
47641 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47642 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47643 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47644 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47645 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47646 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47647 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47648 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47649 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47650 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
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 4 4 4
47655 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47656 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47657 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47658 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47659 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47660 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47661 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47662 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47663 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47664 +13 16 17 4 0 0 4 0 0 4 3 3 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 4 4 4
47669 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47670 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47671 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47672 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47673 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47674 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47675 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47676 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47677 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47678 +4 0 0 4 0 0 5 5 5 5 5 5 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
47683 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47684 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47685 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47686 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47687 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47688 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47689 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47690 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47691 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47692 +4 3 3 5 5 5 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
47697 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47698 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47699 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47700 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47701 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47702 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47703 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47704 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47705 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47710 +4 4 4 4 4 4
47711 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47712 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47713 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47714 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47715 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47716 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47717 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47718 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47719 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47724 +4 4 4 4 4 4
47725 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47726 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47727 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47728 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47729 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47730 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47731 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47732 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47733 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47738 +4 4 4 4 4 4
47739 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47740 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47741 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47742 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47743 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47744 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47745 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47746 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47752 +4 4 4 4 4 4
47753 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47754 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47755 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47756 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47757 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47758 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47759 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47760 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47766 +4 4 4 4 4 4
47767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47768 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47769 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47770 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47771 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47772 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47773 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47774 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47780 +4 4 4 4 4 4
47781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47782 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47783 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47784 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47785 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47786 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47787 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47788 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47794 +4 4 4 4 4 4
47795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47796 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47797 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47798 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47799 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47800 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47801 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47802 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47808 +4 4 4 4 4 4
47809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47811 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47812 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47813 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47814 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47815 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47816 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47822 +4 4 4 4 4 4
47823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47826 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47827 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47828 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47829 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47836 +4 4 4 4 4 4
47837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47840 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47841 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47842 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47843 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47850 +4 4 4 4 4 4
47851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47854 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47855 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47856 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47857 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47864 +4 4 4 4 4 4
47865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47868 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47869 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47870 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47871 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47878 +4 4 4 4 4 4
47879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47883 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47884 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47885 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47892 +4 4 4 4 4 4
47893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47897 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47898 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47899 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47906 +4 4 4 4 4 4
47907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47911 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47912 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47913 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47920 +4 4 4 4 4 4
47921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47925 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47926 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47928 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47934 +4 4 4 4 4 4
47935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47939 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47940 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47948 +4 4 4 4 4 4
47949 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47950 index fe92eed..106e085 100644
47951 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47952 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47953 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47954 struct mb862xxfb_par *par = info->par;
47955
47956 if (info->var.bits_per_pixel == 32) {
47957 - info->fbops->fb_fillrect = cfb_fillrect;
47958 - info->fbops->fb_copyarea = cfb_copyarea;
47959 - info->fbops->fb_imageblit = cfb_imageblit;
47960 + pax_open_kernel();
47961 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47962 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47963 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47964 + pax_close_kernel();
47965 } else {
47966 outreg(disp, GC_L0EM, 3);
47967 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47968 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47969 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47970 + pax_open_kernel();
47971 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47972 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47973 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47974 + pax_close_kernel();
47975 }
47976 outreg(draw, GDC_REG_DRAW_BASE, 0);
47977 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47978 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47979 index ff22871..b129bed 100644
47980 --- a/drivers/video/nvidia/nvidia.c
47981 +++ b/drivers/video/nvidia/nvidia.c
47982 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47983 info->fix.line_length = (info->var.xres_virtual *
47984 info->var.bits_per_pixel) >> 3;
47985 if (info->var.accel_flags) {
47986 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47987 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47988 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47989 - info->fbops->fb_sync = nvidiafb_sync;
47990 + pax_open_kernel();
47991 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47992 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47993 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47994 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47995 + pax_close_kernel();
47996 info->pixmap.scan_align = 4;
47997 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47998 info->flags |= FBINFO_READS_FAST;
47999 NVResetGraphics(info);
48000 } else {
48001 - info->fbops->fb_imageblit = cfb_imageblit;
48002 - info->fbops->fb_fillrect = cfb_fillrect;
48003 - info->fbops->fb_copyarea = cfb_copyarea;
48004 - info->fbops->fb_sync = NULL;
48005 + pax_open_kernel();
48006 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
48007 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
48008 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
48009 + *(void **)&info->fbops->fb_sync = NULL;
48010 + pax_close_kernel();
48011 info->pixmap.scan_align = 1;
48012 info->flags |= FBINFO_HWACCEL_DISABLED;
48013 info->flags &= ~FBINFO_READS_FAST;
48014 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
48015 info->pixmap.size = 8 * 1024;
48016 info->pixmap.flags = FB_PIXMAP_SYSTEM;
48017
48018 - if (!hwcur)
48019 - info->fbops->fb_cursor = NULL;
48020 + if (!hwcur) {
48021 + pax_open_kernel();
48022 + *(void **)&info->fbops->fb_cursor = NULL;
48023 + pax_close_kernel();
48024 + }
48025
48026 info->var.accel_flags = (!noaccel);
48027
48028 diff --git a/drivers/video/output.c b/drivers/video/output.c
48029 index 0d6f2cd..6285b97 100644
48030 --- a/drivers/video/output.c
48031 +++ b/drivers/video/output.c
48032 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
48033 new_dev->props = op;
48034 new_dev->dev.class = &video_output_class;
48035 new_dev->dev.parent = dev;
48036 - dev_set_name(&new_dev->dev, name);
48037 + dev_set_name(&new_dev->dev, "%s", name);
48038 dev_set_drvdata(&new_dev->dev, devdata);
48039 ret_code = device_register(&new_dev->dev);
48040 if (ret_code) {
48041 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
48042 index 05c2dc3..ea1f391 100644
48043 --- a/drivers/video/s1d13xxxfb.c
48044 +++ b/drivers/video/s1d13xxxfb.c
48045 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
48046
48047 switch(prod_id) {
48048 case S1D13506_PROD_ID: /* activate acceleration */
48049 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48050 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48051 + pax_open_kernel();
48052 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48053 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48054 + pax_close_kernel();
48055 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
48056 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
48057 break;
48058 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
48059 index b2b33fc..f9f4658 100644
48060 --- a/drivers/video/smscufx.c
48061 +++ b/drivers/video/smscufx.c
48062 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48063 fb_deferred_io_cleanup(info);
48064 kfree(info->fbdefio);
48065 info->fbdefio = NULL;
48066 - info->fbops->fb_mmap = ufx_ops_mmap;
48067 + pax_open_kernel();
48068 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48069 + pax_close_kernel();
48070 }
48071
48072 pr_debug("released /dev/fb%d user=%d count=%d",
48073 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48074 index ec03e72..f578436 100644
48075 --- a/drivers/video/udlfb.c
48076 +++ b/drivers/video/udlfb.c
48077 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48078 dlfb_urb_completion(urb);
48079
48080 error:
48081 - atomic_add(bytes_sent, &dev->bytes_sent);
48082 - atomic_add(bytes_identical, &dev->bytes_identical);
48083 - atomic_add(width*height*2, &dev->bytes_rendered);
48084 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48085 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48086 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48087 end_cycles = get_cycles();
48088 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48089 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48090 >> 10)), /* Kcycles */
48091 &dev->cpu_kcycles_used);
48092
48093 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48094 dlfb_urb_completion(urb);
48095
48096 error:
48097 - atomic_add(bytes_sent, &dev->bytes_sent);
48098 - atomic_add(bytes_identical, &dev->bytes_identical);
48099 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48100 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48101 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48102 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48103 end_cycles = get_cycles();
48104 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48105 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48106 >> 10)), /* Kcycles */
48107 &dev->cpu_kcycles_used);
48108 }
48109 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48110 fb_deferred_io_cleanup(info);
48111 kfree(info->fbdefio);
48112 info->fbdefio = NULL;
48113 - info->fbops->fb_mmap = dlfb_ops_mmap;
48114 + pax_open_kernel();
48115 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48116 + pax_close_kernel();
48117 }
48118
48119 pr_warn("released /dev/fb%d user=%d count=%d\n",
48120 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48121 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48122 struct dlfb_data *dev = fb_info->par;
48123 return snprintf(buf, PAGE_SIZE, "%u\n",
48124 - atomic_read(&dev->bytes_rendered));
48125 + atomic_read_unchecked(&dev->bytes_rendered));
48126 }
48127
48128 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48129 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48130 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48131 struct dlfb_data *dev = fb_info->par;
48132 return snprintf(buf, PAGE_SIZE, "%u\n",
48133 - atomic_read(&dev->bytes_identical));
48134 + atomic_read_unchecked(&dev->bytes_identical));
48135 }
48136
48137 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48138 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48139 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48140 struct dlfb_data *dev = fb_info->par;
48141 return snprintf(buf, PAGE_SIZE, "%u\n",
48142 - atomic_read(&dev->bytes_sent));
48143 + atomic_read_unchecked(&dev->bytes_sent));
48144 }
48145
48146 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48147 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48148 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48149 struct dlfb_data *dev = fb_info->par;
48150 return snprintf(buf, PAGE_SIZE, "%u\n",
48151 - atomic_read(&dev->cpu_kcycles_used));
48152 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48153 }
48154
48155 static ssize_t edid_show(
48156 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48157 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48158 struct dlfb_data *dev = fb_info->par;
48159
48160 - atomic_set(&dev->bytes_rendered, 0);
48161 - atomic_set(&dev->bytes_identical, 0);
48162 - atomic_set(&dev->bytes_sent, 0);
48163 - atomic_set(&dev->cpu_kcycles_used, 0);
48164 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48165 + atomic_set_unchecked(&dev->bytes_identical, 0);
48166 + atomic_set_unchecked(&dev->bytes_sent, 0);
48167 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48168
48169 return count;
48170 }
48171 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48172 index e328a61..1b08ecb 100644
48173 --- a/drivers/video/uvesafb.c
48174 +++ b/drivers/video/uvesafb.c
48175 @@ -19,6 +19,7 @@
48176 #include <linux/io.h>
48177 #include <linux/mutex.h>
48178 #include <linux/slab.h>
48179 +#include <linux/moduleloader.h>
48180 #include <video/edid.h>
48181 #include <video/uvesafb.h>
48182 #ifdef CONFIG_X86
48183 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48184 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48185 par->pmi_setpal = par->ypan = 0;
48186 } else {
48187 +
48188 +#ifdef CONFIG_PAX_KERNEXEC
48189 +#ifdef CONFIG_MODULES
48190 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48191 +#endif
48192 + if (!par->pmi_code) {
48193 + par->pmi_setpal = par->ypan = 0;
48194 + return 0;
48195 + }
48196 +#endif
48197 +
48198 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48199 + task->t.regs.edi);
48200 +
48201 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48202 + pax_open_kernel();
48203 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48204 + pax_close_kernel();
48205 +
48206 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48207 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48208 +#else
48209 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48210 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48211 +#endif
48212 +
48213 printk(KERN_INFO "uvesafb: protected mode interface info at "
48214 "%04x:%04x\n",
48215 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48216 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48217 par->ypan = ypan;
48218
48219 if (par->pmi_setpal || par->ypan) {
48220 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48221 if (__supported_pte_mask & _PAGE_NX) {
48222 par->pmi_setpal = par->ypan = 0;
48223 printk(KERN_WARNING "uvesafb: NX protection is actively."
48224 "We have better not to use the PMI.\n");
48225 - } else {
48226 + } else
48227 +#endif
48228 uvesafb_vbe_getpmi(task, par);
48229 - }
48230 }
48231 #else
48232 /* The protected mode interface is not available on non-x86. */
48233 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48234 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48235
48236 /* Disable blanking if the user requested so. */
48237 - if (!blank)
48238 - info->fbops->fb_blank = NULL;
48239 + if (!blank) {
48240 + pax_open_kernel();
48241 + *(void **)&info->fbops->fb_blank = NULL;
48242 + pax_close_kernel();
48243 + }
48244
48245 /*
48246 * Find out how much IO memory is required for the mode with
48247 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48248 info->flags = FBINFO_FLAG_DEFAULT |
48249 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48250
48251 - if (!par->ypan)
48252 - info->fbops->fb_pan_display = NULL;
48253 + if (!par->ypan) {
48254 + pax_open_kernel();
48255 + *(void **)&info->fbops->fb_pan_display = NULL;
48256 + pax_close_kernel();
48257 + }
48258 }
48259
48260 static void uvesafb_init_mtrr(struct fb_info *info)
48261 @@ -1836,6 +1866,11 @@ out:
48262 if (par->vbe_modes)
48263 kfree(par->vbe_modes);
48264
48265 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48266 + if (par->pmi_code)
48267 + module_free_exec(NULL, par->pmi_code);
48268 +#endif
48269 +
48270 framebuffer_release(info);
48271 return err;
48272 }
48273 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48274 kfree(par->vbe_state_orig);
48275 if (par->vbe_state_saved)
48276 kfree(par->vbe_state_saved);
48277 +
48278 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48279 + if (par->pmi_code)
48280 + module_free_exec(NULL, par->pmi_code);
48281 +#endif
48282 +
48283 }
48284
48285 framebuffer_release(info);
48286 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48287 index 501b340..d80aa17 100644
48288 --- a/drivers/video/vesafb.c
48289 +++ b/drivers/video/vesafb.c
48290 @@ -9,6 +9,7 @@
48291 */
48292
48293 #include <linux/module.h>
48294 +#include <linux/moduleloader.h>
48295 #include <linux/kernel.h>
48296 #include <linux/errno.h>
48297 #include <linux/string.h>
48298 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48299 static int vram_total __initdata; /* Set total amount of memory */
48300 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48301 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48302 -static void (*pmi_start)(void) __read_mostly;
48303 -static void (*pmi_pal) (void) __read_mostly;
48304 +static void (*pmi_start)(void) __read_only;
48305 +static void (*pmi_pal) (void) __read_only;
48306 static int depth __read_mostly;
48307 static int vga_compat __read_mostly;
48308 /* --------------------------------------------------------------------- */
48309 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48310 unsigned int size_vmode;
48311 unsigned int size_remap;
48312 unsigned int size_total;
48313 + void *pmi_code = NULL;
48314
48315 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48316 return -ENODEV;
48317 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48318 size_remap = size_total;
48319 vesafb_fix.smem_len = size_remap;
48320
48321 -#ifndef __i386__
48322 - screen_info.vesapm_seg = 0;
48323 -#endif
48324 -
48325 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48326 printk(KERN_WARNING
48327 "vesafb: cannot reserve video memory at 0x%lx\n",
48328 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48329 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48330 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48331
48332 +#ifdef __i386__
48333 +
48334 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48335 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48336 + if (!pmi_code)
48337 +#elif !defined(CONFIG_PAX_KERNEXEC)
48338 + if (0)
48339 +#endif
48340 +
48341 +#endif
48342 + screen_info.vesapm_seg = 0;
48343 +
48344 if (screen_info.vesapm_seg) {
48345 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48346 - screen_info.vesapm_seg,screen_info.vesapm_off);
48347 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48348 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48349 }
48350
48351 if (screen_info.vesapm_seg < 0xc000)
48352 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48353
48354 if (ypan || pmi_setpal) {
48355 unsigned short *pmi_base;
48356 +
48357 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48358 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48359 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48360 +
48361 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48362 + pax_open_kernel();
48363 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48364 +#else
48365 + pmi_code = pmi_base;
48366 +#endif
48367 +
48368 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48369 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48370 +
48371 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48372 + pmi_start = ktva_ktla(pmi_start);
48373 + pmi_pal = ktva_ktla(pmi_pal);
48374 + pax_close_kernel();
48375 +#endif
48376 +
48377 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48378 if (pmi_base[3]) {
48379 printk(KERN_INFO "vesafb: pmi: ports = ");
48380 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48381 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48382 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48383
48384 - if (!ypan)
48385 - info->fbops->fb_pan_display = NULL;
48386 + if (!ypan) {
48387 + pax_open_kernel();
48388 + *(void **)&info->fbops->fb_pan_display = NULL;
48389 + pax_close_kernel();
48390 + }
48391
48392 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48393 err = -ENOMEM;
48394 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48395 info->node, info->fix.id);
48396 return 0;
48397 err:
48398 +
48399 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48400 + module_free_exec(NULL, pmi_code);
48401 +#endif
48402 +
48403 if (info->screen_base)
48404 iounmap(info->screen_base);
48405 framebuffer_release(info);
48406 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48407 index 88714ae..16c2e11 100644
48408 --- a/drivers/video/via/via_clock.h
48409 +++ b/drivers/video/via/via_clock.h
48410 @@ -56,7 +56,7 @@ struct via_clock {
48411
48412 void (*set_engine_pll_state)(u8 state);
48413 void (*set_engine_pll)(struct via_pll_config config);
48414 -};
48415 +} __no_const;
48416
48417
48418 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48419 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48420 index fef20db..d28b1ab 100644
48421 --- a/drivers/xen/xenfs/xenstored.c
48422 +++ b/drivers/xen/xenfs/xenstored.c
48423 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48424 static int xsd_kva_open(struct inode *inode, struct file *file)
48425 {
48426 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48427 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48428 + NULL);
48429 +#else
48430 xen_store_interface);
48431 +#endif
48432 +
48433 if (!file->private_data)
48434 return -ENOMEM;
48435 return 0;
48436 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
48437 index 055562c..fdfb10d 100644
48438 --- a/fs/9p/vfs_addr.c
48439 +++ b/fs/9p/vfs_addr.c
48440 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
48441
48442 retval = v9fs_file_write_internal(inode,
48443 v9inode->writeback_fid,
48444 - (__force const char __user *)buffer,
48445 + (const char __force_user *)buffer,
48446 len, &offset, 0);
48447 if (retval > 0)
48448 retval = 0;
48449 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48450 index d86edc8..40ff2fb 100644
48451 --- a/fs/9p/vfs_inode.c
48452 +++ b/fs/9p/vfs_inode.c
48453 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48454 void
48455 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48456 {
48457 - char *s = nd_get_link(nd);
48458 + const char *s = nd_get_link(nd);
48459
48460 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48461 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48462 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48463 index 370b24c..ff0be7b 100644
48464 --- a/fs/Kconfig.binfmt
48465 +++ b/fs/Kconfig.binfmt
48466 @@ -103,7 +103,7 @@ config HAVE_AOUT
48467
48468 config BINFMT_AOUT
48469 tristate "Kernel support for a.out and ECOFF binaries"
48470 - depends on HAVE_AOUT
48471 + depends on HAVE_AOUT && BROKEN
48472 ---help---
48473 A.out (Assembler.OUTput) is a set of formats for libraries and
48474 executables used in the earliest versions of UNIX. Linux used
48475 diff --git a/fs/aio.c b/fs/aio.c
48476 index 2bbcacf..8614116 100644
48477 --- a/fs/aio.c
48478 +++ b/fs/aio.c
48479 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48480 size += sizeof(struct io_event) * nr_events;
48481 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48482
48483 - if (nr_pages < 0)
48484 + if (nr_pages <= 0)
48485 return -EINVAL;
48486
48487 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48488 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
48489 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48490 {
48491 ssize_t ret;
48492 + struct iovec iovstack;
48493
48494 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48495
48496 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48497 if (compat)
48498 ret = compat_rw_copy_check_uvector(rw,
48499 (struct compat_iovec __user *)kiocb->ki_buf,
48500 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48501 + kiocb->ki_nr_segs, 1, &iovstack,
48502 &kiocb->ki_iovec);
48503 else
48504 #endif
48505 ret = rw_copy_check_uvector(rw,
48506 (struct iovec __user *)kiocb->ki_buf,
48507 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48508 + kiocb->ki_nr_segs, 1, &iovstack,
48509 &kiocb->ki_iovec);
48510 if (ret < 0)
48511 return ret;
48512
48513 + if (kiocb->ki_iovec == &iovstack) {
48514 + kiocb->ki_inline_vec = iovstack;
48515 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48516 + }
48517 +
48518 /* ki_nbytes now reflect bytes instead of segs */
48519 kiocb->ki_nbytes = ret;
48520 return 0;
48521 diff --git a/fs/attr.c b/fs/attr.c
48522 index 1449adb..a2038c2 100644
48523 --- a/fs/attr.c
48524 +++ b/fs/attr.c
48525 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48526 unsigned long limit;
48527
48528 limit = rlimit(RLIMIT_FSIZE);
48529 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48530 if (limit != RLIM_INFINITY && offset > limit)
48531 goto out_sig;
48532 if (offset > inode->i_sb->s_maxbytes)
48533 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48534 index 3db70da..7aeec5b 100644
48535 --- a/fs/autofs4/waitq.c
48536 +++ b/fs/autofs4/waitq.c
48537 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48538 {
48539 unsigned long sigpipe, flags;
48540 mm_segment_t fs;
48541 - const char *data = (const char *)addr;
48542 + const char __user *data = (const char __force_user *)addr;
48543 ssize_t wr = 0;
48544
48545 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48546 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48547 return 1;
48548 }
48549
48550 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48551 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48552 +#endif
48553 +
48554 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48555 enum autofs_notify notify)
48556 {
48557 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48558
48559 /* If this is a direct mount request create a dummy name */
48560 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48561 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48562 + /* this name does get written to userland via autofs4_write() */
48563 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48564 +#else
48565 qstr.len = sprintf(name, "%p", dentry);
48566 +#endif
48567 else {
48568 qstr.len = autofs4_getpath(sbi, dentry, &name);
48569 if (!qstr.len) {
48570 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48571 index 2722387..c8dd2a7 100644
48572 --- a/fs/befs/endian.h
48573 +++ b/fs/befs/endian.h
48574 @@ -11,7 +11,7 @@
48575
48576 #include <asm/byteorder.h>
48577
48578 -static inline u64
48579 +static inline u64 __intentional_overflow(-1)
48580 fs64_to_cpu(const struct super_block *sb, fs64 n)
48581 {
48582 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48583 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48584 return (__force fs64)cpu_to_be64(n);
48585 }
48586
48587 -static inline u32
48588 +static inline u32 __intentional_overflow(-1)
48589 fs32_to_cpu(const struct super_block *sb, fs32 n)
48590 {
48591 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48592 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48593 index f95dddc..b1e2c1c 100644
48594 --- a/fs/befs/linuxvfs.c
48595 +++ b/fs/befs/linuxvfs.c
48596 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48597 {
48598 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48599 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48600 - char *link = nd_get_link(nd);
48601 + const char *link = nd_get_link(nd);
48602 if (!IS_ERR(link))
48603 kfree(link);
48604 }
48605 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48606 index bce8769..7fc7544 100644
48607 --- a/fs/binfmt_aout.c
48608 +++ b/fs/binfmt_aout.c
48609 @@ -16,6 +16,7 @@
48610 #include <linux/string.h>
48611 #include <linux/fs.h>
48612 #include <linux/file.h>
48613 +#include <linux/security.h>
48614 #include <linux/stat.h>
48615 #include <linux/fcntl.h>
48616 #include <linux/ptrace.h>
48617 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48618 #endif
48619 # define START_STACK(u) ((void __user *)u.start_stack)
48620
48621 + memset(&dump, 0, sizeof(dump));
48622 +
48623 fs = get_fs();
48624 set_fs(KERNEL_DS);
48625 has_dumped = 1;
48626 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48627
48628 /* If the size of the dump file exceeds the rlimit, then see what would happen
48629 if we wrote the stack, but not the data area. */
48630 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48631 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48632 dump.u_dsize = 0;
48633
48634 /* Make sure we have enough room to write the stack and data areas. */
48635 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48636 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48637 dump.u_ssize = 0;
48638
48639 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48640 rlim = rlimit(RLIMIT_DATA);
48641 if (rlim >= RLIM_INFINITY)
48642 rlim = ~0;
48643 +
48644 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48645 if (ex.a_data + ex.a_bss > rlim)
48646 return -ENOMEM;
48647
48648 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48649
48650 install_exec_creds(bprm);
48651
48652 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48653 + current->mm->pax_flags = 0UL;
48654 +#endif
48655 +
48656 +#ifdef CONFIG_PAX_PAGEEXEC
48657 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48658 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48659 +
48660 +#ifdef CONFIG_PAX_EMUTRAMP
48661 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48662 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48663 +#endif
48664 +
48665 +#ifdef CONFIG_PAX_MPROTECT
48666 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48667 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48668 +#endif
48669 +
48670 + }
48671 +#endif
48672 +
48673 if (N_MAGIC(ex) == OMAGIC) {
48674 unsigned long text_addr, map_size;
48675 loff_t pos;
48676 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48677 }
48678
48679 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48680 - PROT_READ | PROT_WRITE | PROT_EXEC,
48681 + PROT_READ | PROT_WRITE,
48682 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48683 fd_offset + ex.a_text);
48684 if (error != N_DATADDR(ex)) {
48685 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48686 index f8a0b0e..8c841c3 100644
48687 --- a/fs/binfmt_elf.c
48688 +++ b/fs/binfmt_elf.c
48689 @@ -34,6 +34,7 @@
48690 #include <linux/utsname.h>
48691 #include <linux/coredump.h>
48692 #include <linux/sched.h>
48693 +#include <linux/xattr.h>
48694 #include <asm/uaccess.h>
48695 #include <asm/param.h>
48696 #include <asm/page.h>
48697 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
48698 #define elf_core_dump NULL
48699 #endif
48700
48701 +#ifdef CONFIG_PAX_MPROTECT
48702 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48703 +#endif
48704 +
48705 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
48706 +static void elf_handle_mmap(struct file *file);
48707 +#endif
48708 +
48709 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48710 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48711 #else
48712 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
48713 .load_binary = load_elf_binary,
48714 .load_shlib = load_elf_library,
48715 .core_dump = elf_core_dump,
48716 +
48717 +#ifdef CONFIG_PAX_MPROTECT
48718 + .handle_mprotect= elf_handle_mprotect,
48719 +#endif
48720 +
48721 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
48722 + .handle_mmap = elf_handle_mmap,
48723 +#endif
48724 +
48725 .min_coredump = ELF_EXEC_PAGESIZE,
48726 };
48727
48728 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
48729
48730 static int set_brk(unsigned long start, unsigned long end)
48731 {
48732 + unsigned long e = end;
48733 +
48734 start = ELF_PAGEALIGN(start);
48735 end = ELF_PAGEALIGN(end);
48736 if (end > start) {
48737 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
48738 if (BAD_ADDR(addr))
48739 return addr;
48740 }
48741 - current->mm->start_brk = current->mm->brk = end;
48742 + current->mm->start_brk = current->mm->brk = e;
48743 return 0;
48744 }
48745
48746 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48747 elf_addr_t __user *u_rand_bytes;
48748 const char *k_platform = ELF_PLATFORM;
48749 const char *k_base_platform = ELF_BASE_PLATFORM;
48750 - unsigned char k_rand_bytes[16];
48751 + u32 k_rand_bytes[4];
48752 int items;
48753 elf_addr_t *elf_info;
48754 int ei_index = 0;
48755 const struct cred *cred = current_cred();
48756 struct vm_area_struct *vma;
48757 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48758
48759 /*
48760 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48761 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48762 * Generate 16 random bytes for userspace PRNG seeding.
48763 */
48764 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48765 - u_rand_bytes = (elf_addr_t __user *)
48766 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48767 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
48768 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
48769 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
48770 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
48771 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48772 + u_rand_bytes = (elf_addr_t __user *) p;
48773 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48774 return -EFAULT;
48775
48776 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48777 return -EFAULT;
48778 current->mm->env_end = p;
48779
48780 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48781 +
48782 /* Put the elf_info on the stack in the right place. */
48783 sp = (elf_addr_t __user *)envp + 1;
48784 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48785 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48786 return -EFAULT;
48787 return 0;
48788 }
48789 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48790 an ELF header */
48791
48792 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48793 - struct file *interpreter, unsigned long *interp_map_addr,
48794 - unsigned long no_base)
48795 + struct file *interpreter, unsigned long no_base)
48796 {
48797 struct elf_phdr *elf_phdata;
48798 struct elf_phdr *eppnt;
48799 - unsigned long load_addr = 0;
48800 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48801 int load_addr_set = 0;
48802 unsigned long last_bss = 0, elf_bss = 0;
48803 - unsigned long error = ~0UL;
48804 + unsigned long error = -EINVAL;
48805 unsigned long total_size;
48806 int retval, i, size;
48807
48808 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48809 goto out_close;
48810 }
48811
48812 +#ifdef CONFIG_PAX_SEGMEXEC
48813 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48814 + pax_task_size = SEGMEXEC_TASK_SIZE;
48815 +#endif
48816 +
48817 eppnt = elf_phdata;
48818 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48819 if (eppnt->p_type == PT_LOAD) {
48820 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48821 map_addr = elf_map(interpreter, load_addr + vaddr,
48822 eppnt, elf_prot, elf_type, total_size);
48823 total_size = 0;
48824 - if (!*interp_map_addr)
48825 - *interp_map_addr = map_addr;
48826 error = map_addr;
48827 if (BAD_ADDR(map_addr))
48828 goto out_close;
48829 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48830 k = load_addr + eppnt->p_vaddr;
48831 if (BAD_ADDR(k) ||
48832 eppnt->p_filesz > eppnt->p_memsz ||
48833 - eppnt->p_memsz > TASK_SIZE ||
48834 - TASK_SIZE - eppnt->p_memsz < k) {
48835 + eppnt->p_memsz > pax_task_size ||
48836 + pax_task_size - eppnt->p_memsz < k) {
48837 error = -ENOMEM;
48838 goto out_close;
48839 }
48840 @@ -538,6 +567,315 @@ out:
48841 return error;
48842 }
48843
48844 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48845 +#ifdef CONFIG_PAX_SOFTMODE
48846 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48847 +{
48848 + unsigned long pax_flags = 0UL;
48849 +
48850 +#ifdef CONFIG_PAX_PAGEEXEC
48851 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48852 + pax_flags |= MF_PAX_PAGEEXEC;
48853 +#endif
48854 +
48855 +#ifdef CONFIG_PAX_SEGMEXEC
48856 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48857 + pax_flags |= MF_PAX_SEGMEXEC;
48858 +#endif
48859 +
48860 +#ifdef CONFIG_PAX_EMUTRAMP
48861 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48862 + pax_flags |= MF_PAX_EMUTRAMP;
48863 +#endif
48864 +
48865 +#ifdef CONFIG_PAX_MPROTECT
48866 + if (elf_phdata->p_flags & PF_MPROTECT)
48867 + pax_flags |= MF_PAX_MPROTECT;
48868 +#endif
48869 +
48870 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48871 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48872 + pax_flags |= MF_PAX_RANDMMAP;
48873 +#endif
48874 +
48875 + return pax_flags;
48876 +}
48877 +#endif
48878 +
48879 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48880 +{
48881 + unsigned long pax_flags = 0UL;
48882 +
48883 +#ifdef CONFIG_PAX_PAGEEXEC
48884 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48885 + pax_flags |= MF_PAX_PAGEEXEC;
48886 +#endif
48887 +
48888 +#ifdef CONFIG_PAX_SEGMEXEC
48889 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48890 + pax_flags |= MF_PAX_SEGMEXEC;
48891 +#endif
48892 +
48893 +#ifdef CONFIG_PAX_EMUTRAMP
48894 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48895 + pax_flags |= MF_PAX_EMUTRAMP;
48896 +#endif
48897 +
48898 +#ifdef CONFIG_PAX_MPROTECT
48899 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48900 + pax_flags |= MF_PAX_MPROTECT;
48901 +#endif
48902 +
48903 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48904 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48905 + pax_flags |= MF_PAX_RANDMMAP;
48906 +#endif
48907 +
48908 + return pax_flags;
48909 +}
48910 +#endif
48911 +
48912 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48913 +#ifdef CONFIG_PAX_SOFTMODE
48914 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48915 +{
48916 + unsigned long pax_flags = 0UL;
48917 +
48918 +#ifdef CONFIG_PAX_PAGEEXEC
48919 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48920 + pax_flags |= MF_PAX_PAGEEXEC;
48921 +#endif
48922 +
48923 +#ifdef CONFIG_PAX_SEGMEXEC
48924 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48925 + pax_flags |= MF_PAX_SEGMEXEC;
48926 +#endif
48927 +
48928 +#ifdef CONFIG_PAX_EMUTRAMP
48929 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48930 + pax_flags |= MF_PAX_EMUTRAMP;
48931 +#endif
48932 +
48933 +#ifdef CONFIG_PAX_MPROTECT
48934 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48935 + pax_flags |= MF_PAX_MPROTECT;
48936 +#endif
48937 +
48938 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48939 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48940 + pax_flags |= MF_PAX_RANDMMAP;
48941 +#endif
48942 +
48943 + return pax_flags;
48944 +}
48945 +#endif
48946 +
48947 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48948 +{
48949 + unsigned long pax_flags = 0UL;
48950 +
48951 +#ifdef CONFIG_PAX_PAGEEXEC
48952 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48953 + pax_flags |= MF_PAX_PAGEEXEC;
48954 +#endif
48955 +
48956 +#ifdef CONFIG_PAX_SEGMEXEC
48957 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48958 + pax_flags |= MF_PAX_SEGMEXEC;
48959 +#endif
48960 +
48961 +#ifdef CONFIG_PAX_EMUTRAMP
48962 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48963 + pax_flags |= MF_PAX_EMUTRAMP;
48964 +#endif
48965 +
48966 +#ifdef CONFIG_PAX_MPROTECT
48967 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48968 + pax_flags |= MF_PAX_MPROTECT;
48969 +#endif
48970 +
48971 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48972 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48973 + pax_flags |= MF_PAX_RANDMMAP;
48974 +#endif
48975 +
48976 + return pax_flags;
48977 +}
48978 +#endif
48979 +
48980 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48981 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48982 +{
48983 + unsigned long pax_flags = 0UL;
48984 +
48985 +#ifdef CONFIG_PAX_EI_PAX
48986 +
48987 +#ifdef CONFIG_PAX_PAGEEXEC
48988 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48989 + pax_flags |= MF_PAX_PAGEEXEC;
48990 +#endif
48991 +
48992 +#ifdef CONFIG_PAX_SEGMEXEC
48993 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48994 + pax_flags |= MF_PAX_SEGMEXEC;
48995 +#endif
48996 +
48997 +#ifdef CONFIG_PAX_EMUTRAMP
48998 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48999 + pax_flags |= MF_PAX_EMUTRAMP;
49000 +#endif
49001 +
49002 +#ifdef CONFIG_PAX_MPROTECT
49003 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
49004 + pax_flags |= MF_PAX_MPROTECT;
49005 +#endif
49006 +
49007 +#ifdef CONFIG_PAX_ASLR
49008 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
49009 + pax_flags |= MF_PAX_RANDMMAP;
49010 +#endif
49011 +
49012 +#else
49013 +
49014 +#ifdef CONFIG_PAX_PAGEEXEC
49015 + pax_flags |= MF_PAX_PAGEEXEC;
49016 +#endif
49017 +
49018 +#ifdef CONFIG_PAX_SEGMEXEC
49019 + pax_flags |= MF_PAX_SEGMEXEC;
49020 +#endif
49021 +
49022 +#ifdef CONFIG_PAX_MPROTECT
49023 + pax_flags |= MF_PAX_MPROTECT;
49024 +#endif
49025 +
49026 +#ifdef CONFIG_PAX_RANDMMAP
49027 + if (randomize_va_space)
49028 + pax_flags |= MF_PAX_RANDMMAP;
49029 +#endif
49030 +
49031 +#endif
49032 +
49033 + return pax_flags;
49034 +}
49035 +
49036 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
49037 +{
49038 +
49039 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
49040 + unsigned long i;
49041 +
49042 + for (i = 0UL; i < elf_ex->e_phnum; i++)
49043 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
49044 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
49045 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
49046 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
49047 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
49048 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
49049 + return ~0UL;
49050 +
49051 +#ifdef CONFIG_PAX_SOFTMODE
49052 + if (pax_softmode)
49053 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
49054 + else
49055 +#endif
49056 +
49057 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
49058 + break;
49059 + }
49060 +#endif
49061 +
49062 + return ~0UL;
49063 +}
49064 +
49065 +static unsigned long pax_parse_xattr_pax(struct file * const file)
49066 +{
49067 +
49068 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
49069 + ssize_t xattr_size, i;
49070 + unsigned char xattr_value[sizeof("pemrs") - 1];
49071 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
49072 +
49073 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
49074 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
49075 + return ~0UL;
49076 +
49077 + for (i = 0; i < xattr_size; i++)
49078 + switch (xattr_value[i]) {
49079 + default:
49080 + return ~0UL;
49081 +
49082 +#define parse_flag(option1, option2, flag) \
49083 + case option1: \
49084 + if (pax_flags_hardmode & MF_PAX_##flag) \
49085 + return ~0UL; \
49086 + pax_flags_hardmode |= MF_PAX_##flag; \
49087 + break; \
49088 + case option2: \
49089 + if (pax_flags_softmode & MF_PAX_##flag) \
49090 + return ~0UL; \
49091 + pax_flags_softmode |= MF_PAX_##flag; \
49092 + break;
49093 +
49094 + parse_flag('p', 'P', PAGEEXEC);
49095 + parse_flag('e', 'E', EMUTRAMP);
49096 + parse_flag('m', 'M', MPROTECT);
49097 + parse_flag('r', 'R', RANDMMAP);
49098 + parse_flag('s', 'S', SEGMEXEC);
49099 +
49100 +#undef parse_flag
49101 + }
49102 +
49103 + if (pax_flags_hardmode & pax_flags_softmode)
49104 + return ~0UL;
49105 +
49106 +#ifdef CONFIG_PAX_SOFTMODE
49107 + if (pax_softmode)
49108 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49109 + else
49110 +#endif
49111 +
49112 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49113 +#else
49114 + return ~0UL;
49115 +#endif
49116 +
49117 +}
49118 +
49119 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49120 +{
49121 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49122 +
49123 + pax_flags = pax_parse_ei_pax(elf_ex);
49124 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49125 + xattr_pax_flags = pax_parse_xattr_pax(file);
49126 +
49127 + if (pt_pax_flags == ~0UL)
49128 + pt_pax_flags = xattr_pax_flags;
49129 + else if (xattr_pax_flags == ~0UL)
49130 + xattr_pax_flags = pt_pax_flags;
49131 + if (pt_pax_flags != xattr_pax_flags)
49132 + return -EINVAL;
49133 + if (pt_pax_flags != ~0UL)
49134 + pax_flags = pt_pax_flags;
49135 +
49136 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49137 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49138 + if ((__supported_pte_mask & _PAGE_NX))
49139 + pax_flags &= ~MF_PAX_SEGMEXEC;
49140 + else
49141 + pax_flags &= ~MF_PAX_PAGEEXEC;
49142 + }
49143 +#endif
49144 +
49145 + if (0 > pax_check_flags(&pax_flags))
49146 + return -EINVAL;
49147 +
49148 + current->mm->pax_flags = pax_flags;
49149 + return 0;
49150 +}
49151 +#endif
49152 +
49153 /*
49154 * These are the functions used to load ELF style executables and shared
49155 * libraries. There is no binary dependent code anywhere else.
49156 @@ -554,6 +892,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49157 {
49158 unsigned int random_variable = 0;
49159
49160 +#ifdef CONFIG_PAX_RANDUSTACK
49161 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49162 + return stack_top - current->mm->delta_stack;
49163 +#endif
49164 +
49165 if ((current->flags & PF_RANDOMIZE) &&
49166 !(current->personality & ADDR_NO_RANDOMIZE)) {
49167 random_variable = get_random_int() & STACK_RND_MASK;
49168 @@ -572,7 +915,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49169 unsigned long load_addr = 0, load_bias = 0;
49170 int load_addr_set = 0;
49171 char * elf_interpreter = NULL;
49172 - unsigned long error;
49173 + unsigned long error = 0;
49174 struct elf_phdr *elf_ppnt, *elf_phdata;
49175 unsigned long elf_bss, elf_brk;
49176 int retval, i;
49177 @@ -582,12 +925,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49178 unsigned long start_code, end_code, start_data, end_data;
49179 unsigned long reloc_func_desc __maybe_unused = 0;
49180 int executable_stack = EXSTACK_DEFAULT;
49181 - unsigned long def_flags = 0;
49182 struct pt_regs *regs = current_pt_regs();
49183 struct {
49184 struct elfhdr elf_ex;
49185 struct elfhdr interp_elf_ex;
49186 } *loc;
49187 + unsigned long pax_task_size = TASK_SIZE;
49188
49189 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49190 if (!loc) {
49191 @@ -723,11 +1066,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49192 goto out_free_dentry;
49193
49194 /* OK, This is the point of no return */
49195 - current->mm->def_flags = def_flags;
49196 +
49197 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49198 + current->mm->pax_flags = 0UL;
49199 +#endif
49200 +
49201 +#ifdef CONFIG_PAX_DLRESOLVE
49202 + current->mm->call_dl_resolve = 0UL;
49203 +#endif
49204 +
49205 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49206 + current->mm->call_syscall = 0UL;
49207 +#endif
49208 +
49209 +#ifdef CONFIG_PAX_ASLR
49210 + current->mm->delta_mmap = 0UL;
49211 + current->mm->delta_stack = 0UL;
49212 +#endif
49213 +
49214 + current->mm->def_flags = 0;
49215 +
49216 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49217 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49218 + send_sig(SIGKILL, current, 0);
49219 + goto out_free_dentry;
49220 + }
49221 +#endif
49222 +
49223 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49224 + pax_set_initial_flags(bprm);
49225 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49226 + if (pax_set_initial_flags_func)
49227 + (pax_set_initial_flags_func)(bprm);
49228 +#endif
49229 +
49230 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49231 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49232 + current->mm->context.user_cs_limit = PAGE_SIZE;
49233 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49234 + }
49235 +#endif
49236 +
49237 +#ifdef CONFIG_PAX_SEGMEXEC
49238 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49239 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49240 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49241 + pax_task_size = SEGMEXEC_TASK_SIZE;
49242 + current->mm->def_flags |= VM_NOHUGEPAGE;
49243 + }
49244 +#endif
49245 +
49246 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49247 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49248 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49249 + put_cpu();
49250 + }
49251 +#endif
49252
49253 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49254 may depend on the personality. */
49255 SET_PERSONALITY(loc->elf_ex);
49256 +
49257 +#ifdef CONFIG_PAX_ASLR
49258 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49259 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49260 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49261 + }
49262 +#endif
49263 +
49264 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49265 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49266 + executable_stack = EXSTACK_DISABLE_X;
49267 + current->personality &= ~READ_IMPLIES_EXEC;
49268 + } else
49269 +#endif
49270 +
49271 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49272 current->personality |= READ_IMPLIES_EXEC;
49273
49274 @@ -819,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49275 #else
49276 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49277 #endif
49278 +
49279 +#ifdef CONFIG_PAX_RANDMMAP
49280 + /* PaX: randomize base address at the default exe base if requested */
49281 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49282 +#ifdef CONFIG_SPARC64
49283 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49284 +#else
49285 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49286 +#endif
49287 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49288 + elf_flags |= MAP_FIXED;
49289 + }
49290 +#endif
49291 +
49292 }
49293
49294 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49295 @@ -851,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49296 * allowed task size. Note that p_filesz must always be
49297 * <= p_memsz so it is only necessary to check p_memsz.
49298 */
49299 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49300 - elf_ppnt->p_memsz > TASK_SIZE ||
49301 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49302 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49303 + elf_ppnt->p_memsz > pax_task_size ||
49304 + pax_task_size - elf_ppnt->p_memsz < k) {
49305 /* set_brk can never work. Avoid overflows. */
49306 send_sig(SIGKILL, current, 0);
49307 retval = -EINVAL;
49308 @@ -892,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
49309 goto out_free_dentry;
49310 }
49311 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49312 - send_sig(SIGSEGV, current, 0);
49313 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49314 - goto out_free_dentry;
49315 + /*
49316 + * This bss-zeroing can fail if the ELF
49317 + * file specifies odd protections. So
49318 + * we don't check the return value
49319 + */
49320 }
49321
49322 +#ifdef CONFIG_PAX_RANDMMAP
49323 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49324 + unsigned long start, size, flags;
49325 + vm_flags_t vm_flags;
49326 +
49327 + start = ELF_PAGEALIGN(elf_brk);
49328 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49329 + flags = MAP_FIXED | MAP_PRIVATE;
49330 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49331 +
49332 + down_write(&current->mm->mmap_sem);
49333 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49334 + retval = -ENOMEM;
49335 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49336 +// if (current->personality & ADDR_NO_RANDOMIZE)
49337 +// vm_flags |= VM_READ | VM_MAYREAD;
49338 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
49339 + retval = IS_ERR_VALUE(start) ? start : 0;
49340 + }
49341 + up_write(&current->mm->mmap_sem);
49342 + if (retval == 0)
49343 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49344 + if (retval < 0) {
49345 + send_sig(SIGKILL, current, 0);
49346 + goto out_free_dentry;
49347 + }
49348 + }
49349 +#endif
49350 +
49351 if (elf_interpreter) {
49352 - unsigned long interp_map_addr = 0;
49353 -
49354 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49355 interpreter,
49356 - &interp_map_addr,
49357 load_bias);
49358 if (!IS_ERR((void *)elf_entry)) {
49359 /*
49360 @@ -1124,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49361 * Decide what to dump of a segment, part, all or none.
49362 */
49363 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49364 - unsigned long mm_flags)
49365 + unsigned long mm_flags, long signr)
49366 {
49367 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49368
49369 @@ -1162,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49370 if (vma->vm_file == NULL)
49371 return 0;
49372
49373 - if (FILTER(MAPPED_PRIVATE))
49374 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49375 goto whole;
49376
49377 /*
49378 @@ -1387,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49379 {
49380 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49381 int i = 0;
49382 - do
49383 + do {
49384 i += 2;
49385 - while (auxv[i - 2] != AT_NULL);
49386 + } while (auxv[i - 2] != AT_NULL);
49387 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49388 }
49389
49390 @@ -1398,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
49391 {
49392 mm_segment_t old_fs = get_fs();
49393 set_fs(KERNEL_DS);
49394 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
49395 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
49396 set_fs(old_fs);
49397 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
49398 }
49399 @@ -2019,14 +2474,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49400 }
49401
49402 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49403 - unsigned long mm_flags)
49404 + struct coredump_params *cprm)
49405 {
49406 struct vm_area_struct *vma;
49407 size_t size = 0;
49408
49409 for (vma = first_vma(current, gate_vma); vma != NULL;
49410 vma = next_vma(vma, gate_vma))
49411 - size += vma_dump_size(vma, mm_flags);
49412 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49413 return size;
49414 }
49415
49416 @@ -2119,7 +2574,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49417
49418 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49419
49420 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49421 + offset += elf_core_vma_data_size(gate_vma, cprm);
49422 offset += elf_core_extra_data_size();
49423 e_shoff = offset;
49424
49425 @@ -2133,10 +2588,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49426 offset = dataoff;
49427
49428 size += sizeof(*elf);
49429 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49430 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49431 goto end_coredump;
49432
49433 size += sizeof(*phdr4note);
49434 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49435 if (size > cprm->limit
49436 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49437 goto end_coredump;
49438 @@ -2150,7 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49439 phdr.p_offset = offset;
49440 phdr.p_vaddr = vma->vm_start;
49441 phdr.p_paddr = 0;
49442 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49443 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49444 phdr.p_memsz = vma->vm_end - vma->vm_start;
49445 offset += phdr.p_filesz;
49446 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49447 @@ -2161,6 +2618,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49448 phdr.p_align = ELF_EXEC_PAGESIZE;
49449
49450 size += sizeof(phdr);
49451 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49452 if (size > cprm->limit
49453 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49454 goto end_coredump;
49455 @@ -2185,7 +2643,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49456 unsigned long addr;
49457 unsigned long end;
49458
49459 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49460 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49461
49462 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49463 struct page *page;
49464 @@ -2194,6 +2652,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49465 page = get_dump_page(addr);
49466 if (page) {
49467 void *kaddr = kmap(page);
49468 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49469 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49470 !dump_write(cprm->file, kaddr,
49471 PAGE_SIZE);
49472 @@ -2211,6 +2670,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49473
49474 if (e_phnum == PN_XNUM) {
49475 size += sizeof(*shdr4extnum);
49476 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49477 if (size > cprm->limit
49478 || !dump_write(cprm->file, shdr4extnum,
49479 sizeof(*shdr4extnum)))
49480 @@ -2231,6 +2691,167 @@ out:
49481
49482 #endif /* CONFIG_ELF_CORE */
49483
49484 +#ifdef CONFIG_PAX_MPROTECT
49485 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49486 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49487 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49488 + *
49489 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49490 + * basis because we want to allow the common case and not the special ones.
49491 + */
49492 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49493 +{
49494 + struct elfhdr elf_h;
49495 + struct elf_phdr elf_p;
49496 + unsigned long i;
49497 + unsigned long oldflags;
49498 + bool is_textrel_rw, is_textrel_rx, is_relro;
49499 +
49500 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49501 + return;
49502 +
49503 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49504 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49505 +
49506 +#ifdef CONFIG_PAX_ELFRELOCS
49507 + /* possible TEXTREL */
49508 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49509 + 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);
49510 +#else
49511 + is_textrel_rw = false;
49512 + is_textrel_rx = false;
49513 +#endif
49514 +
49515 + /* possible RELRO */
49516 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49517 +
49518 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49519 + return;
49520 +
49521 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49522 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49523 +
49524 +#ifdef CONFIG_PAX_ETEXECRELOCS
49525 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49526 +#else
49527 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49528 +#endif
49529 +
49530 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49531 + !elf_check_arch(&elf_h) ||
49532 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49533 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49534 + return;
49535 +
49536 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49537 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49538 + return;
49539 + switch (elf_p.p_type) {
49540 + case PT_DYNAMIC:
49541 + if (!is_textrel_rw && !is_textrel_rx)
49542 + continue;
49543 + i = 0UL;
49544 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49545 + elf_dyn dyn;
49546 +
49547 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49548 + break;
49549 + if (dyn.d_tag == DT_NULL)
49550 + break;
49551 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49552 + gr_log_textrel(vma);
49553 + if (is_textrel_rw)
49554 + vma->vm_flags |= VM_MAYWRITE;
49555 + else
49556 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49557 + vma->vm_flags &= ~VM_MAYWRITE;
49558 + break;
49559 + }
49560 + i++;
49561 + }
49562 + is_textrel_rw = false;
49563 + is_textrel_rx = false;
49564 + continue;
49565 +
49566 + case PT_GNU_RELRO:
49567 + if (!is_relro)
49568 + continue;
49569 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49570 + vma->vm_flags &= ~VM_MAYWRITE;
49571 + is_relro = false;
49572 + continue;
49573 +
49574 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
49575 + case PT_PAX_FLAGS: {
49576 + const char *msg_mprotect = "", *msg_emutramp = "";
49577 + char *buffer_lib, *buffer_exe;
49578 +
49579 + if (elf_p.p_flags & PF_NOMPROTECT)
49580 + msg_mprotect = "MPROTECT disabled";
49581 +
49582 +#ifdef CONFIG_PAX_EMUTRAMP
49583 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
49584 + msg_emutramp = "EMUTRAMP enabled";
49585 +#endif
49586 +
49587 + if (!msg_mprotect[0] && !msg_emutramp[0])
49588 + continue;
49589 +
49590 + if (!printk_ratelimit())
49591 + continue;
49592 +
49593 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
49594 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
49595 + if (buffer_lib && buffer_exe) {
49596 + char *path_lib, *path_exe;
49597 +
49598 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
49599 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
49600 +
49601 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
49602 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
49603 +
49604 + }
49605 + free_page((unsigned long)buffer_exe);
49606 + free_page((unsigned long)buffer_lib);
49607 + continue;
49608 + }
49609 +#endif
49610 +
49611 + }
49612 + }
49613 +}
49614 +#endif
49615 +
49616 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
49617 +
49618 +extern int grsec_enable_log_rwxmaps;
49619 +
49620 +static void elf_handle_mmap(struct file *file)
49621 +{
49622 + struct elfhdr elf_h;
49623 + struct elf_phdr elf_p;
49624 + unsigned long i;
49625 +
49626 + if (!grsec_enable_log_rwxmaps)
49627 + return;
49628 +
49629 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49630 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49631 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
49632 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49633 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49634 + return;
49635 +
49636 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49637 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49638 + return;
49639 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
49640 + gr_log_ptgnustack(file);
49641 + }
49642 +}
49643 +#endif
49644 +
49645 static int __init init_elf_binfmt(void)
49646 {
49647 register_binfmt(&elf_format);
49648 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49649 index d50bbe5..af3b649 100644
49650 --- a/fs/binfmt_flat.c
49651 +++ b/fs/binfmt_flat.c
49652 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49653 realdatastart = (unsigned long) -ENOMEM;
49654 printk("Unable to allocate RAM for process data, errno %d\n",
49655 (int)-realdatastart);
49656 + down_write(&current->mm->mmap_sem);
49657 vm_munmap(textpos, text_len);
49658 + up_write(&current->mm->mmap_sem);
49659 ret = realdatastart;
49660 goto err;
49661 }
49662 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49663 }
49664 if (IS_ERR_VALUE(result)) {
49665 printk("Unable to read data+bss, errno %d\n", (int)-result);
49666 + down_write(&current->mm->mmap_sem);
49667 vm_munmap(textpos, text_len);
49668 vm_munmap(realdatastart, len);
49669 + up_write(&current->mm->mmap_sem);
49670 ret = result;
49671 goto err;
49672 }
49673 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49674 }
49675 if (IS_ERR_VALUE(result)) {
49676 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49677 + down_write(&current->mm->mmap_sem);
49678 vm_munmap(textpos, text_len + data_len + extra +
49679 MAX_SHARED_LIBS * sizeof(unsigned long));
49680 + up_write(&current->mm->mmap_sem);
49681 ret = result;
49682 goto err;
49683 }
49684 diff --git a/fs/bio.c b/fs/bio.c
49685 index 94bbc04..6fe78a4 100644
49686 --- a/fs/bio.c
49687 +++ b/fs/bio.c
49688 @@ -1096,7 +1096,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49689 /*
49690 * Overflow, abort
49691 */
49692 - if (end < start)
49693 + if (end < start || end - start > INT_MAX - nr_pages)
49694 return ERR_PTR(-EINVAL);
49695
49696 nr_pages += end - start;
49697 @@ -1230,7 +1230,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49698 /*
49699 * Overflow, abort
49700 */
49701 - if (end < start)
49702 + if (end < start || end - start > INT_MAX - nr_pages)
49703 return ERR_PTR(-EINVAL);
49704
49705 nr_pages += end - start;
49706 @@ -1492,7 +1492,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49707 const int read = bio_data_dir(bio) == READ;
49708 struct bio_map_data *bmd = bio->bi_private;
49709 int i;
49710 - char *p = bmd->sgvecs[0].iov_base;
49711 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49712
49713 bio_for_each_segment_all(bvec, bio, i) {
49714 char *addr = page_address(bvec->bv_page);
49715 diff --git a/fs/block_dev.c b/fs/block_dev.c
49716 index 85f5c85..d6f0b1a 100644
49717 --- a/fs/block_dev.c
49718 +++ b/fs/block_dev.c
49719 @@ -658,7 +658,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49720 else if (bdev->bd_contains == bdev)
49721 return true; /* is a whole device which isn't held */
49722
49723 - else if (whole->bd_holder == bd_may_claim)
49724 + else if (whole->bd_holder == (void *)bd_may_claim)
49725 return true; /* is a partition of a device that is being partitioned */
49726 else if (whole->bd_holder != NULL)
49727 return false; /* is a partition of a held device */
49728 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49729 index 7fb054b..ad36c67 100644
49730 --- a/fs/btrfs/ctree.c
49731 +++ b/fs/btrfs/ctree.c
49732 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49733 free_extent_buffer(buf);
49734 add_root_to_dirty_list(root);
49735 } else {
49736 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49737 - parent_start = parent->start;
49738 - else
49739 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49740 + if (parent)
49741 + parent_start = parent->start;
49742 + else
49743 + parent_start = 0;
49744 + } else
49745 parent_start = 0;
49746
49747 WARN_ON(trans->transid != btrfs_header_generation(parent));
49748 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49749 index 0f81d67..0ad55fe 100644
49750 --- a/fs/btrfs/ioctl.c
49751 +++ b/fs/btrfs/ioctl.c
49752 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49753 for (i = 0; i < num_types; i++) {
49754 struct btrfs_space_info *tmp;
49755
49756 + /* Don't copy in more than we allocated */
49757 if (!slot_count)
49758 break;
49759
49760 + slot_count--;
49761 +
49762 info = NULL;
49763 rcu_read_lock();
49764 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49765 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49766 memcpy(dest, &space, sizeof(space));
49767 dest++;
49768 space_args.total_spaces++;
49769 - slot_count--;
49770 }
49771 - if (!slot_count)
49772 - break;
49773 }
49774 up_read(&info->groups_sem);
49775 }
49776 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49777 index f0857e0..e7023c5 100644
49778 --- a/fs/btrfs/super.c
49779 +++ b/fs/btrfs/super.c
49780 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49781 function, line, errstr);
49782 return;
49783 }
49784 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49785 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49786 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49787 }
49788 /*
49789 diff --git a/fs/buffer.c b/fs/buffer.c
49790 index d2a4d1b..df798ca 100644
49791 --- a/fs/buffer.c
49792 +++ b/fs/buffer.c
49793 @@ -3367,7 +3367,7 @@ void __init buffer_init(void)
49794 bh_cachep = kmem_cache_create("buffer_head",
49795 sizeof(struct buffer_head), 0,
49796 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
49797 - SLAB_MEM_SPREAD),
49798 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
49799 NULL);
49800
49801 /*
49802 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49803 index 622f469..e8d2d55 100644
49804 --- a/fs/cachefiles/bind.c
49805 +++ b/fs/cachefiles/bind.c
49806 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49807 args);
49808
49809 /* start by checking things over */
49810 - ASSERT(cache->fstop_percent >= 0 &&
49811 - cache->fstop_percent < cache->fcull_percent &&
49812 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49813 cache->fcull_percent < cache->frun_percent &&
49814 cache->frun_percent < 100);
49815
49816 - ASSERT(cache->bstop_percent >= 0 &&
49817 - cache->bstop_percent < cache->bcull_percent &&
49818 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49819 cache->bcull_percent < cache->brun_percent &&
49820 cache->brun_percent < 100);
49821
49822 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49823 index 0a1467b..6a53245 100644
49824 --- a/fs/cachefiles/daemon.c
49825 +++ b/fs/cachefiles/daemon.c
49826 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49827 if (n > buflen)
49828 return -EMSGSIZE;
49829
49830 - if (copy_to_user(_buffer, buffer, n) != 0)
49831 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49832 return -EFAULT;
49833
49834 return n;
49835 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49836 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49837 return -EIO;
49838
49839 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49840 + if (datalen > PAGE_SIZE - 1)
49841 return -EOPNOTSUPP;
49842
49843 /* drag the command string into the kernel so we can parse it */
49844 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49845 if (args[0] != '%' || args[1] != '\0')
49846 return -EINVAL;
49847
49848 - if (fstop < 0 || fstop >= cache->fcull_percent)
49849 + if (fstop >= cache->fcull_percent)
49850 return cachefiles_daemon_range_error(cache, args);
49851
49852 cache->fstop_percent = fstop;
49853 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49854 if (args[0] != '%' || args[1] != '\0')
49855 return -EINVAL;
49856
49857 - if (bstop < 0 || bstop >= cache->bcull_percent)
49858 + if (bstop >= cache->bcull_percent)
49859 return cachefiles_daemon_range_error(cache, args);
49860
49861 cache->bstop_percent = bstop;
49862 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49863 index 4938251..7e01445 100644
49864 --- a/fs/cachefiles/internal.h
49865 +++ b/fs/cachefiles/internal.h
49866 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49867 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49868 struct rb_root active_nodes; /* active nodes (can't be culled) */
49869 rwlock_t active_lock; /* lock for active_nodes */
49870 - atomic_t gravecounter; /* graveyard uniquifier */
49871 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49872 unsigned frun_percent; /* when to stop culling (% files) */
49873 unsigned fcull_percent; /* when to start culling (% files) */
49874 unsigned fstop_percent; /* when to stop allocating (% files) */
49875 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49876 * proc.c
49877 */
49878 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49879 -extern atomic_t cachefiles_lookup_histogram[HZ];
49880 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49881 -extern atomic_t cachefiles_create_histogram[HZ];
49882 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49883 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49884 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49885
49886 extern int __init cachefiles_proc_init(void);
49887 extern void cachefiles_proc_cleanup(void);
49888 static inline
49889 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49890 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49891 {
49892 unsigned long jif = jiffies - start_jif;
49893 if (jif >= HZ)
49894 jif = HZ - 1;
49895 - atomic_inc(&histogram[jif]);
49896 + atomic_inc_unchecked(&histogram[jif]);
49897 }
49898
49899 #else
49900 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49901 index 8c01c5fc..15f982e 100644
49902 --- a/fs/cachefiles/namei.c
49903 +++ b/fs/cachefiles/namei.c
49904 @@ -317,7 +317,7 @@ try_again:
49905 /* first step is to make up a grave dentry in the graveyard */
49906 sprintf(nbuffer, "%08x%08x",
49907 (uint32_t) get_seconds(),
49908 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49909 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49910
49911 /* do the multiway lock magic */
49912 trap = lock_rename(cache->graveyard, dir);
49913 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49914 index eccd339..4c1d995 100644
49915 --- a/fs/cachefiles/proc.c
49916 +++ b/fs/cachefiles/proc.c
49917 @@ -14,9 +14,9 @@
49918 #include <linux/seq_file.h>
49919 #include "internal.h"
49920
49921 -atomic_t cachefiles_lookup_histogram[HZ];
49922 -atomic_t cachefiles_mkdir_histogram[HZ];
49923 -atomic_t cachefiles_create_histogram[HZ];
49924 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49925 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49926 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49927
49928 /*
49929 * display the latency histogram
49930 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49931 return 0;
49932 default:
49933 index = (unsigned long) v - 3;
49934 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49935 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49936 - z = atomic_read(&cachefiles_create_histogram[index]);
49937 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49938 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49939 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49940 if (x == 0 && y == 0 && z == 0)
49941 return 0;
49942
49943 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49944 index 317f9ee..3d24511 100644
49945 --- a/fs/cachefiles/rdwr.c
49946 +++ b/fs/cachefiles/rdwr.c
49947 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49948 old_fs = get_fs();
49949 set_fs(KERNEL_DS);
49950 ret = file->f_op->write(
49951 - file, (const void __user *) data, len, &pos);
49952 + file, (const void __force_user *) data, len, &pos);
49953 set_fs(old_fs);
49954 kunmap(page);
49955 file_end_write(file);
49956 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49957 index f02d82b..2632cf86 100644
49958 --- a/fs/ceph/dir.c
49959 +++ b/fs/ceph/dir.c
49960 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49961 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49962 struct ceph_mds_client *mdsc = fsc->mdsc;
49963 unsigned frag = fpos_frag(filp->f_pos);
49964 - int off = fpos_off(filp->f_pos);
49965 + unsigned int off = fpos_off(filp->f_pos);
49966 int err;
49967 u32 ftype;
49968 struct ceph_mds_reply_info_parsed *rinfo;
49969 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49970 index d597483..747901b 100644
49971 --- a/fs/cifs/cifs_debug.c
49972 +++ b/fs/cifs/cifs_debug.c
49973 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49974
49975 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49976 #ifdef CONFIG_CIFS_STATS2
49977 - atomic_set(&totBufAllocCount, 0);
49978 - atomic_set(&totSmBufAllocCount, 0);
49979 + atomic_set_unchecked(&totBufAllocCount, 0);
49980 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49981 #endif /* CONFIG_CIFS_STATS2 */
49982 spin_lock(&cifs_tcp_ses_lock);
49983 list_for_each(tmp1, &cifs_tcp_ses_list) {
49984 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49985 tcon = list_entry(tmp3,
49986 struct cifs_tcon,
49987 tcon_list);
49988 - atomic_set(&tcon->num_smbs_sent, 0);
49989 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49990 if (server->ops->clear_stats)
49991 server->ops->clear_stats(tcon);
49992 }
49993 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49994 smBufAllocCount.counter, cifs_min_small);
49995 #ifdef CONFIG_CIFS_STATS2
49996 seq_printf(m, "Total Large %d Small %d Allocations\n",
49997 - atomic_read(&totBufAllocCount),
49998 - atomic_read(&totSmBufAllocCount));
49999 + atomic_read_unchecked(&totBufAllocCount),
50000 + atomic_read_unchecked(&totSmBufAllocCount));
50001 #endif /* CONFIG_CIFS_STATS2 */
50002
50003 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
50004 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
50005 if (tcon->need_reconnect)
50006 seq_puts(m, "\tDISCONNECTED ");
50007 seq_printf(m, "\nSMBs: %d",
50008 - atomic_read(&tcon->num_smbs_sent));
50009 + atomic_read_unchecked(&tcon->num_smbs_sent));
50010 if (server->ops->print_stats)
50011 server->ops->print_stats(m, tcon);
50012 }
50013 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
50014 index 3752b9f..8db5569 100644
50015 --- a/fs/cifs/cifsfs.c
50016 +++ b/fs/cifs/cifsfs.c
50017 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
50018 */
50019 cifs_req_cachep = kmem_cache_create("cifs_request",
50020 CIFSMaxBufSize + max_hdr_size, 0,
50021 - SLAB_HWCACHE_ALIGN, NULL);
50022 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
50023 if (cifs_req_cachep == NULL)
50024 return -ENOMEM;
50025
50026 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
50027 efficient to alloc 1 per page off the slab compared to 17K (5page)
50028 alloc of large cifs buffers even when page debugging is on */
50029 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
50030 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
50031 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
50032 NULL);
50033 if (cifs_sm_req_cachep == NULL) {
50034 mempool_destroy(cifs_req_poolp);
50035 @@ -1147,8 +1147,8 @@ init_cifs(void)
50036 atomic_set(&bufAllocCount, 0);
50037 atomic_set(&smBufAllocCount, 0);
50038 #ifdef CONFIG_CIFS_STATS2
50039 - atomic_set(&totBufAllocCount, 0);
50040 - atomic_set(&totSmBufAllocCount, 0);
50041 + atomic_set_unchecked(&totBufAllocCount, 0);
50042 + atomic_set_unchecked(&totSmBufAllocCount, 0);
50043 #endif /* CONFIG_CIFS_STATS2 */
50044
50045 atomic_set(&midCount, 0);
50046 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
50047 index 4f07f6f..55de8ce 100644
50048 --- a/fs/cifs/cifsglob.h
50049 +++ b/fs/cifs/cifsglob.h
50050 @@ -751,35 +751,35 @@ struct cifs_tcon {
50051 __u16 Flags; /* optional support bits */
50052 enum statusEnum tidStatus;
50053 #ifdef CONFIG_CIFS_STATS
50054 - atomic_t num_smbs_sent;
50055 + atomic_unchecked_t num_smbs_sent;
50056 union {
50057 struct {
50058 - atomic_t num_writes;
50059 - atomic_t num_reads;
50060 - atomic_t num_flushes;
50061 - atomic_t num_oplock_brks;
50062 - atomic_t num_opens;
50063 - atomic_t num_closes;
50064 - atomic_t num_deletes;
50065 - atomic_t num_mkdirs;
50066 - atomic_t num_posixopens;
50067 - atomic_t num_posixmkdirs;
50068 - atomic_t num_rmdirs;
50069 - atomic_t num_renames;
50070 - atomic_t num_t2renames;
50071 - atomic_t num_ffirst;
50072 - atomic_t num_fnext;
50073 - atomic_t num_fclose;
50074 - atomic_t num_hardlinks;
50075 - atomic_t num_symlinks;
50076 - atomic_t num_locks;
50077 - atomic_t num_acl_get;
50078 - atomic_t num_acl_set;
50079 + atomic_unchecked_t num_writes;
50080 + atomic_unchecked_t num_reads;
50081 + atomic_unchecked_t num_flushes;
50082 + atomic_unchecked_t num_oplock_brks;
50083 + atomic_unchecked_t num_opens;
50084 + atomic_unchecked_t num_closes;
50085 + atomic_unchecked_t num_deletes;
50086 + atomic_unchecked_t num_mkdirs;
50087 + atomic_unchecked_t num_posixopens;
50088 + atomic_unchecked_t num_posixmkdirs;
50089 + atomic_unchecked_t num_rmdirs;
50090 + atomic_unchecked_t num_renames;
50091 + atomic_unchecked_t num_t2renames;
50092 + atomic_unchecked_t num_ffirst;
50093 + atomic_unchecked_t num_fnext;
50094 + atomic_unchecked_t num_fclose;
50095 + atomic_unchecked_t num_hardlinks;
50096 + atomic_unchecked_t num_symlinks;
50097 + atomic_unchecked_t num_locks;
50098 + atomic_unchecked_t num_acl_get;
50099 + atomic_unchecked_t num_acl_set;
50100 } cifs_stats;
50101 #ifdef CONFIG_CIFS_SMB2
50102 struct {
50103 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50104 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50105 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50106 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50107 } smb2_stats;
50108 #endif /* CONFIG_CIFS_SMB2 */
50109 } stats;
50110 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
50111 }
50112
50113 #ifdef CONFIG_CIFS_STATS
50114 -#define cifs_stats_inc atomic_inc
50115 +#define cifs_stats_inc atomic_inc_unchecked
50116
50117 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
50118 unsigned int bytes)
50119 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
50120 /* Various Debug counters */
50121 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
50122 #ifdef CONFIG_CIFS_STATS2
50123 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
50124 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
50125 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
50126 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
50127 #endif
50128 GLOBAL_EXTERN atomic_t smBufAllocCount;
50129 GLOBAL_EXTERN atomic_t midCount;
50130 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
50131 index b83c3f5..6437caa 100644
50132 --- a/fs/cifs/link.c
50133 +++ b/fs/cifs/link.c
50134 @@ -616,7 +616,7 @@ symlink_exit:
50135
50136 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
50137 {
50138 - char *p = nd_get_link(nd);
50139 + const char *p = nd_get_link(nd);
50140 if (!IS_ERR(p))
50141 kfree(p);
50142 }
50143 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
50144 index 1bec014..f329411 100644
50145 --- a/fs/cifs/misc.c
50146 +++ b/fs/cifs/misc.c
50147 @@ -169,7 +169,7 @@ cifs_buf_get(void)
50148 memset(ret_buf, 0, buf_size + 3);
50149 atomic_inc(&bufAllocCount);
50150 #ifdef CONFIG_CIFS_STATS2
50151 - atomic_inc(&totBufAllocCount);
50152 + atomic_inc_unchecked(&totBufAllocCount);
50153 #endif /* CONFIG_CIFS_STATS2 */
50154 }
50155
50156 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50157 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50158 atomic_inc(&smBufAllocCount);
50159 #ifdef CONFIG_CIFS_STATS2
50160 - atomic_inc(&totSmBufAllocCount);
50161 + atomic_inc_unchecked(&totSmBufAllocCount);
50162 #endif /* CONFIG_CIFS_STATS2 */
50163
50164 }
50165 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50166 index 3efdb9d..e845a5e 100644
50167 --- a/fs/cifs/smb1ops.c
50168 +++ b/fs/cifs/smb1ops.c
50169 @@ -591,27 +591,27 @@ static void
50170 cifs_clear_stats(struct cifs_tcon *tcon)
50171 {
50172 #ifdef CONFIG_CIFS_STATS
50173 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50174 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50175 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50176 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50177 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50178 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50179 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50180 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50181 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50182 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50183 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50184 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50185 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50186 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50187 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50188 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50189 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50190 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50191 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50192 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50193 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50194 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50195 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50196 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50197 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50198 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50199 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50200 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50201 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50202 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50203 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50204 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50205 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50206 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50207 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50208 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50209 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50210 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50211 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50212 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50213 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50214 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50215 #endif
50216 }
50217
50218 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50219 {
50220 #ifdef CONFIG_CIFS_STATS
50221 seq_printf(m, " Oplocks breaks: %d",
50222 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50223 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50224 seq_printf(m, "\nReads: %d Bytes: %llu",
50225 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50226 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50227 (long long)(tcon->bytes_read));
50228 seq_printf(m, "\nWrites: %d Bytes: %llu",
50229 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50230 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50231 (long long)(tcon->bytes_written));
50232 seq_printf(m, "\nFlushes: %d",
50233 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50234 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50235 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50236 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50237 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50238 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50239 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50240 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50241 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50242 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50243 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50244 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50245 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50246 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50247 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50248 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50249 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50250 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50251 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50252 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50253 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50254 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50255 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50256 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50257 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50258 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50259 seq_printf(m, "\nRenames: %d T2 Renames %d",
50260 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50261 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50262 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50263 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50264 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50265 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50266 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50267 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50268 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50269 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50270 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50271 #endif
50272 }
50273
50274 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50275 index f2e76f3..c44fac7 100644
50276 --- a/fs/cifs/smb2ops.c
50277 +++ b/fs/cifs/smb2ops.c
50278 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50279 #ifdef CONFIG_CIFS_STATS
50280 int i;
50281 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50282 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50283 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50284 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50285 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50286 }
50287 #endif
50288 }
50289 @@ -284,66 +284,66 @@ static void
50290 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50291 {
50292 #ifdef CONFIG_CIFS_STATS
50293 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50294 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50295 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50296 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50297 seq_printf(m, "\nNegotiates: %d sent %d failed",
50298 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50299 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50300 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50301 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50302 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50303 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50304 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50305 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50306 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50307 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50308 seq_printf(m, "\nLogoffs: %d sent %d failed",
50309 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50310 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50311 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50312 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50313 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50314 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50315 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50316 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50317 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50318 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50319 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50320 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50321 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50322 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50323 seq_printf(m, "\nCreates: %d sent %d failed",
50324 - atomic_read(&sent[SMB2_CREATE_HE]),
50325 - atomic_read(&failed[SMB2_CREATE_HE]));
50326 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50327 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50328 seq_printf(m, "\nCloses: %d sent %d failed",
50329 - atomic_read(&sent[SMB2_CLOSE_HE]),
50330 - atomic_read(&failed[SMB2_CLOSE_HE]));
50331 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50332 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50333 seq_printf(m, "\nFlushes: %d sent %d failed",
50334 - atomic_read(&sent[SMB2_FLUSH_HE]),
50335 - atomic_read(&failed[SMB2_FLUSH_HE]));
50336 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50337 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50338 seq_printf(m, "\nReads: %d sent %d failed",
50339 - atomic_read(&sent[SMB2_READ_HE]),
50340 - atomic_read(&failed[SMB2_READ_HE]));
50341 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50342 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50343 seq_printf(m, "\nWrites: %d sent %d failed",
50344 - atomic_read(&sent[SMB2_WRITE_HE]),
50345 - atomic_read(&failed[SMB2_WRITE_HE]));
50346 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50347 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50348 seq_printf(m, "\nLocks: %d sent %d failed",
50349 - atomic_read(&sent[SMB2_LOCK_HE]),
50350 - atomic_read(&failed[SMB2_LOCK_HE]));
50351 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50352 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50353 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50354 - atomic_read(&sent[SMB2_IOCTL_HE]),
50355 - atomic_read(&failed[SMB2_IOCTL_HE]));
50356 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50357 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50358 seq_printf(m, "\nCancels: %d sent %d failed",
50359 - atomic_read(&sent[SMB2_CANCEL_HE]),
50360 - atomic_read(&failed[SMB2_CANCEL_HE]));
50361 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50362 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50363 seq_printf(m, "\nEchos: %d sent %d failed",
50364 - atomic_read(&sent[SMB2_ECHO_HE]),
50365 - atomic_read(&failed[SMB2_ECHO_HE]));
50366 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50367 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50368 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50369 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50370 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50371 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50372 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50373 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50374 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50375 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50376 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50377 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50378 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50379 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50380 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50381 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50382 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50383 seq_printf(m, "\nSetInfos: %d sent %d failed",
50384 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50385 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50386 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50387 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50388 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50389 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50390 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50391 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50392 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50393 #endif
50394 }
50395
50396 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50397 index 2b95ce2..d079d75 100644
50398 --- a/fs/cifs/smb2pdu.c
50399 +++ b/fs/cifs/smb2pdu.c
50400 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50401 default:
50402 cifs_dbg(VFS, "info level %u isn't supported\n",
50403 srch_inf->info_level);
50404 - rc = -EINVAL;
50405 - goto qdir_exit;
50406 + return -EINVAL;
50407 }
50408
50409 req->FileIndex = cpu_to_le32(index);
50410 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50411 index 1da168c..8bc7ff6 100644
50412 --- a/fs/coda/cache.c
50413 +++ b/fs/coda/cache.c
50414 @@ -24,7 +24,7 @@
50415 #include "coda_linux.h"
50416 #include "coda_cache.h"
50417
50418 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50419 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50420
50421 /* replace or extend an acl cache hit */
50422 void coda_cache_enter(struct inode *inode, int mask)
50423 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50424 struct coda_inode_info *cii = ITOC(inode);
50425
50426 spin_lock(&cii->c_lock);
50427 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50428 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50429 if (!uid_eq(cii->c_uid, current_fsuid())) {
50430 cii->c_uid = current_fsuid();
50431 cii->c_cached_perm = mask;
50432 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50433 {
50434 struct coda_inode_info *cii = ITOC(inode);
50435 spin_lock(&cii->c_lock);
50436 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50437 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50438 spin_unlock(&cii->c_lock);
50439 }
50440
50441 /* remove all acl caches */
50442 void coda_cache_clear_all(struct super_block *sb)
50443 {
50444 - atomic_inc(&permission_epoch);
50445 + atomic_inc_unchecked(&permission_epoch);
50446 }
50447
50448
50449 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50450 spin_lock(&cii->c_lock);
50451 hit = (mask & cii->c_cached_perm) == mask &&
50452 uid_eq(cii->c_uid, current_fsuid()) &&
50453 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50454 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50455 spin_unlock(&cii->c_lock);
50456
50457 return hit;
50458 diff --git a/fs/compat.c b/fs/compat.c
50459 index fc3b55d..7b568ae 100644
50460 --- a/fs/compat.c
50461 +++ b/fs/compat.c
50462 @@ -54,7 +54,7 @@
50463 #include <asm/ioctls.h>
50464 #include "internal.h"
50465
50466 -int compat_log = 1;
50467 +int compat_log = 0;
50468
50469 int compat_printk(const char *fmt, ...)
50470 {
50471 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50472
50473 set_fs(KERNEL_DS);
50474 /* The __user pointer cast is valid because of the set_fs() */
50475 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50476 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50477 set_fs(oldfs);
50478 /* truncating is ok because it's a user address */
50479 if (!ret)
50480 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50481 goto out;
50482
50483 ret = -EINVAL;
50484 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50485 + if (nr_segs > UIO_MAXIOV)
50486 goto out;
50487 if (nr_segs > fast_segs) {
50488 ret = -ENOMEM;
50489 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
50490
50491 struct compat_readdir_callback {
50492 struct compat_old_linux_dirent __user *dirent;
50493 + struct file * file;
50494 int result;
50495 };
50496
50497 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50498 buf->result = -EOVERFLOW;
50499 return -EOVERFLOW;
50500 }
50501 +
50502 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50503 + return 0;
50504 +
50505 buf->result++;
50506 dirent = buf->dirent;
50507 if (!access_ok(VERIFY_WRITE, dirent,
50508 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50509
50510 buf.result = 0;
50511 buf.dirent = dirent;
50512 + buf.file = f.file;
50513
50514 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50515 if (buf.result)
50516 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
50517 struct compat_getdents_callback {
50518 struct compat_linux_dirent __user *current_dir;
50519 struct compat_linux_dirent __user *previous;
50520 + struct file * file;
50521 int count;
50522 int error;
50523 };
50524 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50525 buf->error = -EOVERFLOW;
50526 return -EOVERFLOW;
50527 }
50528 +
50529 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50530 + return 0;
50531 +
50532 dirent = buf->previous;
50533 if (dirent) {
50534 if (__put_user(offset, &dirent->d_off))
50535 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50536 buf.previous = NULL;
50537 buf.count = count;
50538 buf.error = 0;
50539 + buf.file = f.file;
50540
50541 error = vfs_readdir(f.file, compat_filldir, &buf);
50542 if (error >= 0)
50543 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50544 struct compat_getdents_callback64 {
50545 struct linux_dirent64 __user *current_dir;
50546 struct linux_dirent64 __user *previous;
50547 + struct file * file;
50548 int count;
50549 int error;
50550 };
50551 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50552 buf->error = -EINVAL; /* only used if we fail.. */
50553 if (reclen > buf->count)
50554 return -EINVAL;
50555 +
50556 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50557 + return 0;
50558 +
50559 dirent = buf->previous;
50560
50561 if (dirent) {
50562 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50563 buf.previous = NULL;
50564 buf.count = count;
50565 buf.error = 0;
50566 + buf.file = f.file;
50567
50568 error = vfs_readdir(f.file, compat_filldir64, &buf);
50569 if (error >= 0)
50570 error = buf.error;
50571 lastdirent = buf.previous;
50572 if (lastdirent) {
50573 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50574 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50575 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50576 error = -EFAULT;
50577 else
50578 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50579 index a81147e..20bf2b5 100644
50580 --- a/fs/compat_binfmt_elf.c
50581 +++ b/fs/compat_binfmt_elf.c
50582 @@ -30,11 +30,13 @@
50583 #undef elf_phdr
50584 #undef elf_shdr
50585 #undef elf_note
50586 +#undef elf_dyn
50587 #undef elf_addr_t
50588 #define elfhdr elf32_hdr
50589 #define elf_phdr elf32_phdr
50590 #define elf_shdr elf32_shdr
50591 #define elf_note elf32_note
50592 +#define elf_dyn Elf32_Dyn
50593 #define elf_addr_t Elf32_Addr
50594
50595 /*
50596 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50597 index 996cdc5..15e2f33 100644
50598 --- a/fs/compat_ioctl.c
50599 +++ b/fs/compat_ioctl.c
50600 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50601 return -EFAULT;
50602 if (__get_user(udata, &ss32->iomem_base))
50603 return -EFAULT;
50604 - ss.iomem_base = compat_ptr(udata);
50605 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50606 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50607 __get_user(ss.port_high, &ss32->port_high))
50608 return -EFAULT;
50609 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
50610 for (i = 0; i < nmsgs; i++) {
50611 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
50612 return -EFAULT;
50613 - if (get_user(datap, &umsgs[i].buf) ||
50614 - put_user(compat_ptr(datap), &tmsgs[i].buf))
50615 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
50616 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
50617 return -EFAULT;
50618 }
50619 return sys_ioctl(fd, cmd, (unsigned long)tdata);
50620 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
50621 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50622 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50623 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50624 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50625 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50626 return -EFAULT;
50627
50628 return ioctl_preallocate(file, p);
50629 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50630 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50631 {
50632 unsigned int a, b;
50633 - a = *(unsigned int *)p;
50634 - b = *(unsigned int *)q;
50635 + a = *(const unsigned int *)p;
50636 + b = *(const unsigned int *)q;
50637 if (a > b)
50638 return 1;
50639 if (a < b)
50640 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50641 index 7aabc6a..34c1197 100644
50642 --- a/fs/configfs/dir.c
50643 +++ b/fs/configfs/dir.c
50644 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50645 }
50646 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50647 struct configfs_dirent *next;
50648 - const char * name;
50649 + const unsigned char * name;
50650 + char d_name[sizeof(next->s_dentry->d_iname)];
50651 int len;
50652 struct inode *inode = NULL;
50653
50654 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50655 continue;
50656
50657 name = configfs_get_name(next);
50658 - len = strlen(name);
50659 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50660 + len = next->s_dentry->d_name.len;
50661 + memcpy(d_name, name, len);
50662 + name = d_name;
50663 + } else
50664 + len = strlen(name);
50665
50666 /*
50667 * We'll have a dentry and an inode for
50668 diff --git a/fs/coredump.c b/fs/coredump.c
50669 index dafafba..10b3b27 100644
50670 --- a/fs/coredump.c
50671 +++ b/fs/coredump.c
50672 @@ -52,7 +52,7 @@ struct core_name {
50673 char *corename;
50674 int used, size;
50675 };
50676 -static atomic_t call_count = ATOMIC_INIT(1);
50677 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50678
50679 /* The maximal length of core_pattern is also specified in sysctl.c */
50680
50681 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50682 {
50683 char *old_corename = cn->corename;
50684
50685 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50686 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50687 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50688
50689 if (!cn->corename) {
50690 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50691 int pid_in_pattern = 0;
50692 int err = 0;
50693
50694 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50695 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50696 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50697 cn->used = 0;
50698
50699 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
50700 struct pipe_inode_info *pipe = file->private_data;
50701
50702 pipe_lock(pipe);
50703 - pipe->readers++;
50704 - pipe->writers--;
50705 + atomic_inc(&pipe->readers);
50706 + atomic_dec(&pipe->writers);
50707 wake_up_interruptible_sync(&pipe->wait);
50708 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50709 pipe_unlock(pipe);
50710 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
50711 * We actually want wait_event_freezable() but then we need
50712 * to clear TIF_SIGPENDING and improve dump_interrupted().
50713 */
50714 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
50715 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
50716
50717 pipe_lock(pipe);
50718 - pipe->readers--;
50719 - pipe->writers++;
50720 + atomic_dec(&pipe->readers);
50721 + atomic_inc(&pipe->writers);
50722 pipe_unlock(pipe);
50723 }
50724
50725 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
50726 struct files_struct *displaced;
50727 bool need_nonrelative = false;
50728 bool core_dumped = false;
50729 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50730 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50731 + long signr = siginfo->si_signo;
50732 struct coredump_params cprm = {
50733 .siginfo = siginfo,
50734 .regs = signal_pt_regs(),
50735 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
50736 .mm_flags = mm->flags,
50737 };
50738
50739 - audit_core_dumps(siginfo->si_signo);
50740 + audit_core_dumps(signr);
50741 +
50742 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50743 + gr_handle_brute_attach(cprm.mm_flags);
50744
50745 binfmt = mm->binfmt;
50746 if (!binfmt || !binfmt->core_dump)
50747 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
50748 need_nonrelative = true;
50749 }
50750
50751 - retval = coredump_wait(siginfo->si_signo, &core_state);
50752 + retval = coredump_wait(signr, &core_state);
50753 if (retval < 0)
50754 goto fail_creds;
50755
50756 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
50757 }
50758 cprm.limit = RLIM_INFINITY;
50759
50760 - dump_count = atomic_inc_return(&core_dump_count);
50761 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50762 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50763 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50764 task_tgid_vnr(current), current->comm);
50765 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
50766 } else {
50767 struct inode *inode;
50768
50769 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50770 +
50771 if (cprm.limit < binfmt->min_coredump)
50772 goto fail_unlock;
50773
50774 @@ -666,7 +672,7 @@ close_fail:
50775 filp_close(cprm.file, NULL);
50776 fail_dropcount:
50777 if (ispipe)
50778 - atomic_dec(&core_dump_count);
50779 + atomic_dec_unchecked(&core_dump_count);
50780 fail_unlock:
50781 kfree(cn.corename);
50782 fail_corename:
50783 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
50784 {
50785 return !dump_interrupted() &&
50786 access_ok(VERIFY_READ, addr, nr) &&
50787 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50788 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50789 }
50790 EXPORT_SYMBOL(dump_write);
50791
50792 diff --git a/fs/dcache.c b/fs/dcache.c
50793 index f09b908..04b9690 100644
50794 --- a/fs/dcache.c
50795 +++ b/fs/dcache.c
50796 @@ -3086,7 +3086,8 @@ void __init vfs_caches_init(unsigned long mempages)
50797 mempages -= reserve;
50798
50799 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50800 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50801 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
50802 + SLAB_NO_SANITIZE, NULL);
50803
50804 dcache_init();
50805 inode_init();
50806 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50807 index 4888cb3..e0f7cf8 100644
50808 --- a/fs/debugfs/inode.c
50809 +++ b/fs/debugfs/inode.c
50810 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50811 */
50812 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50813 {
50814 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50815 + return __create_file(name, S_IFDIR | S_IRWXU,
50816 +#else
50817 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50818 +#endif
50819 parent, NULL, NULL);
50820 }
50821 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50822 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50823 index 5eab400..810a3f5 100644
50824 --- a/fs/ecryptfs/inode.c
50825 +++ b/fs/ecryptfs/inode.c
50826 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50827 old_fs = get_fs();
50828 set_fs(get_ds());
50829 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50830 - (char __user *)lower_buf,
50831 + (char __force_user *)lower_buf,
50832 PATH_MAX);
50833 set_fs(old_fs);
50834 if (rc < 0)
50835 @@ -706,7 +706,7 @@ out:
50836 static void
50837 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50838 {
50839 - char *buf = nd_get_link(nd);
50840 + const char *buf = nd_get_link(nd);
50841 if (!IS_ERR(buf)) {
50842 /* Free the char* */
50843 kfree(buf);
50844 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50845 index e4141f2..d8263e8 100644
50846 --- a/fs/ecryptfs/miscdev.c
50847 +++ b/fs/ecryptfs/miscdev.c
50848 @@ -304,7 +304,7 @@ check_list:
50849 goto out_unlock_msg_ctx;
50850 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50851 if (msg_ctx->msg) {
50852 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50853 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50854 goto out_unlock_msg_ctx;
50855 i += packet_length_size;
50856 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50857 diff --git a/fs/exec.c b/fs/exec.c
50858 index ffd7a81..d95acf6 100644
50859 --- a/fs/exec.c
50860 +++ b/fs/exec.c
50861 @@ -55,8 +55,20 @@
50862 #include <linux/pipe_fs_i.h>
50863 #include <linux/oom.h>
50864 #include <linux/compat.h>
50865 +#include <linux/random.h>
50866 +#include <linux/seq_file.h>
50867 +#include <linux/coredump.h>
50868 +#include <linux/mman.h>
50869 +
50870 +#ifdef CONFIG_PAX_REFCOUNT
50871 +#include <linux/kallsyms.h>
50872 +#include <linux/kdebug.h>
50873 +#endif
50874 +
50875 +#include <trace/events/fs.h>
50876
50877 #include <asm/uaccess.h>
50878 +#include <asm/sections.h>
50879 #include <asm/mmu_context.h>
50880 #include <asm/tlb.h>
50881
50882 @@ -66,17 +78,32 @@
50883
50884 #include <trace/events/sched.h>
50885
50886 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50887 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50888 +{
50889 + 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");
50890 +}
50891 +#endif
50892 +
50893 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50894 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50895 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50896 +#endif
50897 +
50898 int suid_dumpable = 0;
50899
50900 static LIST_HEAD(formats);
50901 static DEFINE_RWLOCK(binfmt_lock);
50902
50903 +extern int gr_process_kernel_exec_ban(void);
50904 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
50905 +
50906 void __register_binfmt(struct linux_binfmt * fmt, int insert)
50907 {
50908 BUG_ON(!fmt);
50909 write_lock(&binfmt_lock);
50910 - insert ? list_add(&fmt->lh, &formats) :
50911 - list_add_tail(&fmt->lh, &formats);
50912 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50913 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50914 write_unlock(&binfmt_lock);
50915 }
50916
50917 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
50918 void unregister_binfmt(struct linux_binfmt * fmt)
50919 {
50920 write_lock(&binfmt_lock);
50921 - list_del(&fmt->lh);
50922 + pax_list_del((struct list_head *)&fmt->lh);
50923 write_unlock(&binfmt_lock);
50924 }
50925
50926 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50927 int write)
50928 {
50929 struct page *page;
50930 - int ret;
50931
50932 -#ifdef CONFIG_STACK_GROWSUP
50933 - if (write) {
50934 - ret = expand_downwards(bprm->vma, pos);
50935 - if (ret < 0)
50936 - return NULL;
50937 - }
50938 -#endif
50939 - ret = get_user_pages(current, bprm->mm, pos,
50940 - 1, write, 1, &page, NULL);
50941 - if (ret <= 0)
50942 + if (0 > expand_downwards(bprm->vma, pos))
50943 + return NULL;
50944 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50945 return NULL;
50946
50947 if (write) {
50948 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50949 if (size <= ARG_MAX)
50950 return page;
50951
50952 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50953 + // only allow 512KB for argv+env on suid/sgid binaries
50954 + // to prevent easy ASLR exhaustion
50955 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50956 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50957 + (size > (512 * 1024))) {
50958 + put_page(page);
50959 + return NULL;
50960 + }
50961 +#endif
50962 +
50963 /*
50964 * Limit to 1/4-th the stack size for the argv+env strings.
50965 * This ensures that:
50966 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50967 vma->vm_end = STACK_TOP_MAX;
50968 vma->vm_start = vma->vm_end - PAGE_SIZE;
50969 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50970 +
50971 +#ifdef CONFIG_PAX_SEGMEXEC
50972 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50973 +#endif
50974 +
50975 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50976 INIT_LIST_HEAD(&vma->anon_vma_chain);
50977
50978 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50979 mm->stack_vm = mm->total_vm = 1;
50980 up_write(&mm->mmap_sem);
50981 bprm->p = vma->vm_end - sizeof(void *);
50982 +
50983 +#ifdef CONFIG_PAX_RANDUSTACK
50984 + if (randomize_va_space)
50985 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
50986 +#endif
50987 +
50988 return 0;
50989 err:
50990 up_write(&mm->mmap_sem);
50991 @@ -396,7 +437,7 @@ struct user_arg_ptr {
50992 } ptr;
50993 };
50994
50995 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50996 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50997 {
50998 const char __user *native;
50999
51000 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
51001 compat_uptr_t compat;
51002
51003 if (get_user(compat, argv.ptr.compat + nr))
51004 - return ERR_PTR(-EFAULT);
51005 + return (const char __force_user *)ERR_PTR(-EFAULT);
51006
51007 return compat_ptr(compat);
51008 }
51009 #endif
51010
51011 if (get_user(native, argv.ptr.native + nr))
51012 - return ERR_PTR(-EFAULT);
51013 + return (const char __force_user *)ERR_PTR(-EFAULT);
51014
51015 return native;
51016 }
51017 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
51018 if (!p)
51019 break;
51020
51021 - if (IS_ERR(p))
51022 + if (IS_ERR((const char __force_kernel *)p))
51023 return -EFAULT;
51024
51025 if (i >= max)
51026 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
51027
51028 ret = -EFAULT;
51029 str = get_user_arg_ptr(argv, argc);
51030 - if (IS_ERR(str))
51031 + if (IS_ERR((const char __force_kernel *)str))
51032 goto out;
51033
51034 len = strnlen_user(str, MAX_ARG_STRLEN);
51035 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
51036 int r;
51037 mm_segment_t oldfs = get_fs();
51038 struct user_arg_ptr argv = {
51039 - .ptr.native = (const char __user *const __user *)__argv,
51040 + .ptr.native = (const char __force_user * const __force_user *)__argv,
51041 };
51042
51043 set_fs(KERNEL_DS);
51044 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51045 unsigned long new_end = old_end - shift;
51046 struct mmu_gather tlb;
51047
51048 - BUG_ON(new_start > new_end);
51049 + if (new_start >= new_end || new_start < mmap_min_addr)
51050 + return -ENOMEM;
51051
51052 /*
51053 * ensure there are no vmas between where we want to go
51054 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51055 if (vma != find_vma(mm, new_start))
51056 return -EFAULT;
51057
51058 +#ifdef CONFIG_PAX_SEGMEXEC
51059 + BUG_ON(pax_find_mirror_vma(vma));
51060 +#endif
51061 +
51062 /*
51063 * cover the whole range: [new_start, old_end)
51064 */
51065 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51066 stack_top = arch_align_stack(stack_top);
51067 stack_top = PAGE_ALIGN(stack_top);
51068
51069 - if (unlikely(stack_top < mmap_min_addr) ||
51070 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
51071 - return -ENOMEM;
51072 -
51073 stack_shift = vma->vm_end - stack_top;
51074
51075 bprm->p -= stack_shift;
51076 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
51077 bprm->exec -= stack_shift;
51078
51079 down_write(&mm->mmap_sem);
51080 +
51081 + /* Move stack pages down in memory. */
51082 + if (stack_shift) {
51083 + ret = shift_arg_pages(vma, stack_shift);
51084 + if (ret)
51085 + goto out_unlock;
51086 + }
51087 +
51088 vm_flags = VM_STACK_FLAGS;
51089
51090 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51091 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51092 + vm_flags &= ~VM_EXEC;
51093 +
51094 +#ifdef CONFIG_PAX_MPROTECT
51095 + if (mm->pax_flags & MF_PAX_MPROTECT)
51096 + vm_flags &= ~VM_MAYEXEC;
51097 +#endif
51098 +
51099 + }
51100 +#endif
51101 +
51102 /*
51103 * Adjust stack execute permissions; explicitly enable for
51104 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51105 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51106 goto out_unlock;
51107 BUG_ON(prev != vma);
51108
51109 - /* Move stack pages down in memory. */
51110 - if (stack_shift) {
51111 - ret = shift_arg_pages(vma, stack_shift);
51112 - if (ret)
51113 - goto out_unlock;
51114 - }
51115 -
51116 /* mprotect_fixup is overkill to remove the temporary stack flags */
51117 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51118
51119 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51120 #endif
51121 current->mm->start_stack = bprm->p;
51122 ret = expand_stack(vma, stack_base);
51123 +
51124 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51125 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51126 + unsigned long size;
51127 + vm_flags_t vm_flags;
51128 +
51129 + size = STACK_TOP - vma->vm_end;
51130 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51131 +
51132 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
51133 +
51134 +#ifdef CONFIG_X86
51135 + if (!ret) {
51136 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51137 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
51138 + }
51139 +#endif
51140 +
51141 + }
51142 +#endif
51143 +
51144 if (ret)
51145 ret = -EFAULT;
51146
51147 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
51148
51149 fsnotify_open(file);
51150
51151 + trace_open_exec(name);
51152 +
51153 err = deny_write_access(file);
51154 if (err)
51155 goto exit;
51156 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
51157 old_fs = get_fs();
51158 set_fs(get_ds());
51159 /* The cast to a user pointer is valid due to the set_fs() */
51160 - result = vfs_read(file, (void __user *)addr, count, &pos);
51161 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51162 set_fs(old_fs);
51163 return result;
51164 }
51165 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51166 }
51167 rcu_read_unlock();
51168
51169 - if (p->fs->users > n_fs) {
51170 + if (atomic_read(&p->fs->users) > n_fs) {
51171 bprm->unsafe |= LSM_UNSAFE_SHARE;
51172 } else {
51173 res = -EAGAIN;
51174 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51175
51176 EXPORT_SYMBOL(search_binary_handler);
51177
51178 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51179 +static DEFINE_PER_CPU(u64, exec_counter);
51180 +static int __init init_exec_counters(void)
51181 +{
51182 + unsigned int cpu;
51183 +
51184 + for_each_possible_cpu(cpu) {
51185 + per_cpu(exec_counter, cpu) = (u64)cpu;
51186 + }
51187 +
51188 + return 0;
51189 +}
51190 +early_initcall(init_exec_counters);
51191 +static inline void increment_exec_counter(void)
51192 +{
51193 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51194 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51195 +}
51196 +#else
51197 +static inline void increment_exec_counter(void) {}
51198 +#endif
51199 +
51200 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51201 + struct user_arg_ptr argv);
51202 +
51203 /*
51204 * sys_execve() executes a new program.
51205 */
51206 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
51207 struct user_arg_ptr argv,
51208 struct user_arg_ptr envp)
51209 {
51210 +#ifdef CONFIG_GRKERNSEC
51211 + struct file *old_exec_file;
51212 + struct acl_subject_label *old_acl;
51213 + struct rlimit old_rlim[RLIM_NLIMITS];
51214 +#endif
51215 struct linux_binprm *bprm;
51216 struct file *file;
51217 struct files_struct *displaced;
51218 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
51219 int retval;
51220 const struct cred *cred = current_cred();
51221
51222 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
51223 +
51224 /*
51225 * We move the actual failure in case of RLIMIT_NPROC excess from
51226 * set*uid() to execve() because too many poorly written programs
51227 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
51228 if (IS_ERR(file))
51229 goto out_unmark;
51230
51231 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51232 + retval = -EPERM;
51233 + goto out_file;
51234 + }
51235 +
51236 sched_exec();
51237
51238 bprm->file = file;
51239 bprm->filename = filename;
51240 bprm->interp = filename;
51241
51242 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
51243 + retval = -EACCES;
51244 + goto out_file;
51245 + }
51246 +
51247 retval = bprm_mm_init(bprm);
51248 if (retval)
51249 goto out_file;
51250 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
51251 if (retval < 0)
51252 goto out;
51253
51254 +#ifdef CONFIG_GRKERNSEC
51255 + old_acl = current->acl;
51256 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51257 + old_exec_file = current->exec_file;
51258 + get_file(file);
51259 + current->exec_file = file;
51260 +#endif
51261 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51262 + /* limit suid stack to 8MB
51263 + * we saved the old limits above and will restore them if this exec fails
51264 + */
51265 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51266 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51267 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51268 +#endif
51269 +
51270 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
51271 + retval = -EPERM;
51272 + goto out_fail;
51273 + }
51274 +
51275 + if (!gr_tpe_allow(file)) {
51276 + retval = -EACCES;
51277 + goto out_fail;
51278 + }
51279 +
51280 + if (gr_check_crash_exec(file)) {
51281 + retval = -EACCES;
51282 + goto out_fail;
51283 + }
51284 +
51285 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
51286 + bprm->unsafe);
51287 + if (retval < 0)
51288 + goto out_fail;
51289 +
51290 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51291 if (retval < 0)
51292 - goto out;
51293 + goto out_fail;
51294
51295 bprm->exec = bprm->p;
51296 retval = copy_strings(bprm->envc, envp, bprm);
51297 if (retval < 0)
51298 - goto out;
51299 + goto out_fail;
51300
51301 retval = copy_strings(bprm->argc, argv, bprm);
51302 if (retval < 0)
51303 - goto out;
51304 + goto out_fail;
51305 +
51306 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
51307 +
51308 + gr_handle_exec_args(bprm, argv);
51309
51310 retval = search_binary_handler(bprm);
51311 if (retval < 0)
51312 - goto out;
51313 + goto out_fail;
51314 +#ifdef CONFIG_GRKERNSEC
51315 + if (old_exec_file)
51316 + fput(old_exec_file);
51317 +#endif
51318
51319 /* execve succeeded */
51320 +
51321 + increment_exec_counter();
51322 current->fs->in_exec = 0;
51323 current->in_execve = 0;
51324 acct_update_integrals(current);
51325 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
51326 put_files_struct(displaced);
51327 return retval;
51328
51329 +out_fail:
51330 +#ifdef CONFIG_GRKERNSEC
51331 + current->acl = old_acl;
51332 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51333 + fput(current->exec_file);
51334 + current->exec_file = old_exec_file;
51335 +#endif
51336 +
51337 out:
51338 if (bprm->mm) {
51339 acct_arg_size(bprm, 0);
51340 @@ -1701,3 +1875,285 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51341 return error;
51342 }
51343 #endif
51344 +
51345 +int pax_check_flags(unsigned long *flags)
51346 +{
51347 + int retval = 0;
51348 +
51349 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51350 + if (*flags & MF_PAX_SEGMEXEC)
51351 + {
51352 + *flags &= ~MF_PAX_SEGMEXEC;
51353 + retval = -EINVAL;
51354 + }
51355 +#endif
51356 +
51357 + if ((*flags & MF_PAX_PAGEEXEC)
51358 +
51359 +#ifdef CONFIG_PAX_PAGEEXEC
51360 + && (*flags & MF_PAX_SEGMEXEC)
51361 +#endif
51362 +
51363 + )
51364 + {
51365 + *flags &= ~MF_PAX_PAGEEXEC;
51366 + retval = -EINVAL;
51367 + }
51368 +
51369 + if ((*flags & MF_PAX_MPROTECT)
51370 +
51371 +#ifdef CONFIG_PAX_MPROTECT
51372 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51373 +#endif
51374 +
51375 + )
51376 + {
51377 + *flags &= ~MF_PAX_MPROTECT;
51378 + retval = -EINVAL;
51379 + }
51380 +
51381 + if ((*flags & MF_PAX_EMUTRAMP)
51382 +
51383 +#ifdef CONFIG_PAX_EMUTRAMP
51384 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51385 +#endif
51386 +
51387 + )
51388 + {
51389 + *flags &= ~MF_PAX_EMUTRAMP;
51390 + retval = -EINVAL;
51391 + }
51392 +
51393 + return retval;
51394 +}
51395 +
51396 +EXPORT_SYMBOL(pax_check_flags);
51397 +
51398 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51399 +char *pax_get_path(const struct path *path, char *buf, int buflen)
51400 +{
51401 + char *pathname = d_path(path, buf, buflen);
51402 +
51403 + if (IS_ERR(pathname))
51404 + goto toolong;
51405 +
51406 + pathname = mangle_path(buf, pathname, "\t\n\\");
51407 + if (!pathname)
51408 + goto toolong;
51409 +
51410 + *pathname = 0;
51411 + return buf;
51412 +
51413 +toolong:
51414 + return "<path too long>";
51415 +}
51416 +EXPORT_SYMBOL(pax_get_path);
51417 +
51418 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51419 +{
51420 + struct task_struct *tsk = current;
51421 + struct mm_struct *mm = current->mm;
51422 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51423 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51424 + char *path_exec = NULL;
51425 + char *path_fault = NULL;
51426 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51427 + siginfo_t info = { };
51428 +
51429 + if (buffer_exec && buffer_fault) {
51430 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51431 +
51432 + down_read(&mm->mmap_sem);
51433 + vma = mm->mmap;
51434 + while (vma && (!vma_exec || !vma_fault)) {
51435 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51436 + vma_exec = vma;
51437 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51438 + vma_fault = vma;
51439 + vma = vma->vm_next;
51440 + }
51441 + if (vma_exec)
51442 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51443 + if (vma_fault) {
51444 + start = vma_fault->vm_start;
51445 + end = vma_fault->vm_end;
51446 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51447 + if (vma_fault->vm_file)
51448 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51449 + else if (pc >= mm->start_brk && pc < mm->brk)
51450 + path_fault = "<heap>";
51451 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
51452 + path_fault = "<stack>";
51453 + else
51454 + path_fault = "<anonymous mapping>";
51455 + }
51456 + up_read(&mm->mmap_sem);
51457 + }
51458 + if (tsk->signal->curr_ip)
51459 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51460 + else
51461 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51462 + 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),
51463 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51464 + free_page((unsigned long)buffer_exec);
51465 + free_page((unsigned long)buffer_fault);
51466 + pax_report_insns(regs, pc, sp);
51467 + info.si_signo = SIGKILL;
51468 + info.si_errno = 0;
51469 + info.si_code = SI_KERNEL;
51470 + info.si_pid = 0;
51471 + info.si_uid = 0;
51472 + do_coredump(&info);
51473 +}
51474 +#endif
51475 +
51476 +#ifdef CONFIG_PAX_REFCOUNT
51477 +void pax_report_refcount_overflow(struct pt_regs *regs)
51478 +{
51479 + if (current->signal->curr_ip)
51480 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51481 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51482 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51483 + else
51484 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51485 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51486 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51487 + show_regs(regs);
51488 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51489 +}
51490 +#endif
51491 +
51492 +#ifdef CONFIG_PAX_USERCOPY
51493 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51494 +static noinline int check_stack_object(const void *obj, unsigned long len)
51495 +{
51496 + const void * const stack = task_stack_page(current);
51497 + const void * const stackend = stack + THREAD_SIZE;
51498 +
51499 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51500 + const void *frame = NULL;
51501 + const void *oldframe;
51502 +#endif
51503 +
51504 + if (obj + len < obj)
51505 + return -1;
51506 +
51507 + if (obj + len <= stack || stackend <= obj)
51508 + return 0;
51509 +
51510 + if (obj < stack || stackend < obj + len)
51511 + return -1;
51512 +
51513 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51514 + oldframe = __builtin_frame_address(1);
51515 + if (oldframe)
51516 + frame = __builtin_frame_address(2);
51517 + /*
51518 + low ----------------------------------------------> high
51519 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51520 + ^----------------^
51521 + allow copies only within here
51522 + */
51523 + while (stack <= frame && frame < stackend) {
51524 + /* if obj + len extends past the last frame, this
51525 + check won't pass and the next frame will be 0,
51526 + causing us to bail out and correctly report
51527 + the copy as invalid
51528 + */
51529 + if (obj + len <= frame)
51530 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51531 + oldframe = frame;
51532 + frame = *(const void * const *)frame;
51533 + }
51534 + return -1;
51535 +#else
51536 + return 1;
51537 +#endif
51538 +}
51539 +
51540 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51541 +{
51542 + if (current->signal->curr_ip)
51543 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51544 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51545 + else
51546 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51547 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51548 + dump_stack();
51549 + gr_handle_kernel_exploit();
51550 + do_group_exit(SIGKILL);
51551 +}
51552 +#endif
51553 +
51554 +#ifdef CONFIG_PAX_USERCOPY
51555 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51556 +{
51557 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51558 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51559 +#ifdef CONFIG_MODULES
51560 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
51561 +#else
51562 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51563 +#endif
51564 +
51565 +#else
51566 + unsigned long textlow = (unsigned long)_stext;
51567 + unsigned long texthigh = (unsigned long)_etext;
51568 +#endif
51569 +
51570 + if (high <= textlow || low > texthigh)
51571 + return false;
51572 + else
51573 + return true;
51574 +}
51575 +#endif
51576 +
51577 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51578 +{
51579 +
51580 +#ifdef CONFIG_PAX_USERCOPY
51581 + const char *type;
51582 +
51583 + if (!n)
51584 + return;
51585 +
51586 + type = check_heap_object(ptr, n);
51587 + if (!type) {
51588 + int ret = check_stack_object(ptr, n);
51589 + if (ret == 1 || ret == 2)
51590 + return;
51591 + if (ret == 0) {
51592 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51593 + type = "<kernel text>";
51594 + else
51595 + return;
51596 + } else
51597 + type = "<process stack>";
51598 + }
51599 +
51600 + pax_report_usercopy(ptr, n, to_user, type);
51601 +#endif
51602 +
51603 +}
51604 +EXPORT_SYMBOL(__check_object_size);
51605 +
51606 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51607 +void pax_track_stack(void)
51608 +{
51609 + unsigned long sp = (unsigned long)&sp;
51610 + if (sp < current_thread_info()->lowest_stack &&
51611 + sp > (unsigned long)task_stack_page(current))
51612 + current_thread_info()->lowest_stack = sp;
51613 +}
51614 +EXPORT_SYMBOL(pax_track_stack);
51615 +#endif
51616 +
51617 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51618 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51619 +{
51620 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51621 + dump_stack();
51622 + do_group_exit(SIGKILL);
51623 +}
51624 +EXPORT_SYMBOL(report_size_overflow);
51625 +#endif
51626 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51627 index 9f9992b..8b59411 100644
51628 --- a/fs/ext2/balloc.c
51629 +++ b/fs/ext2/balloc.c
51630 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51631
51632 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51633 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51634 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51635 + if (free_blocks < root_blocks + 1 &&
51636 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51637 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51638 - !in_group_p (sbi->s_resgid))) {
51639 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51640 return 0;
51641 }
51642 return 1;
51643 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51644 index 22548f5..41521d8 100644
51645 --- a/fs/ext3/balloc.c
51646 +++ b/fs/ext3/balloc.c
51647 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51648
51649 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51650 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51651 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51652 + if (free_blocks < root_blocks + 1 &&
51653 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51654 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51655 - !in_group_p (sbi->s_resgid))) {
51656 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51657 return 0;
51658 }
51659 return 1;
51660 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51661 index 3742e4c..69a797f 100644
51662 --- a/fs/ext4/balloc.c
51663 +++ b/fs/ext4/balloc.c
51664 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51665 /* Hm, nope. Are (enough) root reserved clusters available? */
51666 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51667 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51668 - capable(CAP_SYS_RESOURCE) ||
51669 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51670 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51671 + capable_nolog(CAP_SYS_RESOURCE)) {
51672
51673 if (free_clusters >= (nclusters + dirty_clusters +
51674 resv_clusters))
51675 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51676 index 5aae3d1..b5da7f8 100644
51677 --- a/fs/ext4/ext4.h
51678 +++ b/fs/ext4/ext4.h
51679 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
51680 unsigned long s_mb_last_start;
51681
51682 /* stats for buddy allocator */
51683 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51684 - atomic_t s_bal_success; /* we found long enough chunks */
51685 - atomic_t s_bal_allocated; /* in blocks */
51686 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51687 - atomic_t s_bal_goals; /* goal hits */
51688 - atomic_t s_bal_breaks; /* too long searches */
51689 - atomic_t s_bal_2orders; /* 2^order hits */
51690 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51691 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51692 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51693 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51694 + atomic_unchecked_t s_bal_goals; /* goal hits */
51695 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51696 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51697 spinlock_t s_bal_lock;
51698 unsigned long s_mb_buddies_generated;
51699 unsigned long long s_mb_generation_time;
51700 - atomic_t s_mb_lost_chunks;
51701 - atomic_t s_mb_preallocated;
51702 - atomic_t s_mb_discarded;
51703 + atomic_unchecked_t s_mb_lost_chunks;
51704 + atomic_unchecked_t s_mb_preallocated;
51705 + atomic_unchecked_t s_mb_discarded;
51706 atomic_t s_lock_busy;
51707
51708 /* locality groups */
51709 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51710 index 59c6750..a549154 100644
51711 --- a/fs/ext4/mballoc.c
51712 +++ b/fs/ext4/mballoc.c
51713 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51714 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51715
51716 if (EXT4_SB(sb)->s_mb_stats)
51717 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51718 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51719
51720 break;
51721 }
51722 @@ -2170,7 +2170,7 @@ repeat:
51723 ac->ac_status = AC_STATUS_CONTINUE;
51724 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51725 cr = 3;
51726 - atomic_inc(&sbi->s_mb_lost_chunks);
51727 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51728 goto repeat;
51729 }
51730 }
51731 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
51732 if (sbi->s_mb_stats) {
51733 ext4_msg(sb, KERN_INFO,
51734 "mballoc: %u blocks %u reqs (%u success)",
51735 - atomic_read(&sbi->s_bal_allocated),
51736 - atomic_read(&sbi->s_bal_reqs),
51737 - atomic_read(&sbi->s_bal_success));
51738 + atomic_read_unchecked(&sbi->s_bal_allocated),
51739 + atomic_read_unchecked(&sbi->s_bal_reqs),
51740 + atomic_read_unchecked(&sbi->s_bal_success));
51741 ext4_msg(sb, KERN_INFO,
51742 "mballoc: %u extents scanned, %u goal hits, "
51743 "%u 2^N hits, %u breaks, %u lost",
51744 - atomic_read(&sbi->s_bal_ex_scanned),
51745 - atomic_read(&sbi->s_bal_goals),
51746 - atomic_read(&sbi->s_bal_2orders),
51747 - atomic_read(&sbi->s_bal_breaks),
51748 - atomic_read(&sbi->s_mb_lost_chunks));
51749 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51750 + atomic_read_unchecked(&sbi->s_bal_goals),
51751 + atomic_read_unchecked(&sbi->s_bal_2orders),
51752 + atomic_read_unchecked(&sbi->s_bal_breaks),
51753 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51754 ext4_msg(sb, KERN_INFO,
51755 "mballoc: %lu generated and it took %Lu",
51756 sbi->s_mb_buddies_generated,
51757 sbi->s_mb_generation_time);
51758 ext4_msg(sb, KERN_INFO,
51759 "mballoc: %u preallocated, %u discarded",
51760 - atomic_read(&sbi->s_mb_preallocated),
51761 - atomic_read(&sbi->s_mb_discarded));
51762 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51763 + atomic_read_unchecked(&sbi->s_mb_discarded));
51764 }
51765
51766 free_percpu(sbi->s_locality_groups);
51767 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51768 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51769
51770 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51771 - atomic_inc(&sbi->s_bal_reqs);
51772 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51773 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51774 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51775 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51776 - atomic_inc(&sbi->s_bal_success);
51777 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51778 + atomic_inc_unchecked(&sbi->s_bal_success);
51779 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51780 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51781 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51782 - atomic_inc(&sbi->s_bal_goals);
51783 + atomic_inc_unchecked(&sbi->s_bal_goals);
51784 if (ac->ac_found > sbi->s_mb_max_to_scan)
51785 - atomic_inc(&sbi->s_bal_breaks);
51786 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51787 }
51788
51789 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51790 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51791 trace_ext4_mb_new_inode_pa(ac, pa);
51792
51793 ext4_mb_use_inode_pa(ac, pa);
51794 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51795 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51796
51797 ei = EXT4_I(ac->ac_inode);
51798 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51799 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51800 trace_ext4_mb_new_group_pa(ac, pa);
51801
51802 ext4_mb_use_group_pa(ac, pa);
51803 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51804 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51805
51806 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51807 lg = ac->ac_lg;
51808 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51809 * from the bitmap and continue.
51810 */
51811 }
51812 - atomic_add(free, &sbi->s_mb_discarded);
51813 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51814
51815 return err;
51816 }
51817 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51818 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51819 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51820 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51821 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51822 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51823 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51824
51825 return 0;
51826 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
51827 index 214461e..3614c89 100644
51828 --- a/fs/ext4/mmp.c
51829 +++ b/fs/ext4/mmp.c
51830 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
51831 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
51832 const char *function, unsigned int line, const char *msg)
51833 {
51834 - __ext4_warning(sb, function, line, msg);
51835 + __ext4_warning(sb, function, line, "%s", msg);
51836 __ext4_warning(sb, function, line,
51837 "MMP failure info: last update time: %llu, last update "
51838 "node: %s, last update device: %s\n",
51839 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
51840 index 49d3c01..9579efd 100644
51841 --- a/fs/ext4/resize.c
51842 +++ b/fs/ext4/resize.c
51843 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
51844 ext4_fsblk_t end = start + input->blocks_count;
51845 ext4_group_t group = input->group;
51846 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
51847 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
51848 - ext4_fsblk_t metaend = start + overhead;
51849 + unsigned overhead;
51850 + ext4_fsblk_t metaend;
51851 struct buffer_head *bh = NULL;
51852 ext4_grpblk_t free_blocks_count, offset;
51853 int err = -EINVAL;
51854
51855 + if (group != sbi->s_groups_count) {
51856 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51857 + input->group, sbi->s_groups_count);
51858 + return -EINVAL;
51859 + }
51860 +
51861 + overhead = ext4_group_overhead_blocks(sb, group);
51862 + metaend = start + overhead;
51863 input->free_blocks_count = free_blocks_count =
51864 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
51865
51866 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
51867 free_blocks_count, input->reserved_blocks);
51868
51869 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
51870 - if (group != sbi->s_groups_count)
51871 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51872 - input->group, sbi->s_groups_count);
51873 - else if (offset != 0)
51874 + if (offset != 0)
51875 ext4_warning(sb, "Last group not full");
51876 else if (input->reserved_blocks > input->blocks_count / 5)
51877 ext4_warning(sb, "Reserved blocks too high (%u)",
51878 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51879 index 6681c03..d88cd33 100644
51880 --- a/fs/ext4/super.c
51881 +++ b/fs/ext4/super.c
51882 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
51883 }
51884
51885 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
51886 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51887 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51888 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
51889
51890 #ifdef CONFIG_QUOTA
51891 @@ -2372,7 +2372,7 @@ struct ext4_attr {
51892 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51893 const char *, size_t);
51894 int offset;
51895 -};
51896 +} __do_const;
51897
51898 static int parse_strtoull(const char *buf,
51899 unsigned long long max, unsigned long long *value)
51900 diff --git a/fs/fcntl.c b/fs/fcntl.c
51901 index 6599222..e7bf0de 100644
51902 --- a/fs/fcntl.c
51903 +++ b/fs/fcntl.c
51904 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51905 if (err)
51906 return err;
51907
51908 + if (gr_handle_chroot_fowner(pid, type))
51909 + return -ENOENT;
51910 + if (gr_check_protected_task_fowner(pid, type))
51911 + return -EACCES;
51912 +
51913 f_modown(filp, pid, type, force);
51914 return 0;
51915 }
51916 diff --git a/fs/fhandle.c b/fs/fhandle.c
51917 index 999ff5c..41f4109 100644
51918 --- a/fs/fhandle.c
51919 +++ b/fs/fhandle.c
51920 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51921 } else
51922 retval = 0;
51923 /* copy the mount id */
51924 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51925 - sizeof(*mnt_id)) ||
51926 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51927 copy_to_user(ufh, handle,
51928 sizeof(struct file_handle) + handle_bytes))
51929 retval = -EFAULT;
51930 diff --git a/fs/file.c b/fs/file.c
51931 index 4a78f98..9447397 100644
51932 --- a/fs/file.c
51933 +++ b/fs/file.c
51934 @@ -16,6 +16,7 @@
51935 #include <linux/slab.h>
51936 #include <linux/vmalloc.h>
51937 #include <linux/file.h>
51938 +#include <linux/security.h>
51939 #include <linux/fdtable.h>
51940 #include <linux/bitops.h>
51941 #include <linux/interrupt.h>
51942 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51943 if (!file)
51944 return __close_fd(files, fd);
51945
51946 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51947 if (fd >= rlimit(RLIMIT_NOFILE))
51948 return -EBADF;
51949
51950 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51951 if (unlikely(oldfd == newfd))
51952 return -EINVAL;
51953
51954 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51955 if (newfd >= rlimit(RLIMIT_NOFILE))
51956 return -EBADF;
51957
51958 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51959 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51960 {
51961 int err;
51962 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51963 if (from >= rlimit(RLIMIT_NOFILE))
51964 return -EINVAL;
51965 err = alloc_fd(from, flags);
51966 diff --git a/fs/filesystems.c b/fs/filesystems.c
51967 index 92567d9..fcd8cbf 100644
51968 --- a/fs/filesystems.c
51969 +++ b/fs/filesystems.c
51970 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51971 int len = dot ? dot - name : strlen(name);
51972
51973 fs = __get_fs_type(name, len);
51974 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51975 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51976 +#else
51977 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51978 +#endif
51979 fs = __get_fs_type(name, len);
51980
51981 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51982 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51983 index d8ac61d..79a36f0 100644
51984 --- a/fs/fs_struct.c
51985 +++ b/fs/fs_struct.c
51986 @@ -4,6 +4,7 @@
51987 #include <linux/path.h>
51988 #include <linux/slab.h>
51989 #include <linux/fs_struct.h>
51990 +#include <linux/grsecurity.h>
51991 #include "internal.h"
51992
51993 /*
51994 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51995 write_seqcount_begin(&fs->seq);
51996 old_root = fs->root;
51997 fs->root = *path;
51998 + gr_set_chroot_entries(current, path);
51999 write_seqcount_end(&fs->seq);
52000 spin_unlock(&fs->lock);
52001 if (old_root.dentry)
52002 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
52003 int hits = 0;
52004 spin_lock(&fs->lock);
52005 write_seqcount_begin(&fs->seq);
52006 + /* this root replacement is only done by pivot_root,
52007 + leave grsec's chroot tagging alone for this task
52008 + so that a pivoted root isn't treated as a chroot
52009 + */
52010 hits += replace_path(&fs->root, old_root, new_root);
52011 hits += replace_path(&fs->pwd, old_root, new_root);
52012 write_seqcount_end(&fs->seq);
52013 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
52014 task_lock(tsk);
52015 spin_lock(&fs->lock);
52016 tsk->fs = NULL;
52017 - kill = !--fs->users;
52018 + gr_clear_chroot_entries(tsk);
52019 + kill = !atomic_dec_return(&fs->users);
52020 spin_unlock(&fs->lock);
52021 task_unlock(tsk);
52022 if (kill)
52023 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52024 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
52025 /* We don't need to lock fs - think why ;-) */
52026 if (fs) {
52027 - fs->users = 1;
52028 + atomic_set(&fs->users, 1);
52029 fs->in_exec = 0;
52030 spin_lock_init(&fs->lock);
52031 seqcount_init(&fs->seq);
52032 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52033 spin_lock(&old->lock);
52034 fs->root = old->root;
52035 path_get(&fs->root);
52036 + /* instead of calling gr_set_chroot_entries here,
52037 + we call it from every caller of this function
52038 + */
52039 fs->pwd = old->pwd;
52040 path_get(&fs->pwd);
52041 spin_unlock(&old->lock);
52042 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
52043
52044 task_lock(current);
52045 spin_lock(&fs->lock);
52046 - kill = !--fs->users;
52047 + kill = !atomic_dec_return(&fs->users);
52048 current->fs = new_fs;
52049 + gr_set_chroot_entries(current, &new_fs->root);
52050 spin_unlock(&fs->lock);
52051 task_unlock(current);
52052
52053 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
52054
52055 int current_umask(void)
52056 {
52057 - return current->fs->umask;
52058 + return current->fs->umask | gr_acl_umask();
52059 }
52060 EXPORT_SYMBOL(current_umask);
52061
52062 /* to be mentioned only in INIT_TASK */
52063 struct fs_struct init_fs = {
52064 - .users = 1,
52065 + .users = ATOMIC_INIT(1),
52066 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
52067 .seq = SEQCNT_ZERO,
52068 .umask = 0022,
52069 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
52070 index e2cba1f..17a25bb 100644
52071 --- a/fs/fscache/cookie.c
52072 +++ b/fs/fscache/cookie.c
52073 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52074 parent ? (char *) parent->def->name : "<no-parent>",
52075 def->name, netfs_data);
52076
52077 - fscache_stat(&fscache_n_acquires);
52078 + fscache_stat_unchecked(&fscache_n_acquires);
52079
52080 /* if there's no parent cookie, then we don't create one here either */
52081 if (!parent) {
52082 - fscache_stat(&fscache_n_acquires_null);
52083 + fscache_stat_unchecked(&fscache_n_acquires_null);
52084 _leave(" [no parent]");
52085 return NULL;
52086 }
52087 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52088 /* allocate and initialise a cookie */
52089 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52090 if (!cookie) {
52091 - fscache_stat(&fscache_n_acquires_oom);
52092 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52093 _leave(" [ENOMEM]");
52094 return NULL;
52095 }
52096 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52097
52098 switch (cookie->def->type) {
52099 case FSCACHE_COOKIE_TYPE_INDEX:
52100 - fscache_stat(&fscache_n_cookie_index);
52101 + fscache_stat_unchecked(&fscache_n_cookie_index);
52102 break;
52103 case FSCACHE_COOKIE_TYPE_DATAFILE:
52104 - fscache_stat(&fscache_n_cookie_data);
52105 + fscache_stat_unchecked(&fscache_n_cookie_data);
52106 break;
52107 default:
52108 - fscache_stat(&fscache_n_cookie_special);
52109 + fscache_stat_unchecked(&fscache_n_cookie_special);
52110 break;
52111 }
52112
52113 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52114 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52115 atomic_dec(&parent->n_children);
52116 __fscache_cookie_put(cookie);
52117 - fscache_stat(&fscache_n_acquires_nobufs);
52118 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52119 _leave(" = NULL");
52120 return NULL;
52121 }
52122 }
52123
52124 - fscache_stat(&fscache_n_acquires_ok);
52125 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52126 _leave(" = %p", cookie);
52127 return cookie;
52128 }
52129 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52130 cache = fscache_select_cache_for_object(cookie->parent);
52131 if (!cache) {
52132 up_read(&fscache_addremove_sem);
52133 - fscache_stat(&fscache_n_acquires_no_cache);
52134 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52135 _leave(" = -ENOMEDIUM [no cache]");
52136 return -ENOMEDIUM;
52137 }
52138 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52139 object = cache->ops->alloc_object(cache, cookie);
52140 fscache_stat_d(&fscache_n_cop_alloc_object);
52141 if (IS_ERR(object)) {
52142 - fscache_stat(&fscache_n_object_no_alloc);
52143 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52144 ret = PTR_ERR(object);
52145 goto error;
52146 }
52147
52148 - fscache_stat(&fscache_n_object_alloc);
52149 + fscache_stat_unchecked(&fscache_n_object_alloc);
52150
52151 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52152
52153 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52154
52155 _enter("{%s}", cookie->def->name);
52156
52157 - fscache_stat(&fscache_n_invalidates);
52158 + fscache_stat_unchecked(&fscache_n_invalidates);
52159
52160 /* Only permit invalidation of data files. Invalidating an index will
52161 * require the caller to release all its attachments to the tree rooted
52162 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52163 {
52164 struct fscache_object *object;
52165
52166 - fscache_stat(&fscache_n_updates);
52167 + fscache_stat_unchecked(&fscache_n_updates);
52168
52169 if (!cookie) {
52170 - fscache_stat(&fscache_n_updates_null);
52171 + fscache_stat_unchecked(&fscache_n_updates_null);
52172 _leave(" [no cookie]");
52173 return;
52174 }
52175 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52176 struct fscache_object *object;
52177 unsigned long event;
52178
52179 - fscache_stat(&fscache_n_relinquishes);
52180 + fscache_stat_unchecked(&fscache_n_relinquishes);
52181 if (retire)
52182 - fscache_stat(&fscache_n_relinquishes_retire);
52183 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52184
52185 if (!cookie) {
52186 - fscache_stat(&fscache_n_relinquishes_null);
52187 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52188 _leave(" [no cookie]");
52189 return;
52190 }
52191 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52192
52193 /* wait for the cookie to finish being instantiated (or to fail) */
52194 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52195 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52196 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52197 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52198 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52199 }
52200 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52201 index ee38fef..0a326d4 100644
52202 --- a/fs/fscache/internal.h
52203 +++ b/fs/fscache/internal.h
52204 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52205 * stats.c
52206 */
52207 #ifdef CONFIG_FSCACHE_STATS
52208 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52209 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52210 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52211 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52212
52213 -extern atomic_t fscache_n_op_pend;
52214 -extern atomic_t fscache_n_op_run;
52215 -extern atomic_t fscache_n_op_enqueue;
52216 -extern atomic_t fscache_n_op_deferred_release;
52217 -extern atomic_t fscache_n_op_release;
52218 -extern atomic_t fscache_n_op_gc;
52219 -extern atomic_t fscache_n_op_cancelled;
52220 -extern atomic_t fscache_n_op_rejected;
52221 +extern atomic_unchecked_t fscache_n_op_pend;
52222 +extern atomic_unchecked_t fscache_n_op_run;
52223 +extern atomic_unchecked_t fscache_n_op_enqueue;
52224 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52225 +extern atomic_unchecked_t fscache_n_op_release;
52226 +extern atomic_unchecked_t fscache_n_op_gc;
52227 +extern atomic_unchecked_t fscache_n_op_cancelled;
52228 +extern atomic_unchecked_t fscache_n_op_rejected;
52229
52230 -extern atomic_t fscache_n_attr_changed;
52231 -extern atomic_t fscache_n_attr_changed_ok;
52232 -extern atomic_t fscache_n_attr_changed_nobufs;
52233 -extern atomic_t fscache_n_attr_changed_nomem;
52234 -extern atomic_t fscache_n_attr_changed_calls;
52235 +extern atomic_unchecked_t fscache_n_attr_changed;
52236 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52237 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52238 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52239 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52240
52241 -extern atomic_t fscache_n_allocs;
52242 -extern atomic_t fscache_n_allocs_ok;
52243 -extern atomic_t fscache_n_allocs_wait;
52244 -extern atomic_t fscache_n_allocs_nobufs;
52245 -extern atomic_t fscache_n_allocs_intr;
52246 -extern atomic_t fscache_n_allocs_object_dead;
52247 -extern atomic_t fscache_n_alloc_ops;
52248 -extern atomic_t fscache_n_alloc_op_waits;
52249 +extern atomic_unchecked_t fscache_n_allocs;
52250 +extern atomic_unchecked_t fscache_n_allocs_ok;
52251 +extern atomic_unchecked_t fscache_n_allocs_wait;
52252 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52253 +extern atomic_unchecked_t fscache_n_allocs_intr;
52254 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52255 +extern atomic_unchecked_t fscache_n_alloc_ops;
52256 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52257
52258 -extern atomic_t fscache_n_retrievals;
52259 -extern atomic_t fscache_n_retrievals_ok;
52260 -extern atomic_t fscache_n_retrievals_wait;
52261 -extern atomic_t fscache_n_retrievals_nodata;
52262 -extern atomic_t fscache_n_retrievals_nobufs;
52263 -extern atomic_t fscache_n_retrievals_intr;
52264 -extern atomic_t fscache_n_retrievals_nomem;
52265 -extern atomic_t fscache_n_retrievals_object_dead;
52266 -extern atomic_t fscache_n_retrieval_ops;
52267 -extern atomic_t fscache_n_retrieval_op_waits;
52268 +extern atomic_unchecked_t fscache_n_retrievals;
52269 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52270 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52271 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52272 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52273 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52274 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52275 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52276 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52277 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52278
52279 -extern atomic_t fscache_n_stores;
52280 -extern atomic_t fscache_n_stores_ok;
52281 -extern atomic_t fscache_n_stores_again;
52282 -extern atomic_t fscache_n_stores_nobufs;
52283 -extern atomic_t fscache_n_stores_oom;
52284 -extern atomic_t fscache_n_store_ops;
52285 -extern atomic_t fscache_n_store_calls;
52286 -extern atomic_t fscache_n_store_pages;
52287 -extern atomic_t fscache_n_store_radix_deletes;
52288 -extern atomic_t fscache_n_store_pages_over_limit;
52289 +extern atomic_unchecked_t fscache_n_stores;
52290 +extern atomic_unchecked_t fscache_n_stores_ok;
52291 +extern atomic_unchecked_t fscache_n_stores_again;
52292 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52293 +extern atomic_unchecked_t fscache_n_stores_oom;
52294 +extern atomic_unchecked_t fscache_n_store_ops;
52295 +extern atomic_unchecked_t fscache_n_store_calls;
52296 +extern atomic_unchecked_t fscache_n_store_pages;
52297 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52298 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52299
52300 -extern atomic_t fscache_n_store_vmscan_not_storing;
52301 -extern atomic_t fscache_n_store_vmscan_gone;
52302 -extern atomic_t fscache_n_store_vmscan_busy;
52303 -extern atomic_t fscache_n_store_vmscan_cancelled;
52304 -extern atomic_t fscache_n_store_vmscan_wait;
52305 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52306 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52307 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52308 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52309 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52310
52311 -extern atomic_t fscache_n_marks;
52312 -extern atomic_t fscache_n_uncaches;
52313 +extern atomic_unchecked_t fscache_n_marks;
52314 +extern atomic_unchecked_t fscache_n_uncaches;
52315
52316 -extern atomic_t fscache_n_acquires;
52317 -extern atomic_t fscache_n_acquires_null;
52318 -extern atomic_t fscache_n_acquires_no_cache;
52319 -extern atomic_t fscache_n_acquires_ok;
52320 -extern atomic_t fscache_n_acquires_nobufs;
52321 -extern atomic_t fscache_n_acquires_oom;
52322 +extern atomic_unchecked_t fscache_n_acquires;
52323 +extern atomic_unchecked_t fscache_n_acquires_null;
52324 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52325 +extern atomic_unchecked_t fscache_n_acquires_ok;
52326 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52327 +extern atomic_unchecked_t fscache_n_acquires_oom;
52328
52329 -extern atomic_t fscache_n_invalidates;
52330 -extern atomic_t fscache_n_invalidates_run;
52331 +extern atomic_unchecked_t fscache_n_invalidates;
52332 +extern atomic_unchecked_t fscache_n_invalidates_run;
52333
52334 -extern atomic_t fscache_n_updates;
52335 -extern atomic_t fscache_n_updates_null;
52336 -extern atomic_t fscache_n_updates_run;
52337 +extern atomic_unchecked_t fscache_n_updates;
52338 +extern atomic_unchecked_t fscache_n_updates_null;
52339 +extern atomic_unchecked_t fscache_n_updates_run;
52340
52341 -extern atomic_t fscache_n_relinquishes;
52342 -extern atomic_t fscache_n_relinquishes_null;
52343 -extern atomic_t fscache_n_relinquishes_waitcrt;
52344 -extern atomic_t fscache_n_relinquishes_retire;
52345 +extern atomic_unchecked_t fscache_n_relinquishes;
52346 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52347 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52348 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52349
52350 -extern atomic_t fscache_n_cookie_index;
52351 -extern atomic_t fscache_n_cookie_data;
52352 -extern atomic_t fscache_n_cookie_special;
52353 +extern atomic_unchecked_t fscache_n_cookie_index;
52354 +extern atomic_unchecked_t fscache_n_cookie_data;
52355 +extern atomic_unchecked_t fscache_n_cookie_special;
52356
52357 -extern atomic_t fscache_n_object_alloc;
52358 -extern atomic_t fscache_n_object_no_alloc;
52359 -extern atomic_t fscache_n_object_lookups;
52360 -extern atomic_t fscache_n_object_lookups_negative;
52361 -extern atomic_t fscache_n_object_lookups_positive;
52362 -extern atomic_t fscache_n_object_lookups_timed_out;
52363 -extern atomic_t fscache_n_object_created;
52364 -extern atomic_t fscache_n_object_avail;
52365 -extern atomic_t fscache_n_object_dead;
52366 +extern atomic_unchecked_t fscache_n_object_alloc;
52367 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52368 +extern atomic_unchecked_t fscache_n_object_lookups;
52369 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52370 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52371 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52372 +extern atomic_unchecked_t fscache_n_object_created;
52373 +extern atomic_unchecked_t fscache_n_object_avail;
52374 +extern atomic_unchecked_t fscache_n_object_dead;
52375
52376 -extern atomic_t fscache_n_checkaux_none;
52377 -extern atomic_t fscache_n_checkaux_okay;
52378 -extern atomic_t fscache_n_checkaux_update;
52379 -extern atomic_t fscache_n_checkaux_obsolete;
52380 +extern atomic_unchecked_t fscache_n_checkaux_none;
52381 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52382 +extern atomic_unchecked_t fscache_n_checkaux_update;
52383 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52384
52385 extern atomic_t fscache_n_cop_alloc_object;
52386 extern atomic_t fscache_n_cop_lookup_object;
52387 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52388 atomic_inc(stat);
52389 }
52390
52391 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52392 +{
52393 + atomic_inc_unchecked(stat);
52394 +}
52395 +
52396 static inline void fscache_stat_d(atomic_t *stat)
52397 {
52398 atomic_dec(stat);
52399 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52400
52401 #define __fscache_stat(stat) (NULL)
52402 #define fscache_stat(stat) do {} while (0)
52403 +#define fscache_stat_unchecked(stat) do {} while (0)
52404 #define fscache_stat_d(stat) do {} while (0)
52405 #endif
52406
52407 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52408 index 50d41c1..10ee117 100644
52409 --- a/fs/fscache/object.c
52410 +++ b/fs/fscache/object.c
52411 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52412 /* Invalidate an object on disk */
52413 case FSCACHE_OBJECT_INVALIDATING:
52414 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52415 - fscache_stat(&fscache_n_invalidates_run);
52416 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52417 fscache_stat(&fscache_n_cop_invalidate_object);
52418 fscache_invalidate_object(object);
52419 fscache_stat_d(&fscache_n_cop_invalidate_object);
52420 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52421 /* update the object metadata on disk */
52422 case FSCACHE_OBJECT_UPDATING:
52423 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52424 - fscache_stat(&fscache_n_updates_run);
52425 + fscache_stat_unchecked(&fscache_n_updates_run);
52426 fscache_stat(&fscache_n_cop_update_object);
52427 object->cache->ops->update_object(object);
52428 fscache_stat_d(&fscache_n_cop_update_object);
52429 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52430 spin_lock(&object->lock);
52431 object->state = FSCACHE_OBJECT_DEAD;
52432 spin_unlock(&object->lock);
52433 - fscache_stat(&fscache_n_object_dead);
52434 + fscache_stat_unchecked(&fscache_n_object_dead);
52435 goto terminal_transit;
52436
52437 /* handle the parent cache of this object being withdrawn from
52438 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52439 spin_lock(&object->lock);
52440 object->state = FSCACHE_OBJECT_DEAD;
52441 spin_unlock(&object->lock);
52442 - fscache_stat(&fscache_n_object_dead);
52443 + fscache_stat_unchecked(&fscache_n_object_dead);
52444 goto terminal_transit;
52445
52446 /* complain about the object being woken up once it is
52447 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52448 parent->cookie->def->name, cookie->def->name,
52449 object->cache->tag->name);
52450
52451 - fscache_stat(&fscache_n_object_lookups);
52452 + fscache_stat_unchecked(&fscache_n_object_lookups);
52453 fscache_stat(&fscache_n_cop_lookup_object);
52454 ret = object->cache->ops->lookup_object(object);
52455 fscache_stat_d(&fscache_n_cop_lookup_object);
52456 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52457 if (ret == -ETIMEDOUT) {
52458 /* probably stuck behind another object, so move this one to
52459 * the back of the queue */
52460 - fscache_stat(&fscache_n_object_lookups_timed_out);
52461 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52462 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52463 }
52464
52465 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52466
52467 spin_lock(&object->lock);
52468 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52469 - fscache_stat(&fscache_n_object_lookups_negative);
52470 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52471
52472 /* transit here to allow write requests to begin stacking up
52473 * and read requests to begin returning ENODATA */
52474 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52475 * result, in which case there may be data available */
52476 spin_lock(&object->lock);
52477 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52478 - fscache_stat(&fscache_n_object_lookups_positive);
52479 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52480
52481 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52482
52483 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52484 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52485 } else {
52486 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52487 - fscache_stat(&fscache_n_object_created);
52488 + fscache_stat_unchecked(&fscache_n_object_created);
52489
52490 object->state = FSCACHE_OBJECT_AVAILABLE;
52491 spin_unlock(&object->lock);
52492 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52493 fscache_enqueue_dependents(object);
52494
52495 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52496 - fscache_stat(&fscache_n_object_avail);
52497 + fscache_stat_unchecked(&fscache_n_object_avail);
52498
52499 _leave("");
52500 }
52501 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52502 enum fscache_checkaux result;
52503
52504 if (!object->cookie->def->check_aux) {
52505 - fscache_stat(&fscache_n_checkaux_none);
52506 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52507 return FSCACHE_CHECKAUX_OKAY;
52508 }
52509
52510 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52511 switch (result) {
52512 /* entry okay as is */
52513 case FSCACHE_CHECKAUX_OKAY:
52514 - fscache_stat(&fscache_n_checkaux_okay);
52515 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52516 break;
52517
52518 /* entry requires update */
52519 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52520 - fscache_stat(&fscache_n_checkaux_update);
52521 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52522 break;
52523
52524 /* entry requires deletion */
52525 case FSCACHE_CHECKAUX_OBSOLETE:
52526 - fscache_stat(&fscache_n_checkaux_obsolete);
52527 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52528 break;
52529
52530 default:
52531 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52532 index 762a9ec..2023284 100644
52533 --- a/fs/fscache/operation.c
52534 +++ b/fs/fscache/operation.c
52535 @@ -17,7 +17,7 @@
52536 #include <linux/slab.h>
52537 #include "internal.h"
52538
52539 -atomic_t fscache_op_debug_id;
52540 +atomic_unchecked_t fscache_op_debug_id;
52541 EXPORT_SYMBOL(fscache_op_debug_id);
52542
52543 /**
52544 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52545 ASSERTCMP(atomic_read(&op->usage), >, 0);
52546 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52547
52548 - fscache_stat(&fscache_n_op_enqueue);
52549 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52550 switch (op->flags & FSCACHE_OP_TYPE) {
52551 case FSCACHE_OP_ASYNC:
52552 _debug("queue async");
52553 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52554 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52555 if (op->processor)
52556 fscache_enqueue_operation(op);
52557 - fscache_stat(&fscache_n_op_run);
52558 + fscache_stat_unchecked(&fscache_n_op_run);
52559 }
52560
52561 /*
52562 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52563 if (object->n_in_progress > 0) {
52564 atomic_inc(&op->usage);
52565 list_add_tail(&op->pend_link, &object->pending_ops);
52566 - fscache_stat(&fscache_n_op_pend);
52567 + fscache_stat_unchecked(&fscache_n_op_pend);
52568 } else if (!list_empty(&object->pending_ops)) {
52569 atomic_inc(&op->usage);
52570 list_add_tail(&op->pend_link, &object->pending_ops);
52571 - fscache_stat(&fscache_n_op_pend);
52572 + fscache_stat_unchecked(&fscache_n_op_pend);
52573 fscache_start_operations(object);
52574 } else {
52575 ASSERTCMP(object->n_in_progress, ==, 0);
52576 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52577 object->n_exclusive++; /* reads and writes must wait */
52578 atomic_inc(&op->usage);
52579 list_add_tail(&op->pend_link, &object->pending_ops);
52580 - fscache_stat(&fscache_n_op_pend);
52581 + fscache_stat_unchecked(&fscache_n_op_pend);
52582 ret = 0;
52583 } else {
52584 /* If we're in any other state, there must have been an I/O
52585 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52586 if (object->n_exclusive > 0) {
52587 atomic_inc(&op->usage);
52588 list_add_tail(&op->pend_link, &object->pending_ops);
52589 - fscache_stat(&fscache_n_op_pend);
52590 + fscache_stat_unchecked(&fscache_n_op_pend);
52591 } else if (!list_empty(&object->pending_ops)) {
52592 atomic_inc(&op->usage);
52593 list_add_tail(&op->pend_link, &object->pending_ops);
52594 - fscache_stat(&fscache_n_op_pend);
52595 + fscache_stat_unchecked(&fscache_n_op_pend);
52596 fscache_start_operations(object);
52597 } else {
52598 ASSERTCMP(object->n_exclusive, ==, 0);
52599 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52600 object->n_ops++;
52601 atomic_inc(&op->usage);
52602 list_add_tail(&op->pend_link, &object->pending_ops);
52603 - fscache_stat(&fscache_n_op_pend);
52604 + fscache_stat_unchecked(&fscache_n_op_pend);
52605 ret = 0;
52606 } else if (object->state == FSCACHE_OBJECT_DYING ||
52607 object->state == FSCACHE_OBJECT_LC_DYING ||
52608 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52609 - fscache_stat(&fscache_n_op_rejected);
52610 + fscache_stat_unchecked(&fscache_n_op_rejected);
52611 op->state = FSCACHE_OP_ST_CANCELLED;
52612 ret = -ENOBUFS;
52613 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52614 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52615 ret = -EBUSY;
52616 if (op->state == FSCACHE_OP_ST_PENDING) {
52617 ASSERT(!list_empty(&op->pend_link));
52618 - fscache_stat(&fscache_n_op_cancelled);
52619 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52620 list_del_init(&op->pend_link);
52621 if (do_cancel)
52622 do_cancel(op);
52623 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52624 while (!list_empty(&object->pending_ops)) {
52625 op = list_entry(object->pending_ops.next,
52626 struct fscache_operation, pend_link);
52627 - fscache_stat(&fscache_n_op_cancelled);
52628 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52629 list_del_init(&op->pend_link);
52630
52631 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52632 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52633 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52634 op->state = FSCACHE_OP_ST_DEAD;
52635
52636 - fscache_stat(&fscache_n_op_release);
52637 + fscache_stat_unchecked(&fscache_n_op_release);
52638
52639 if (op->release) {
52640 op->release(op);
52641 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52642 * lock, and defer it otherwise */
52643 if (!spin_trylock(&object->lock)) {
52644 _debug("defer put");
52645 - fscache_stat(&fscache_n_op_deferred_release);
52646 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52647
52648 cache = object->cache;
52649 spin_lock(&cache->op_gc_list_lock);
52650 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52651
52652 _debug("GC DEFERRED REL OBJ%x OP%x",
52653 object->debug_id, op->debug_id);
52654 - fscache_stat(&fscache_n_op_gc);
52655 + fscache_stat_unchecked(&fscache_n_op_gc);
52656
52657 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52658 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52659 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52660 index ff000e5..c44ec6d 100644
52661 --- a/fs/fscache/page.c
52662 +++ b/fs/fscache/page.c
52663 @@ -61,7 +61,7 @@ try_again:
52664 val = radix_tree_lookup(&cookie->stores, page->index);
52665 if (!val) {
52666 rcu_read_unlock();
52667 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52668 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52669 __fscache_uncache_page(cookie, page);
52670 return true;
52671 }
52672 @@ -91,11 +91,11 @@ try_again:
52673 spin_unlock(&cookie->stores_lock);
52674
52675 if (xpage) {
52676 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52677 - fscache_stat(&fscache_n_store_radix_deletes);
52678 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52679 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52680 ASSERTCMP(xpage, ==, page);
52681 } else {
52682 - fscache_stat(&fscache_n_store_vmscan_gone);
52683 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52684 }
52685
52686 wake_up_bit(&cookie->flags, 0);
52687 @@ -110,11 +110,11 @@ page_busy:
52688 * sleeping on memory allocation, so we may need to impose a timeout
52689 * too. */
52690 if (!(gfp & __GFP_WAIT)) {
52691 - fscache_stat(&fscache_n_store_vmscan_busy);
52692 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52693 return false;
52694 }
52695
52696 - fscache_stat(&fscache_n_store_vmscan_wait);
52697 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52698 __fscache_wait_on_page_write(cookie, page);
52699 gfp &= ~__GFP_WAIT;
52700 goto try_again;
52701 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52702 FSCACHE_COOKIE_STORING_TAG);
52703 if (!radix_tree_tag_get(&cookie->stores, page->index,
52704 FSCACHE_COOKIE_PENDING_TAG)) {
52705 - fscache_stat(&fscache_n_store_radix_deletes);
52706 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52707 xpage = radix_tree_delete(&cookie->stores, page->index);
52708 }
52709 spin_unlock(&cookie->stores_lock);
52710 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52711
52712 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52713
52714 - fscache_stat(&fscache_n_attr_changed_calls);
52715 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52716
52717 if (fscache_object_is_active(object)) {
52718 fscache_stat(&fscache_n_cop_attr_changed);
52719 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52720
52721 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52722
52723 - fscache_stat(&fscache_n_attr_changed);
52724 + fscache_stat_unchecked(&fscache_n_attr_changed);
52725
52726 op = kzalloc(sizeof(*op), GFP_KERNEL);
52727 if (!op) {
52728 - fscache_stat(&fscache_n_attr_changed_nomem);
52729 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52730 _leave(" = -ENOMEM");
52731 return -ENOMEM;
52732 }
52733 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52734 if (fscache_submit_exclusive_op(object, op) < 0)
52735 goto nobufs;
52736 spin_unlock(&cookie->lock);
52737 - fscache_stat(&fscache_n_attr_changed_ok);
52738 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52739 fscache_put_operation(op);
52740 _leave(" = 0");
52741 return 0;
52742 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52743 nobufs:
52744 spin_unlock(&cookie->lock);
52745 kfree(op);
52746 - fscache_stat(&fscache_n_attr_changed_nobufs);
52747 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52748 _leave(" = %d", -ENOBUFS);
52749 return -ENOBUFS;
52750 }
52751 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52752 /* allocate a retrieval operation and attempt to submit it */
52753 op = kzalloc(sizeof(*op), GFP_NOIO);
52754 if (!op) {
52755 - fscache_stat(&fscache_n_retrievals_nomem);
52756 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52757 return NULL;
52758 }
52759
52760 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52761 return 0;
52762 }
52763
52764 - fscache_stat(&fscache_n_retrievals_wait);
52765 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52766
52767 jif = jiffies;
52768 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52769 fscache_wait_bit_interruptible,
52770 TASK_INTERRUPTIBLE) != 0) {
52771 - fscache_stat(&fscache_n_retrievals_intr);
52772 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52773 _leave(" = -ERESTARTSYS");
52774 return -ERESTARTSYS;
52775 }
52776 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52777 */
52778 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52779 struct fscache_retrieval *op,
52780 - atomic_t *stat_op_waits,
52781 - atomic_t *stat_object_dead)
52782 + atomic_unchecked_t *stat_op_waits,
52783 + atomic_unchecked_t *stat_object_dead)
52784 {
52785 int ret;
52786
52787 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52788 goto check_if_dead;
52789
52790 _debug(">>> WT");
52791 - fscache_stat(stat_op_waits);
52792 + fscache_stat_unchecked(stat_op_waits);
52793 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52794 fscache_wait_bit_interruptible,
52795 TASK_INTERRUPTIBLE) != 0) {
52796 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52797
52798 check_if_dead:
52799 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52800 - fscache_stat(stat_object_dead);
52801 + fscache_stat_unchecked(stat_object_dead);
52802 _leave(" = -ENOBUFS [cancelled]");
52803 return -ENOBUFS;
52804 }
52805 if (unlikely(fscache_object_is_dead(object))) {
52806 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52807 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52808 - fscache_stat(stat_object_dead);
52809 + fscache_stat_unchecked(stat_object_dead);
52810 return -ENOBUFS;
52811 }
52812 return 0;
52813 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52814
52815 _enter("%p,%p,,,", cookie, page);
52816
52817 - fscache_stat(&fscache_n_retrievals);
52818 + fscache_stat_unchecked(&fscache_n_retrievals);
52819
52820 if (hlist_empty(&cookie->backing_objects))
52821 goto nobufs;
52822 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52823 goto nobufs_unlock_dec;
52824 spin_unlock(&cookie->lock);
52825
52826 - fscache_stat(&fscache_n_retrieval_ops);
52827 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52828
52829 /* pin the netfs read context in case we need to do the actual netfs
52830 * read because we've encountered a cache read failure */
52831 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52832
52833 error:
52834 if (ret == -ENOMEM)
52835 - fscache_stat(&fscache_n_retrievals_nomem);
52836 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52837 else if (ret == -ERESTARTSYS)
52838 - fscache_stat(&fscache_n_retrievals_intr);
52839 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52840 else if (ret == -ENODATA)
52841 - fscache_stat(&fscache_n_retrievals_nodata);
52842 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52843 else if (ret < 0)
52844 - fscache_stat(&fscache_n_retrievals_nobufs);
52845 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52846 else
52847 - fscache_stat(&fscache_n_retrievals_ok);
52848 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52849
52850 fscache_put_retrieval(op);
52851 _leave(" = %d", ret);
52852 @@ -467,7 +467,7 @@ nobufs_unlock:
52853 spin_unlock(&cookie->lock);
52854 kfree(op);
52855 nobufs:
52856 - fscache_stat(&fscache_n_retrievals_nobufs);
52857 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52858 _leave(" = -ENOBUFS");
52859 return -ENOBUFS;
52860 }
52861 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52862
52863 _enter("%p,,%d,,,", cookie, *nr_pages);
52864
52865 - fscache_stat(&fscache_n_retrievals);
52866 + fscache_stat_unchecked(&fscache_n_retrievals);
52867
52868 if (hlist_empty(&cookie->backing_objects))
52869 goto nobufs;
52870 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52871 goto nobufs_unlock_dec;
52872 spin_unlock(&cookie->lock);
52873
52874 - fscache_stat(&fscache_n_retrieval_ops);
52875 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52876
52877 /* pin the netfs read context in case we need to do the actual netfs
52878 * read because we've encountered a cache read failure */
52879 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52880
52881 error:
52882 if (ret == -ENOMEM)
52883 - fscache_stat(&fscache_n_retrievals_nomem);
52884 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52885 else if (ret == -ERESTARTSYS)
52886 - fscache_stat(&fscache_n_retrievals_intr);
52887 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52888 else if (ret == -ENODATA)
52889 - fscache_stat(&fscache_n_retrievals_nodata);
52890 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52891 else if (ret < 0)
52892 - fscache_stat(&fscache_n_retrievals_nobufs);
52893 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52894 else
52895 - fscache_stat(&fscache_n_retrievals_ok);
52896 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52897
52898 fscache_put_retrieval(op);
52899 _leave(" = %d", ret);
52900 @@ -591,7 +591,7 @@ nobufs_unlock:
52901 spin_unlock(&cookie->lock);
52902 kfree(op);
52903 nobufs:
52904 - fscache_stat(&fscache_n_retrievals_nobufs);
52905 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52906 _leave(" = -ENOBUFS");
52907 return -ENOBUFS;
52908 }
52909 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52910
52911 _enter("%p,%p,,,", cookie, page);
52912
52913 - fscache_stat(&fscache_n_allocs);
52914 + fscache_stat_unchecked(&fscache_n_allocs);
52915
52916 if (hlist_empty(&cookie->backing_objects))
52917 goto nobufs;
52918 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52919 goto nobufs_unlock;
52920 spin_unlock(&cookie->lock);
52921
52922 - fscache_stat(&fscache_n_alloc_ops);
52923 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52924
52925 ret = fscache_wait_for_retrieval_activation(
52926 object, op,
52927 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52928
52929 error:
52930 if (ret == -ERESTARTSYS)
52931 - fscache_stat(&fscache_n_allocs_intr);
52932 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52933 else if (ret < 0)
52934 - fscache_stat(&fscache_n_allocs_nobufs);
52935 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52936 else
52937 - fscache_stat(&fscache_n_allocs_ok);
52938 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52939
52940 fscache_put_retrieval(op);
52941 _leave(" = %d", ret);
52942 @@ -677,7 +677,7 @@ nobufs_unlock:
52943 spin_unlock(&cookie->lock);
52944 kfree(op);
52945 nobufs:
52946 - fscache_stat(&fscache_n_allocs_nobufs);
52947 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52948 _leave(" = -ENOBUFS");
52949 return -ENOBUFS;
52950 }
52951 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52952
52953 spin_lock(&cookie->stores_lock);
52954
52955 - fscache_stat(&fscache_n_store_calls);
52956 + fscache_stat_unchecked(&fscache_n_store_calls);
52957
52958 /* find a page to store */
52959 page = NULL;
52960 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52961 page = results[0];
52962 _debug("gang %d [%lx]", n, page->index);
52963 if (page->index > op->store_limit) {
52964 - fscache_stat(&fscache_n_store_pages_over_limit);
52965 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52966 goto superseded;
52967 }
52968
52969 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52970 spin_unlock(&cookie->stores_lock);
52971 spin_unlock(&object->lock);
52972
52973 - fscache_stat(&fscache_n_store_pages);
52974 + fscache_stat_unchecked(&fscache_n_store_pages);
52975 fscache_stat(&fscache_n_cop_write_page);
52976 ret = object->cache->ops->write_page(op, page);
52977 fscache_stat_d(&fscache_n_cop_write_page);
52978 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52979 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52980 ASSERT(PageFsCache(page));
52981
52982 - fscache_stat(&fscache_n_stores);
52983 + fscache_stat_unchecked(&fscache_n_stores);
52984
52985 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52986 _leave(" = -ENOBUFS [invalidating]");
52987 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52988 spin_unlock(&cookie->stores_lock);
52989 spin_unlock(&object->lock);
52990
52991 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52992 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52993 op->store_limit = object->store_limit;
52994
52995 if (fscache_submit_op(object, &op->op) < 0)
52996 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52997
52998 spin_unlock(&cookie->lock);
52999 radix_tree_preload_end();
53000 - fscache_stat(&fscache_n_store_ops);
53001 - fscache_stat(&fscache_n_stores_ok);
53002 + fscache_stat_unchecked(&fscache_n_store_ops);
53003 + fscache_stat_unchecked(&fscache_n_stores_ok);
53004
53005 /* the work queue now carries its own ref on the object */
53006 fscache_put_operation(&op->op);
53007 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53008 return 0;
53009
53010 already_queued:
53011 - fscache_stat(&fscache_n_stores_again);
53012 + fscache_stat_unchecked(&fscache_n_stores_again);
53013 already_pending:
53014 spin_unlock(&cookie->stores_lock);
53015 spin_unlock(&object->lock);
53016 spin_unlock(&cookie->lock);
53017 radix_tree_preload_end();
53018 kfree(op);
53019 - fscache_stat(&fscache_n_stores_ok);
53020 + fscache_stat_unchecked(&fscache_n_stores_ok);
53021 _leave(" = 0");
53022 return 0;
53023
53024 @@ -959,14 +959,14 @@ nobufs:
53025 spin_unlock(&cookie->lock);
53026 radix_tree_preload_end();
53027 kfree(op);
53028 - fscache_stat(&fscache_n_stores_nobufs);
53029 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
53030 _leave(" = -ENOBUFS");
53031 return -ENOBUFS;
53032
53033 nomem_free:
53034 kfree(op);
53035 nomem:
53036 - fscache_stat(&fscache_n_stores_oom);
53037 + fscache_stat_unchecked(&fscache_n_stores_oom);
53038 _leave(" = -ENOMEM");
53039 return -ENOMEM;
53040 }
53041 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
53042 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53043 ASSERTCMP(page, !=, NULL);
53044
53045 - fscache_stat(&fscache_n_uncaches);
53046 + fscache_stat_unchecked(&fscache_n_uncaches);
53047
53048 /* cache withdrawal may beat us to it */
53049 if (!PageFsCache(page))
53050 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
53051 struct fscache_cookie *cookie = op->op.object->cookie;
53052
53053 #ifdef CONFIG_FSCACHE_STATS
53054 - atomic_inc(&fscache_n_marks);
53055 + atomic_inc_unchecked(&fscache_n_marks);
53056 #endif
53057
53058 _debug("- mark %p{%lx}", page, page->index);
53059 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
53060 index 40d13c7..ddf52b9 100644
53061 --- a/fs/fscache/stats.c
53062 +++ b/fs/fscache/stats.c
53063 @@ -18,99 +18,99 @@
53064 /*
53065 * operation counters
53066 */
53067 -atomic_t fscache_n_op_pend;
53068 -atomic_t fscache_n_op_run;
53069 -atomic_t fscache_n_op_enqueue;
53070 -atomic_t fscache_n_op_requeue;
53071 -atomic_t fscache_n_op_deferred_release;
53072 -atomic_t fscache_n_op_release;
53073 -atomic_t fscache_n_op_gc;
53074 -atomic_t fscache_n_op_cancelled;
53075 -atomic_t fscache_n_op_rejected;
53076 +atomic_unchecked_t fscache_n_op_pend;
53077 +atomic_unchecked_t fscache_n_op_run;
53078 +atomic_unchecked_t fscache_n_op_enqueue;
53079 +atomic_unchecked_t fscache_n_op_requeue;
53080 +atomic_unchecked_t fscache_n_op_deferred_release;
53081 +atomic_unchecked_t fscache_n_op_release;
53082 +atomic_unchecked_t fscache_n_op_gc;
53083 +atomic_unchecked_t fscache_n_op_cancelled;
53084 +atomic_unchecked_t fscache_n_op_rejected;
53085
53086 -atomic_t fscache_n_attr_changed;
53087 -atomic_t fscache_n_attr_changed_ok;
53088 -atomic_t fscache_n_attr_changed_nobufs;
53089 -atomic_t fscache_n_attr_changed_nomem;
53090 -atomic_t fscache_n_attr_changed_calls;
53091 +atomic_unchecked_t fscache_n_attr_changed;
53092 +atomic_unchecked_t fscache_n_attr_changed_ok;
53093 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53094 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53095 +atomic_unchecked_t fscache_n_attr_changed_calls;
53096
53097 -atomic_t fscache_n_allocs;
53098 -atomic_t fscache_n_allocs_ok;
53099 -atomic_t fscache_n_allocs_wait;
53100 -atomic_t fscache_n_allocs_nobufs;
53101 -atomic_t fscache_n_allocs_intr;
53102 -atomic_t fscache_n_allocs_object_dead;
53103 -atomic_t fscache_n_alloc_ops;
53104 -atomic_t fscache_n_alloc_op_waits;
53105 +atomic_unchecked_t fscache_n_allocs;
53106 +atomic_unchecked_t fscache_n_allocs_ok;
53107 +atomic_unchecked_t fscache_n_allocs_wait;
53108 +atomic_unchecked_t fscache_n_allocs_nobufs;
53109 +atomic_unchecked_t fscache_n_allocs_intr;
53110 +atomic_unchecked_t fscache_n_allocs_object_dead;
53111 +atomic_unchecked_t fscache_n_alloc_ops;
53112 +atomic_unchecked_t fscache_n_alloc_op_waits;
53113
53114 -atomic_t fscache_n_retrievals;
53115 -atomic_t fscache_n_retrievals_ok;
53116 -atomic_t fscache_n_retrievals_wait;
53117 -atomic_t fscache_n_retrievals_nodata;
53118 -atomic_t fscache_n_retrievals_nobufs;
53119 -atomic_t fscache_n_retrievals_intr;
53120 -atomic_t fscache_n_retrievals_nomem;
53121 -atomic_t fscache_n_retrievals_object_dead;
53122 -atomic_t fscache_n_retrieval_ops;
53123 -atomic_t fscache_n_retrieval_op_waits;
53124 +atomic_unchecked_t fscache_n_retrievals;
53125 +atomic_unchecked_t fscache_n_retrievals_ok;
53126 +atomic_unchecked_t fscache_n_retrievals_wait;
53127 +atomic_unchecked_t fscache_n_retrievals_nodata;
53128 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53129 +atomic_unchecked_t fscache_n_retrievals_intr;
53130 +atomic_unchecked_t fscache_n_retrievals_nomem;
53131 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53132 +atomic_unchecked_t fscache_n_retrieval_ops;
53133 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53134
53135 -atomic_t fscache_n_stores;
53136 -atomic_t fscache_n_stores_ok;
53137 -atomic_t fscache_n_stores_again;
53138 -atomic_t fscache_n_stores_nobufs;
53139 -atomic_t fscache_n_stores_oom;
53140 -atomic_t fscache_n_store_ops;
53141 -atomic_t fscache_n_store_calls;
53142 -atomic_t fscache_n_store_pages;
53143 -atomic_t fscache_n_store_radix_deletes;
53144 -atomic_t fscache_n_store_pages_over_limit;
53145 +atomic_unchecked_t fscache_n_stores;
53146 +atomic_unchecked_t fscache_n_stores_ok;
53147 +atomic_unchecked_t fscache_n_stores_again;
53148 +atomic_unchecked_t fscache_n_stores_nobufs;
53149 +atomic_unchecked_t fscache_n_stores_oom;
53150 +atomic_unchecked_t fscache_n_store_ops;
53151 +atomic_unchecked_t fscache_n_store_calls;
53152 +atomic_unchecked_t fscache_n_store_pages;
53153 +atomic_unchecked_t fscache_n_store_radix_deletes;
53154 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53155
53156 -atomic_t fscache_n_store_vmscan_not_storing;
53157 -atomic_t fscache_n_store_vmscan_gone;
53158 -atomic_t fscache_n_store_vmscan_busy;
53159 -atomic_t fscache_n_store_vmscan_cancelled;
53160 -atomic_t fscache_n_store_vmscan_wait;
53161 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53162 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53163 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53164 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53165 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53166
53167 -atomic_t fscache_n_marks;
53168 -atomic_t fscache_n_uncaches;
53169 +atomic_unchecked_t fscache_n_marks;
53170 +atomic_unchecked_t fscache_n_uncaches;
53171
53172 -atomic_t fscache_n_acquires;
53173 -atomic_t fscache_n_acquires_null;
53174 -atomic_t fscache_n_acquires_no_cache;
53175 -atomic_t fscache_n_acquires_ok;
53176 -atomic_t fscache_n_acquires_nobufs;
53177 -atomic_t fscache_n_acquires_oom;
53178 +atomic_unchecked_t fscache_n_acquires;
53179 +atomic_unchecked_t fscache_n_acquires_null;
53180 +atomic_unchecked_t fscache_n_acquires_no_cache;
53181 +atomic_unchecked_t fscache_n_acquires_ok;
53182 +atomic_unchecked_t fscache_n_acquires_nobufs;
53183 +atomic_unchecked_t fscache_n_acquires_oom;
53184
53185 -atomic_t fscache_n_invalidates;
53186 -atomic_t fscache_n_invalidates_run;
53187 +atomic_unchecked_t fscache_n_invalidates;
53188 +atomic_unchecked_t fscache_n_invalidates_run;
53189
53190 -atomic_t fscache_n_updates;
53191 -atomic_t fscache_n_updates_null;
53192 -atomic_t fscache_n_updates_run;
53193 +atomic_unchecked_t fscache_n_updates;
53194 +atomic_unchecked_t fscache_n_updates_null;
53195 +atomic_unchecked_t fscache_n_updates_run;
53196
53197 -atomic_t fscache_n_relinquishes;
53198 -atomic_t fscache_n_relinquishes_null;
53199 -atomic_t fscache_n_relinquishes_waitcrt;
53200 -atomic_t fscache_n_relinquishes_retire;
53201 +atomic_unchecked_t fscache_n_relinquishes;
53202 +atomic_unchecked_t fscache_n_relinquishes_null;
53203 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53204 +atomic_unchecked_t fscache_n_relinquishes_retire;
53205
53206 -atomic_t fscache_n_cookie_index;
53207 -atomic_t fscache_n_cookie_data;
53208 -atomic_t fscache_n_cookie_special;
53209 +atomic_unchecked_t fscache_n_cookie_index;
53210 +atomic_unchecked_t fscache_n_cookie_data;
53211 +atomic_unchecked_t fscache_n_cookie_special;
53212
53213 -atomic_t fscache_n_object_alloc;
53214 -atomic_t fscache_n_object_no_alloc;
53215 -atomic_t fscache_n_object_lookups;
53216 -atomic_t fscache_n_object_lookups_negative;
53217 -atomic_t fscache_n_object_lookups_positive;
53218 -atomic_t fscache_n_object_lookups_timed_out;
53219 -atomic_t fscache_n_object_created;
53220 -atomic_t fscache_n_object_avail;
53221 -atomic_t fscache_n_object_dead;
53222 +atomic_unchecked_t fscache_n_object_alloc;
53223 +atomic_unchecked_t fscache_n_object_no_alloc;
53224 +atomic_unchecked_t fscache_n_object_lookups;
53225 +atomic_unchecked_t fscache_n_object_lookups_negative;
53226 +atomic_unchecked_t fscache_n_object_lookups_positive;
53227 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53228 +atomic_unchecked_t fscache_n_object_created;
53229 +atomic_unchecked_t fscache_n_object_avail;
53230 +atomic_unchecked_t fscache_n_object_dead;
53231
53232 -atomic_t fscache_n_checkaux_none;
53233 -atomic_t fscache_n_checkaux_okay;
53234 -atomic_t fscache_n_checkaux_update;
53235 -atomic_t fscache_n_checkaux_obsolete;
53236 +atomic_unchecked_t fscache_n_checkaux_none;
53237 +atomic_unchecked_t fscache_n_checkaux_okay;
53238 +atomic_unchecked_t fscache_n_checkaux_update;
53239 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53240
53241 atomic_t fscache_n_cop_alloc_object;
53242 atomic_t fscache_n_cop_lookup_object;
53243 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53244 seq_puts(m, "FS-Cache statistics\n");
53245
53246 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53247 - atomic_read(&fscache_n_cookie_index),
53248 - atomic_read(&fscache_n_cookie_data),
53249 - atomic_read(&fscache_n_cookie_special));
53250 + atomic_read_unchecked(&fscache_n_cookie_index),
53251 + atomic_read_unchecked(&fscache_n_cookie_data),
53252 + atomic_read_unchecked(&fscache_n_cookie_special));
53253
53254 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53255 - atomic_read(&fscache_n_object_alloc),
53256 - atomic_read(&fscache_n_object_no_alloc),
53257 - atomic_read(&fscache_n_object_avail),
53258 - atomic_read(&fscache_n_object_dead));
53259 + atomic_read_unchecked(&fscache_n_object_alloc),
53260 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53261 + atomic_read_unchecked(&fscache_n_object_avail),
53262 + atomic_read_unchecked(&fscache_n_object_dead));
53263 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53264 - atomic_read(&fscache_n_checkaux_none),
53265 - atomic_read(&fscache_n_checkaux_okay),
53266 - atomic_read(&fscache_n_checkaux_update),
53267 - atomic_read(&fscache_n_checkaux_obsolete));
53268 + atomic_read_unchecked(&fscache_n_checkaux_none),
53269 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53270 + atomic_read_unchecked(&fscache_n_checkaux_update),
53271 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53272
53273 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53274 - atomic_read(&fscache_n_marks),
53275 - atomic_read(&fscache_n_uncaches));
53276 + atomic_read_unchecked(&fscache_n_marks),
53277 + atomic_read_unchecked(&fscache_n_uncaches));
53278
53279 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53280 " oom=%u\n",
53281 - atomic_read(&fscache_n_acquires),
53282 - atomic_read(&fscache_n_acquires_null),
53283 - atomic_read(&fscache_n_acquires_no_cache),
53284 - atomic_read(&fscache_n_acquires_ok),
53285 - atomic_read(&fscache_n_acquires_nobufs),
53286 - atomic_read(&fscache_n_acquires_oom));
53287 + atomic_read_unchecked(&fscache_n_acquires),
53288 + atomic_read_unchecked(&fscache_n_acquires_null),
53289 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53290 + atomic_read_unchecked(&fscache_n_acquires_ok),
53291 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53292 + atomic_read_unchecked(&fscache_n_acquires_oom));
53293
53294 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53295 - atomic_read(&fscache_n_object_lookups),
53296 - atomic_read(&fscache_n_object_lookups_negative),
53297 - atomic_read(&fscache_n_object_lookups_positive),
53298 - atomic_read(&fscache_n_object_created),
53299 - atomic_read(&fscache_n_object_lookups_timed_out));
53300 + atomic_read_unchecked(&fscache_n_object_lookups),
53301 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53302 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53303 + atomic_read_unchecked(&fscache_n_object_created),
53304 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53305
53306 seq_printf(m, "Invals : n=%u run=%u\n",
53307 - atomic_read(&fscache_n_invalidates),
53308 - atomic_read(&fscache_n_invalidates_run));
53309 + atomic_read_unchecked(&fscache_n_invalidates),
53310 + atomic_read_unchecked(&fscache_n_invalidates_run));
53311
53312 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53313 - atomic_read(&fscache_n_updates),
53314 - atomic_read(&fscache_n_updates_null),
53315 - atomic_read(&fscache_n_updates_run));
53316 + atomic_read_unchecked(&fscache_n_updates),
53317 + atomic_read_unchecked(&fscache_n_updates_null),
53318 + atomic_read_unchecked(&fscache_n_updates_run));
53319
53320 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53321 - atomic_read(&fscache_n_relinquishes),
53322 - atomic_read(&fscache_n_relinquishes_null),
53323 - atomic_read(&fscache_n_relinquishes_waitcrt),
53324 - atomic_read(&fscache_n_relinquishes_retire));
53325 + atomic_read_unchecked(&fscache_n_relinquishes),
53326 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53327 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53328 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53329
53330 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53331 - atomic_read(&fscache_n_attr_changed),
53332 - atomic_read(&fscache_n_attr_changed_ok),
53333 - atomic_read(&fscache_n_attr_changed_nobufs),
53334 - atomic_read(&fscache_n_attr_changed_nomem),
53335 - atomic_read(&fscache_n_attr_changed_calls));
53336 + atomic_read_unchecked(&fscache_n_attr_changed),
53337 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53338 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53339 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53340 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53341
53342 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53343 - atomic_read(&fscache_n_allocs),
53344 - atomic_read(&fscache_n_allocs_ok),
53345 - atomic_read(&fscache_n_allocs_wait),
53346 - atomic_read(&fscache_n_allocs_nobufs),
53347 - atomic_read(&fscache_n_allocs_intr));
53348 + atomic_read_unchecked(&fscache_n_allocs),
53349 + atomic_read_unchecked(&fscache_n_allocs_ok),
53350 + atomic_read_unchecked(&fscache_n_allocs_wait),
53351 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53352 + atomic_read_unchecked(&fscache_n_allocs_intr));
53353 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53354 - atomic_read(&fscache_n_alloc_ops),
53355 - atomic_read(&fscache_n_alloc_op_waits),
53356 - atomic_read(&fscache_n_allocs_object_dead));
53357 + atomic_read_unchecked(&fscache_n_alloc_ops),
53358 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53359 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53360
53361 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53362 " int=%u oom=%u\n",
53363 - atomic_read(&fscache_n_retrievals),
53364 - atomic_read(&fscache_n_retrievals_ok),
53365 - atomic_read(&fscache_n_retrievals_wait),
53366 - atomic_read(&fscache_n_retrievals_nodata),
53367 - atomic_read(&fscache_n_retrievals_nobufs),
53368 - atomic_read(&fscache_n_retrievals_intr),
53369 - atomic_read(&fscache_n_retrievals_nomem));
53370 + atomic_read_unchecked(&fscache_n_retrievals),
53371 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53372 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53373 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53374 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53375 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53376 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53377 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53378 - atomic_read(&fscache_n_retrieval_ops),
53379 - atomic_read(&fscache_n_retrieval_op_waits),
53380 - atomic_read(&fscache_n_retrievals_object_dead));
53381 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53382 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53383 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53384
53385 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53386 - atomic_read(&fscache_n_stores),
53387 - atomic_read(&fscache_n_stores_ok),
53388 - atomic_read(&fscache_n_stores_again),
53389 - atomic_read(&fscache_n_stores_nobufs),
53390 - atomic_read(&fscache_n_stores_oom));
53391 + atomic_read_unchecked(&fscache_n_stores),
53392 + atomic_read_unchecked(&fscache_n_stores_ok),
53393 + atomic_read_unchecked(&fscache_n_stores_again),
53394 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53395 + atomic_read_unchecked(&fscache_n_stores_oom));
53396 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53397 - atomic_read(&fscache_n_store_ops),
53398 - atomic_read(&fscache_n_store_calls),
53399 - atomic_read(&fscache_n_store_pages),
53400 - atomic_read(&fscache_n_store_radix_deletes),
53401 - atomic_read(&fscache_n_store_pages_over_limit));
53402 + atomic_read_unchecked(&fscache_n_store_ops),
53403 + atomic_read_unchecked(&fscache_n_store_calls),
53404 + atomic_read_unchecked(&fscache_n_store_pages),
53405 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53406 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53407
53408 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53409 - atomic_read(&fscache_n_store_vmscan_not_storing),
53410 - atomic_read(&fscache_n_store_vmscan_gone),
53411 - atomic_read(&fscache_n_store_vmscan_busy),
53412 - atomic_read(&fscache_n_store_vmscan_cancelled),
53413 - atomic_read(&fscache_n_store_vmscan_wait));
53414 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53415 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53416 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53417 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53418 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53419
53420 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53421 - atomic_read(&fscache_n_op_pend),
53422 - atomic_read(&fscache_n_op_run),
53423 - atomic_read(&fscache_n_op_enqueue),
53424 - atomic_read(&fscache_n_op_cancelled),
53425 - atomic_read(&fscache_n_op_rejected));
53426 + atomic_read_unchecked(&fscache_n_op_pend),
53427 + atomic_read_unchecked(&fscache_n_op_run),
53428 + atomic_read_unchecked(&fscache_n_op_enqueue),
53429 + atomic_read_unchecked(&fscache_n_op_cancelled),
53430 + atomic_read_unchecked(&fscache_n_op_rejected));
53431 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53432 - atomic_read(&fscache_n_op_deferred_release),
53433 - atomic_read(&fscache_n_op_release),
53434 - atomic_read(&fscache_n_op_gc));
53435 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53436 + atomic_read_unchecked(&fscache_n_op_release),
53437 + atomic_read_unchecked(&fscache_n_op_gc));
53438
53439 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53440 atomic_read(&fscache_n_cop_alloc_object),
53441 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53442 index aef34b1..59bfd7b 100644
53443 --- a/fs/fuse/cuse.c
53444 +++ b/fs/fuse/cuse.c
53445 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
53446 INIT_LIST_HEAD(&cuse_conntbl[i]);
53447
53448 /* inherit and extend fuse_dev_operations */
53449 - cuse_channel_fops = fuse_dev_operations;
53450 - cuse_channel_fops.owner = THIS_MODULE;
53451 - cuse_channel_fops.open = cuse_channel_open;
53452 - cuse_channel_fops.release = cuse_channel_release;
53453 + pax_open_kernel();
53454 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53455 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53456 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53457 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53458 + pax_close_kernel();
53459
53460 cuse_class = class_create(THIS_MODULE, "cuse");
53461 if (IS_ERR(cuse_class))
53462 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53463 index 1d55f94..088da65 100644
53464 --- a/fs/fuse/dev.c
53465 +++ b/fs/fuse/dev.c
53466 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53467 ret = 0;
53468 pipe_lock(pipe);
53469
53470 - if (!pipe->readers) {
53471 + if (!atomic_read(&pipe->readers)) {
53472 send_sig(SIGPIPE, current, 0);
53473 if (!ret)
53474 ret = -EPIPE;
53475 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53476 page_nr++;
53477 ret += buf->len;
53478
53479 - if (pipe->files)
53480 + if (atomic_read(&pipe->files))
53481 do_wakeup = 1;
53482 }
53483
53484 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53485 index 5b12746..b481b03 100644
53486 --- a/fs/fuse/dir.c
53487 +++ b/fs/fuse/dir.c
53488 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
53489 return link;
53490 }
53491
53492 -static void free_link(char *link)
53493 +static void free_link(const char *link)
53494 {
53495 if (!IS_ERR(link))
53496 free_page((unsigned long) link);
53497 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53498 index 62b484e..0f9a140 100644
53499 --- a/fs/gfs2/inode.c
53500 +++ b/fs/gfs2/inode.c
53501 @@ -1441,7 +1441,7 @@ out:
53502
53503 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53504 {
53505 - char *s = nd_get_link(nd);
53506 + const char *s = nd_get_link(nd);
53507 if (!IS_ERR(s))
53508 kfree(s);
53509 }
53510 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53511 index a3f868a..bb308ae 100644
53512 --- a/fs/hugetlbfs/inode.c
53513 +++ b/fs/hugetlbfs/inode.c
53514 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53515 struct mm_struct *mm = current->mm;
53516 struct vm_area_struct *vma;
53517 struct hstate *h = hstate_file(file);
53518 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53519 struct vm_unmapped_area_info info;
53520
53521 if (len & ~huge_page_mask(h))
53522 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53523 return addr;
53524 }
53525
53526 +#ifdef CONFIG_PAX_RANDMMAP
53527 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53528 +#endif
53529 +
53530 if (addr) {
53531 addr = ALIGN(addr, huge_page_size(h));
53532 vma = find_vma(mm, addr);
53533 - if (TASK_SIZE - len >= addr &&
53534 - (!vma || addr + len <= vma->vm_start))
53535 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53536 return addr;
53537 }
53538
53539 info.flags = 0;
53540 info.length = len;
53541 info.low_limit = TASK_UNMAPPED_BASE;
53542 +
53543 +#ifdef CONFIG_PAX_RANDMMAP
53544 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53545 + info.low_limit += mm->delta_mmap;
53546 +#endif
53547 +
53548 info.high_limit = TASK_SIZE;
53549 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53550 info.align_offset = 0;
53551 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53552 };
53553 MODULE_ALIAS_FS("hugetlbfs");
53554
53555 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53556 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53557
53558 static int can_do_hugetlb_shm(void)
53559 {
53560 diff --git a/fs/inode.c b/fs/inode.c
53561 index 00d5fc3..98ce7d7 100644
53562 --- a/fs/inode.c
53563 +++ b/fs/inode.c
53564 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
53565
53566 #ifdef CONFIG_SMP
53567 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53568 - static atomic_t shared_last_ino;
53569 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53570 + static atomic_unchecked_t shared_last_ino;
53571 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53572
53573 res = next - LAST_INO_BATCH;
53574 }
53575 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53576 index 4a6cf28..d3a29d3 100644
53577 --- a/fs/jffs2/erase.c
53578 +++ b/fs/jffs2/erase.c
53579 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53580 struct jffs2_unknown_node marker = {
53581 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53582 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53583 - .totlen = cpu_to_je32(c->cleanmarker_size)
53584 + .totlen = cpu_to_je32(c->cleanmarker_size),
53585 + .hdr_crc = cpu_to_je32(0)
53586 };
53587
53588 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53589 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53590 index a6597d6..41b30ec 100644
53591 --- a/fs/jffs2/wbuf.c
53592 +++ b/fs/jffs2/wbuf.c
53593 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53594 {
53595 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53596 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53597 - .totlen = constant_cpu_to_je32(8)
53598 + .totlen = constant_cpu_to_je32(8),
53599 + .hdr_crc = constant_cpu_to_je32(0)
53600 };
53601
53602 /*
53603 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53604 index 788e0a9..8433098 100644
53605 --- a/fs/jfs/super.c
53606 +++ b/fs/jfs/super.c
53607 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
53608
53609 jfs_inode_cachep =
53610 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53611 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53612 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53613 init_once);
53614 if (jfs_inode_cachep == NULL)
53615 return -ENOMEM;
53616 diff --git a/fs/libfs.c b/fs/libfs.c
53617 index 916da8c..1588998 100644
53618 --- a/fs/libfs.c
53619 +++ b/fs/libfs.c
53620 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53621
53622 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53623 struct dentry *next;
53624 + char d_name[sizeof(next->d_iname)];
53625 + const unsigned char *name;
53626 +
53627 next = list_entry(p, struct dentry, d_u.d_child);
53628 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53629 if (!simple_positive(next)) {
53630 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53631
53632 spin_unlock(&next->d_lock);
53633 spin_unlock(&dentry->d_lock);
53634 - if (filldir(dirent, next->d_name.name,
53635 + name = next->d_name.name;
53636 + if (name == next->d_iname) {
53637 + memcpy(d_name, name, next->d_name.len);
53638 + name = d_name;
53639 + }
53640 + if (filldir(dirent, name,
53641 next->d_name.len, filp->f_pos,
53642 next->d_inode->i_ino,
53643 dt_type(next->d_inode)) < 0)
53644 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53645 index 9760ecb..9b838ef 100644
53646 --- a/fs/lockd/clntproc.c
53647 +++ b/fs/lockd/clntproc.c
53648 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53649 /*
53650 * Cookie counter for NLM requests
53651 */
53652 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53653 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53654
53655 void nlmclnt_next_cookie(struct nlm_cookie *c)
53656 {
53657 - u32 cookie = atomic_inc_return(&nlm_cookie);
53658 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53659
53660 memcpy(c->data, &cookie, 4);
53661 c->len=4;
53662 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
53663 index a2aa97d..10d6c41 100644
53664 --- a/fs/lockd/svc.c
53665 +++ b/fs/lockd/svc.c
53666 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
53667 svc_sock_update_bufs(serv);
53668 serv->sv_maxconn = nlm_max_connections;
53669
53670 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
53671 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
53672 if (IS_ERR(nlmsvc_task)) {
53673 error = PTR_ERR(nlmsvc_task);
53674 printk(KERN_WARNING
53675 diff --git a/fs/locks.c b/fs/locks.c
53676 index cb424a4..850e4dd 100644
53677 --- a/fs/locks.c
53678 +++ b/fs/locks.c
53679 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53680 return;
53681
53682 if (filp->f_op && filp->f_op->flock) {
53683 - struct file_lock fl = {
53684 + struct file_lock flock = {
53685 .fl_pid = current->tgid,
53686 .fl_file = filp,
53687 .fl_flags = FL_FLOCK,
53688 .fl_type = F_UNLCK,
53689 .fl_end = OFFSET_MAX,
53690 };
53691 - filp->f_op->flock(filp, F_SETLKW, &fl);
53692 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53693 - fl.fl_ops->fl_release_private(&fl);
53694 + filp->f_op->flock(filp, F_SETLKW, &flock);
53695 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53696 + flock.fl_ops->fl_release_private(&flock);
53697 }
53698
53699 lock_flocks();
53700 diff --git a/fs/namei.c b/fs/namei.c
53701 index 9ed9361..2b72db1 100644
53702 --- a/fs/namei.c
53703 +++ b/fs/namei.c
53704 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53705 if (ret != -EACCES)
53706 return ret;
53707
53708 +#ifdef CONFIG_GRKERNSEC
53709 + /* we'll block if we have to log due to a denied capability use */
53710 + if (mask & MAY_NOT_BLOCK)
53711 + return -ECHILD;
53712 +#endif
53713 +
53714 if (S_ISDIR(inode->i_mode)) {
53715 /* DACs are overridable for directories */
53716 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53717 - return 0;
53718 if (!(mask & MAY_WRITE))
53719 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53720 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53721 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53722 return 0;
53723 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53724 + return 0;
53725 return -EACCES;
53726 }
53727 /*
53728 + * Searching includes executable on directories, else just read.
53729 + */
53730 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53731 + if (mask == MAY_READ)
53732 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53733 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53734 + return 0;
53735 +
53736 + /*
53737 * Read/write DACs are always overridable.
53738 * Executable DACs are overridable when there is
53739 * at least one exec bit set.
53740 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53741 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53742 return 0;
53743
53744 - /*
53745 - * Searching includes executable on directories, else just read.
53746 - */
53747 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53748 - if (mask == MAY_READ)
53749 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53750 - return 0;
53751 -
53752 return -EACCES;
53753 }
53754
53755 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53756 {
53757 struct dentry *dentry = link->dentry;
53758 int error;
53759 - char *s;
53760 + const char *s;
53761
53762 BUG_ON(nd->flags & LOOKUP_RCU);
53763
53764 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53765 if (error)
53766 goto out_put_nd_path;
53767
53768 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53769 + dentry->d_inode, dentry, nd->path.mnt)) {
53770 + error = -EACCES;
53771 + goto out_put_nd_path;
53772 + }
53773 +
53774 nd->last_type = LAST_BIND;
53775 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53776 error = PTR_ERR(*p);
53777 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53778 if (res)
53779 break;
53780 res = walk_component(nd, path, LOOKUP_FOLLOW);
53781 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53782 + res = -EACCES;
53783 put_link(nd, &link, cookie);
53784 } while (res > 0);
53785
53786 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53787 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53788 {
53789 unsigned long a, b, adata, bdata, mask, hash, len;
53790 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53791 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53792
53793 hash = a = 0;
53794 len = -sizeof(unsigned long);
53795 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53796 if (err)
53797 break;
53798 err = lookup_last(nd, &path);
53799 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53800 + err = -EACCES;
53801 put_link(nd, &link, cookie);
53802 }
53803 }
53804 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53805 if (!err)
53806 err = complete_walk(nd);
53807
53808 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53809 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53810 + path_put(&nd->path);
53811 + err = -ENOENT;
53812 + }
53813 + }
53814 +
53815 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53816 if (!can_lookup(nd->inode)) {
53817 path_put(&nd->path);
53818 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53819 retval = path_lookupat(dfd, name->name,
53820 flags | LOOKUP_REVAL, nd);
53821
53822 - if (likely(!retval))
53823 + if (likely(!retval)) {
53824 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53825 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53826 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53827 + path_put(&nd->path);
53828 + return -ENOENT;
53829 + }
53830 + }
53831 + }
53832 return retval;
53833 }
53834
53835 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53836 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53837 return -EPERM;
53838
53839 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53840 + return -EPERM;
53841 + if (gr_handle_rawio(inode))
53842 + return -EPERM;
53843 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53844 + return -EACCES;
53845 +
53846 return 0;
53847 }
53848
53849 @@ -2602,7 +2641,7 @@ looked_up:
53850 * cleared otherwise prior to returning.
53851 */
53852 static int lookup_open(struct nameidata *nd, struct path *path,
53853 - struct file *file,
53854 + struct path *link, struct file *file,
53855 const struct open_flags *op,
53856 bool got_write, int *opened)
53857 {
53858 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53859 /* Negative dentry, just create the file */
53860 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53861 umode_t mode = op->mode;
53862 +
53863 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53864 + error = -EACCES;
53865 + goto out_dput;
53866 + }
53867 +
53868 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53869 + error = -EACCES;
53870 + goto out_dput;
53871 + }
53872 +
53873 if (!IS_POSIXACL(dir->d_inode))
53874 mode &= ~current_umask();
53875 /*
53876 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53877 nd->flags & LOOKUP_EXCL);
53878 if (error)
53879 goto out_dput;
53880 + else
53881 + gr_handle_create(dentry, nd->path.mnt);
53882 }
53883 out_no_open:
53884 path->dentry = dentry;
53885 @@ -2672,7 +2724,7 @@ out_dput:
53886 /*
53887 * Handle the last step of open()
53888 */
53889 -static int do_last(struct nameidata *nd, struct path *path,
53890 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53891 struct file *file, const struct open_flags *op,
53892 int *opened, struct filename *name)
53893 {
53894 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53895 error = complete_walk(nd);
53896 if (error)
53897 return error;
53898 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53899 + error = -ENOENT;
53900 + goto out;
53901 + }
53902 audit_inode(name, nd->path.dentry, 0);
53903 if (open_flag & O_CREAT) {
53904 error = -EISDIR;
53905 goto out;
53906 }
53907 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53908 + error = -EACCES;
53909 + goto out;
53910 + }
53911 goto finish_open;
53912 case LAST_BIND:
53913 error = complete_walk(nd);
53914 if (error)
53915 return error;
53916 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53917 + error = -ENOENT;
53918 + goto out;
53919 + }
53920 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53921 + error = -EACCES;
53922 + goto out;
53923 + }
53924 audit_inode(name, dir, 0);
53925 goto finish_open;
53926 }
53927 @@ -2759,7 +2827,7 @@ retry_lookup:
53928 */
53929 }
53930 mutex_lock(&dir->d_inode->i_mutex);
53931 - error = lookup_open(nd, path, file, op, got_write, opened);
53932 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53933 mutex_unlock(&dir->d_inode->i_mutex);
53934
53935 if (error <= 0) {
53936 @@ -2783,11 +2851,28 @@ retry_lookup:
53937 goto finish_open_created;
53938 }
53939
53940 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53941 + error = -ENOENT;
53942 + goto exit_dput;
53943 + }
53944 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53945 + error = -EACCES;
53946 + goto exit_dput;
53947 + }
53948 +
53949 /*
53950 * create/update audit record if it already exists.
53951 */
53952 - if (path->dentry->d_inode)
53953 + if (path->dentry->d_inode) {
53954 + /* only check if O_CREAT is specified, all other checks need to go
53955 + into may_open */
53956 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53957 + error = -EACCES;
53958 + goto exit_dput;
53959 + }
53960 +
53961 audit_inode(name, path->dentry, 0);
53962 + }
53963
53964 /*
53965 * If atomic_open() acquired write access it is dropped now due to
53966 @@ -2828,6 +2913,11 @@ finish_lookup:
53967 }
53968 }
53969 BUG_ON(inode != path->dentry->d_inode);
53970 + /* if we're resolving a symlink to another symlink */
53971 + if (link && gr_handle_symlink_owner(link, inode)) {
53972 + error = -EACCES;
53973 + goto out;
53974 + }
53975 return 1;
53976 }
53977
53978 @@ -2837,7 +2927,6 @@ finish_lookup:
53979 save_parent.dentry = nd->path.dentry;
53980 save_parent.mnt = mntget(path->mnt);
53981 nd->path.dentry = path->dentry;
53982 -
53983 }
53984 nd->inode = inode;
53985 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53986 @@ -2846,6 +2935,16 @@ finish_lookup:
53987 path_put(&save_parent);
53988 return error;
53989 }
53990 +
53991 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53992 + error = -ENOENT;
53993 + goto out;
53994 + }
53995 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53996 + error = -EACCES;
53997 + goto out;
53998 + }
53999 +
54000 error = -EISDIR;
54001 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
54002 goto out;
54003 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54004 if (unlikely(error))
54005 goto out;
54006
54007 - error = do_last(nd, &path, file, op, &opened, pathname);
54008 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
54009 while (unlikely(error > 0)) { /* trailing symlink */
54010 struct path link = path;
54011 void *cookie;
54012 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54013 error = follow_link(&link, nd, &cookie);
54014 if (unlikely(error))
54015 break;
54016 - error = do_last(nd, &path, file, op, &opened, pathname);
54017 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
54018 put_link(nd, &link, cookie);
54019 }
54020 out:
54021 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
54022 goto unlock;
54023
54024 error = -EEXIST;
54025 - if (dentry->d_inode)
54026 + if (dentry->d_inode) {
54027 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
54028 + error = -ENOENT;
54029 + }
54030 goto fail;
54031 + }
54032 /*
54033 * Special case - lookup gave negative, but... we had foo/bar/
54034 * From the vfs_mknod() POV we just have a negative dentry -
54035 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
54036 }
54037 EXPORT_SYMBOL(user_path_create);
54038
54039 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
54040 +{
54041 + struct filename *tmp = getname(pathname);
54042 + struct dentry *res;
54043 + if (IS_ERR(tmp))
54044 + return ERR_CAST(tmp);
54045 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
54046 + if (IS_ERR(res))
54047 + putname(tmp);
54048 + else
54049 + *to = tmp;
54050 + return res;
54051 +}
54052 +
54053 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
54054 {
54055 int error = may_create(dir, dentry);
54056 @@ -3177,6 +3294,17 @@ retry:
54057
54058 if (!IS_POSIXACL(path.dentry->d_inode))
54059 mode &= ~current_umask();
54060 +
54061 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
54062 + error = -EPERM;
54063 + goto out;
54064 + }
54065 +
54066 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
54067 + error = -EACCES;
54068 + goto out;
54069 + }
54070 +
54071 error = security_path_mknod(&path, dentry, mode, dev);
54072 if (error)
54073 goto out;
54074 @@ -3193,6 +3321,8 @@ retry:
54075 break;
54076 }
54077 out:
54078 + if (!error)
54079 + gr_handle_create(dentry, path.mnt);
54080 done_path_create(&path, dentry);
54081 if (retry_estale(error, lookup_flags)) {
54082 lookup_flags |= LOOKUP_REVAL;
54083 @@ -3245,9 +3375,16 @@ retry:
54084
54085 if (!IS_POSIXACL(path.dentry->d_inode))
54086 mode &= ~current_umask();
54087 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54088 + error = -EACCES;
54089 + goto out;
54090 + }
54091 error = security_path_mkdir(&path, dentry, mode);
54092 if (!error)
54093 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54094 + if (!error)
54095 + gr_handle_create(dentry, path.mnt);
54096 +out:
54097 done_path_create(&path, dentry);
54098 if (retry_estale(error, lookup_flags)) {
54099 lookup_flags |= LOOKUP_REVAL;
54100 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54101 struct filename *name;
54102 struct dentry *dentry;
54103 struct nameidata nd;
54104 + ino_t saved_ino = 0;
54105 + dev_t saved_dev = 0;
54106 unsigned int lookup_flags = 0;
54107 retry:
54108 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54109 @@ -3360,10 +3499,21 @@ retry:
54110 error = -ENOENT;
54111 goto exit3;
54112 }
54113 +
54114 + saved_ino = dentry->d_inode->i_ino;
54115 + saved_dev = gr_get_dev_from_dentry(dentry);
54116 +
54117 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54118 + error = -EACCES;
54119 + goto exit3;
54120 + }
54121 +
54122 error = security_path_rmdir(&nd.path, dentry);
54123 if (error)
54124 goto exit3;
54125 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54126 + if (!error && (saved_dev || saved_ino))
54127 + gr_handle_delete(saved_ino, saved_dev);
54128 exit3:
54129 dput(dentry);
54130 exit2:
54131 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54132 struct dentry *dentry;
54133 struct nameidata nd;
54134 struct inode *inode = NULL;
54135 + ino_t saved_ino = 0;
54136 + dev_t saved_dev = 0;
54137 unsigned int lookup_flags = 0;
54138 retry:
54139 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54140 @@ -3455,10 +3607,22 @@ retry:
54141 if (!inode)
54142 goto slashes;
54143 ihold(inode);
54144 +
54145 + if (inode->i_nlink <= 1) {
54146 + saved_ino = inode->i_ino;
54147 + saved_dev = gr_get_dev_from_dentry(dentry);
54148 + }
54149 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54150 + error = -EACCES;
54151 + goto exit2;
54152 + }
54153 +
54154 error = security_path_unlink(&nd.path, dentry);
54155 if (error)
54156 goto exit2;
54157 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54158 + if (!error && (saved_ino || saved_dev))
54159 + gr_handle_delete(saved_ino, saved_dev);
54160 exit2:
54161 dput(dentry);
54162 }
54163 @@ -3536,9 +3700,17 @@ retry:
54164 if (IS_ERR(dentry))
54165 goto out_putname;
54166
54167 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54168 + error = -EACCES;
54169 + goto out;
54170 + }
54171 +
54172 error = security_path_symlink(&path, dentry, from->name);
54173 if (!error)
54174 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54175 + if (!error)
54176 + gr_handle_create(dentry, path.mnt);
54177 +out:
54178 done_path_create(&path, dentry);
54179 if (retry_estale(error, lookup_flags)) {
54180 lookup_flags |= LOOKUP_REVAL;
54181 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54182 {
54183 struct dentry *new_dentry;
54184 struct path old_path, new_path;
54185 + struct filename *to = NULL;
54186 int how = 0;
54187 int error;
54188
54189 @@ -3635,7 +3808,7 @@ retry:
54190 if (error)
54191 return error;
54192
54193 - new_dentry = user_path_create(newdfd, newname, &new_path,
54194 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54195 (how & LOOKUP_REVAL));
54196 error = PTR_ERR(new_dentry);
54197 if (IS_ERR(new_dentry))
54198 @@ -3647,11 +3820,28 @@ retry:
54199 error = may_linkat(&old_path);
54200 if (unlikely(error))
54201 goto out_dput;
54202 +
54203 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54204 + old_path.dentry->d_inode,
54205 + old_path.dentry->d_inode->i_mode, to)) {
54206 + error = -EACCES;
54207 + goto out_dput;
54208 + }
54209 +
54210 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54211 + old_path.dentry, old_path.mnt, to)) {
54212 + error = -EACCES;
54213 + goto out_dput;
54214 + }
54215 +
54216 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54217 if (error)
54218 goto out_dput;
54219 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54220 + if (!error)
54221 + gr_handle_create(new_dentry, new_path.mnt);
54222 out_dput:
54223 + putname(to);
54224 done_path_create(&new_path, new_dentry);
54225 if (retry_estale(error, how)) {
54226 how |= LOOKUP_REVAL;
54227 @@ -3897,12 +4087,21 @@ retry:
54228 if (new_dentry == trap)
54229 goto exit5;
54230
54231 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54232 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54233 + to);
54234 + if (error)
54235 + goto exit5;
54236 +
54237 error = security_path_rename(&oldnd.path, old_dentry,
54238 &newnd.path, new_dentry);
54239 if (error)
54240 goto exit5;
54241 error = vfs_rename(old_dir->d_inode, old_dentry,
54242 new_dir->d_inode, new_dentry);
54243 + if (!error)
54244 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54245 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54246 exit5:
54247 dput(new_dentry);
54248 exit4:
54249 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54250
54251 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54252 {
54253 + char tmpbuf[64];
54254 + const char *newlink;
54255 int len;
54256
54257 len = PTR_ERR(link);
54258 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54259 len = strlen(link);
54260 if (len > (unsigned) buflen)
54261 len = buflen;
54262 - if (copy_to_user(buffer, link, len))
54263 +
54264 + if (len < sizeof(tmpbuf)) {
54265 + memcpy(tmpbuf, link, len);
54266 + newlink = tmpbuf;
54267 + } else
54268 + newlink = link;
54269 +
54270 + if (copy_to_user(buffer, newlink, len))
54271 len = -EFAULT;
54272 out:
54273 return len;
54274 diff --git a/fs/namespace.c b/fs/namespace.c
54275 index 7b1ca9b..6faeccf 100644
54276 --- a/fs/namespace.c
54277 +++ b/fs/namespace.c
54278 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
54279 if (!(sb->s_flags & MS_RDONLY))
54280 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54281 up_write(&sb->s_umount);
54282 +
54283 + gr_log_remount(mnt->mnt_devname, retval);
54284 +
54285 return retval;
54286 }
54287
54288 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
54289 }
54290 br_write_unlock(&vfsmount_lock);
54291 namespace_unlock();
54292 +
54293 + gr_log_unmount(mnt->mnt_devname, retval);
54294 +
54295 return retval;
54296 }
54297
54298 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
54299 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
54300 */
54301
54302 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
54303 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
54304 {
54305 struct path path;
54306 struct mount *mnt;
54307 @@ -1342,7 +1348,7 @@ out:
54308 /*
54309 * The 2.0 compatible umount. No flags.
54310 */
54311 -SYSCALL_DEFINE1(oldumount, char __user *, name)
54312 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
54313 {
54314 return sys_umount(name, 0);
54315 }
54316 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54317 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54318 MS_STRICTATIME);
54319
54320 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54321 + retval = -EPERM;
54322 + goto dput_out;
54323 + }
54324 +
54325 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54326 + retval = -EPERM;
54327 + goto dput_out;
54328 + }
54329 +
54330 if (flags & MS_REMOUNT)
54331 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54332 data_page);
54333 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54334 dev_name, data_page);
54335 dput_out:
54336 path_put(&path);
54337 +
54338 + gr_log_mount(dev_name, dir_name, retval);
54339 +
54340 return retval;
54341 }
54342
54343 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
54344 }
54345 EXPORT_SYMBOL(mount_subtree);
54346
54347 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
54348 - char __user *, type, unsigned long, flags, void __user *, data)
54349 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
54350 + const char __user *, type, unsigned long, flags, void __user *, data)
54351 {
54352 int ret;
54353 char *kernel_type;
54354 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54355 if (error)
54356 goto out2;
54357
54358 + if (gr_handle_chroot_pivot()) {
54359 + error = -EPERM;
54360 + goto out2;
54361 + }
54362 +
54363 get_fs_root(current->fs, &root);
54364 old_mp = lock_mount(&old);
54365 error = PTR_ERR(old_mp);
54366 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54367 !nsown_capable(CAP_SYS_ADMIN))
54368 return -EPERM;
54369
54370 - if (fs->users != 1)
54371 + if (atomic_read(&fs->users) != 1)
54372 return -EINVAL;
54373
54374 get_mnt_ns(mnt_ns);
54375 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
54376 index cff089a..4c3d57a 100644
54377 --- a/fs/nfs/callback.c
54378 +++ b/fs/nfs/callback.c
54379 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54380 struct svc_rqst *rqstp;
54381 int (*callback_svc)(void *vrqstp);
54382 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
54383 - char svc_name[12];
54384 int ret;
54385
54386 nfs_callback_bc_serv(minorversion, xprt, serv);
54387 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54388
54389 svc_sock_update_bufs(serv);
54390
54391 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
54392 cb_info->serv = serv;
54393 cb_info->rqst = rqstp;
54394 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
54395 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
54396 if (IS_ERR(cb_info->task)) {
54397 ret = PTR_ERR(cb_info->task);
54398 svc_exit_thread(cb_info->rqst);
54399 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54400 index a35582c..ebbdcd5 100644
54401 --- a/fs/nfs/callback_xdr.c
54402 +++ b/fs/nfs/callback_xdr.c
54403 @@ -51,7 +51,7 @@ struct callback_op {
54404 callback_decode_arg_t decode_args;
54405 callback_encode_res_t encode_res;
54406 long res_maxsize;
54407 -};
54408 +} __do_const;
54409
54410 static struct callback_op callback_ops[];
54411
54412 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54413 index c1c7a9d..7afa0b8 100644
54414 --- a/fs/nfs/inode.c
54415 +++ b/fs/nfs/inode.c
54416 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54417 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54418 }
54419
54420 -static atomic_long_t nfs_attr_generation_counter;
54421 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54422
54423 static unsigned long nfs_read_attr_generation_counter(void)
54424 {
54425 - return atomic_long_read(&nfs_attr_generation_counter);
54426 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54427 }
54428
54429 unsigned long nfs_inc_attr_generation_counter(void)
54430 {
54431 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54432 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54433 }
54434
54435 void nfs_fattr_init(struct nfs_fattr *fattr)
54436 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
54437 index 2c37442..9b9538b 100644
54438 --- a/fs/nfs/nfs4state.c
54439 +++ b/fs/nfs/nfs4state.c
54440 @@ -1193,7 +1193,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
54441 snprintf(buf, sizeof(buf), "%s-manager",
54442 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
54443 rcu_read_unlock();
54444 - task = kthread_run(nfs4_run_state_manager, clp, buf);
54445 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
54446 if (IS_ERR(task)) {
54447 printk(KERN_ERR "%s: kthread_run: %ld\n",
54448 __func__, PTR_ERR(task));
54449 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54450 index 27d74a2..c4c2a73 100644
54451 --- a/fs/nfsd/nfs4proc.c
54452 +++ b/fs/nfsd/nfs4proc.c
54453 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
54454 nfsd4op_rsize op_rsize_bop;
54455 stateid_getter op_get_currentstateid;
54456 stateid_setter op_set_currentstateid;
54457 -};
54458 +} __do_const;
54459
54460 static struct nfsd4_operation nfsd4_ops[];
54461
54462 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54463 index 582321a..0224663 100644
54464 --- a/fs/nfsd/nfs4xdr.c
54465 +++ b/fs/nfsd/nfs4xdr.c
54466 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54467
54468 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54469
54470 -static nfsd4_dec nfsd4_dec_ops[] = {
54471 +static const nfsd4_dec nfsd4_dec_ops[] = {
54472 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54473 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54474 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54475 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54476 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54477 };
54478
54479 -static nfsd4_dec nfsd41_dec_ops[] = {
54480 +static const nfsd4_dec nfsd41_dec_ops[] = {
54481 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54482 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54483 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54484 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54485 };
54486
54487 struct nfsd4_minorversion_ops {
54488 - nfsd4_dec *decoders;
54489 + const nfsd4_dec *decoders;
54490 int nops;
54491 };
54492
54493 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54494 index e76244e..9fe8f2f1 100644
54495 --- a/fs/nfsd/nfscache.c
54496 +++ b/fs/nfsd/nfscache.c
54497 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54498 {
54499 struct svc_cacherep *rp = rqstp->rq_cacherep;
54500 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
54501 - int len;
54502 + long len;
54503 size_t bufsize = 0;
54504
54505 if (!rp)
54506 return;
54507
54508 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54509 - len >>= 2;
54510 + if (statp) {
54511 + len = (char*)statp - (char*)resv->iov_base;
54512 + len = resv->iov_len - len;
54513 + len >>= 2;
54514 + }
54515
54516 /* Don't cache excessive amounts of data and XDR failures */
54517 if (!statp || len > (256 >> 2)) {
54518 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54519 index 84ce601..633d226 100644
54520 --- a/fs/nfsd/vfs.c
54521 +++ b/fs/nfsd/vfs.c
54522 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54523 } else {
54524 oldfs = get_fs();
54525 set_fs(KERNEL_DS);
54526 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54527 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54528 set_fs(oldfs);
54529 }
54530
54531 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54532
54533 /* Write the data. */
54534 oldfs = get_fs(); set_fs(KERNEL_DS);
54535 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54536 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54537 set_fs(oldfs);
54538 if (host_err < 0)
54539 goto out_nfserr;
54540 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54541 */
54542
54543 oldfs = get_fs(); set_fs(KERNEL_DS);
54544 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54545 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54546 set_fs(oldfs);
54547
54548 if (host_err < 0)
54549 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54550 index fea6bd5..8ee9d81 100644
54551 --- a/fs/nls/nls_base.c
54552 +++ b/fs/nls/nls_base.c
54553 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54554
54555 int register_nls(struct nls_table * nls)
54556 {
54557 - struct nls_table ** tmp = &tables;
54558 + struct nls_table *tmp = tables;
54559
54560 if (nls->next)
54561 return -EBUSY;
54562
54563 spin_lock(&nls_lock);
54564 - while (*tmp) {
54565 - if (nls == *tmp) {
54566 + while (tmp) {
54567 + if (nls == tmp) {
54568 spin_unlock(&nls_lock);
54569 return -EBUSY;
54570 }
54571 - tmp = &(*tmp)->next;
54572 + tmp = tmp->next;
54573 }
54574 - nls->next = tables;
54575 + pax_open_kernel();
54576 + *(struct nls_table **)&nls->next = tables;
54577 + pax_close_kernel();
54578 tables = nls;
54579 spin_unlock(&nls_lock);
54580 return 0;
54581 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54582
54583 int unregister_nls(struct nls_table * nls)
54584 {
54585 - struct nls_table ** tmp = &tables;
54586 + struct nls_table * const * tmp = &tables;
54587
54588 spin_lock(&nls_lock);
54589 while (*tmp) {
54590 if (nls == *tmp) {
54591 - *tmp = nls->next;
54592 + pax_open_kernel();
54593 + *(struct nls_table **)tmp = nls->next;
54594 + pax_close_kernel();
54595 spin_unlock(&nls_lock);
54596 return 0;
54597 }
54598 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54599 index 7424929..35f6be5 100644
54600 --- a/fs/nls/nls_euc-jp.c
54601 +++ b/fs/nls/nls_euc-jp.c
54602 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54603 p_nls = load_nls("cp932");
54604
54605 if (p_nls) {
54606 - table.charset2upper = p_nls->charset2upper;
54607 - table.charset2lower = p_nls->charset2lower;
54608 + pax_open_kernel();
54609 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54610 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54611 + pax_close_kernel();
54612 return register_nls(&table);
54613 }
54614
54615 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54616 index e7bc1d7..06bd4bb 100644
54617 --- a/fs/nls/nls_koi8-ru.c
54618 +++ b/fs/nls/nls_koi8-ru.c
54619 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54620 p_nls = load_nls("koi8-u");
54621
54622 if (p_nls) {
54623 - table.charset2upper = p_nls->charset2upper;
54624 - table.charset2lower = p_nls->charset2lower;
54625 + pax_open_kernel();
54626 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54627 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54628 + pax_close_kernel();
54629 return register_nls(&table);
54630 }
54631
54632 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54633 index 6c80083..a1e6299 100644
54634 --- a/fs/notify/fanotify/fanotify_user.c
54635 +++ b/fs/notify/fanotify/fanotify_user.c
54636 @@ -122,6 +122,7 @@ static int fill_event_metadata(struct fsnotify_group *group,
54637 metadata->event_len = FAN_EVENT_METADATA_LEN;
54638 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
54639 metadata->vers = FANOTIFY_METADATA_VERSION;
54640 + metadata->reserved = 0;
54641 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
54642 metadata->pid = pid_vnr(event->tgid);
54643 if (unlikely(event->mask & FAN_Q_OVERFLOW))
54644 @@ -252,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54645
54646 fd = fanotify_event_metadata.fd;
54647 ret = -EFAULT;
54648 - if (copy_to_user(buf, &fanotify_event_metadata,
54649 - fanotify_event_metadata.event_len))
54650 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54651 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54652 goto out_close_fd;
54653
54654 ret = prepare_for_access_response(group, event, fd);
54655 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54656 index 7b51b05..5ea5ef6 100644
54657 --- a/fs/notify/notification.c
54658 +++ b/fs/notify/notification.c
54659 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54660 * get set to 0 so it will never get 'freed'
54661 */
54662 static struct fsnotify_event *q_overflow_event;
54663 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54664 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54665
54666 /**
54667 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54668 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54669 */
54670 u32 fsnotify_get_cookie(void)
54671 {
54672 - return atomic_inc_return(&fsnotify_sync_cookie);
54673 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54674 }
54675 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54676
54677 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54678 index aa411c3..c260a84 100644
54679 --- a/fs/ntfs/dir.c
54680 +++ b/fs/ntfs/dir.c
54681 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54682 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54683 ~(s64)(ndir->itype.index.block_size - 1)));
54684 /* Bounds checks. */
54685 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54686 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54687 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54688 "inode 0x%lx or driver bug.", vdir->i_ino);
54689 goto err_out;
54690 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54691 index c5670b8..01a3656 100644
54692 --- a/fs/ntfs/file.c
54693 +++ b/fs/ntfs/file.c
54694 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54695 #endif /* NTFS_RW */
54696 };
54697
54698 -const struct file_operations ntfs_empty_file_ops = {};
54699 +const struct file_operations ntfs_empty_file_ops __read_only;
54700
54701 -const struct inode_operations ntfs_empty_inode_ops = {};
54702 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54703 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54704 index aebeacd..0dcdd26 100644
54705 --- a/fs/ocfs2/localalloc.c
54706 +++ b/fs/ocfs2/localalloc.c
54707 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54708 goto bail;
54709 }
54710
54711 - atomic_inc(&osb->alloc_stats.moves);
54712 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54713
54714 bail:
54715 if (handle)
54716 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54717 index d355e6e..578d905 100644
54718 --- a/fs/ocfs2/ocfs2.h
54719 +++ b/fs/ocfs2/ocfs2.h
54720 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54721
54722 struct ocfs2_alloc_stats
54723 {
54724 - atomic_t moves;
54725 - atomic_t local_data;
54726 - atomic_t bitmap_data;
54727 - atomic_t bg_allocs;
54728 - atomic_t bg_extends;
54729 + atomic_unchecked_t moves;
54730 + atomic_unchecked_t local_data;
54731 + atomic_unchecked_t bitmap_data;
54732 + atomic_unchecked_t bg_allocs;
54733 + atomic_unchecked_t bg_extends;
54734 };
54735
54736 enum ocfs2_local_alloc_state
54737 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54738 index b7e74b5..19c6536 100644
54739 --- a/fs/ocfs2/suballoc.c
54740 +++ b/fs/ocfs2/suballoc.c
54741 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54742 mlog_errno(status);
54743 goto bail;
54744 }
54745 - atomic_inc(&osb->alloc_stats.bg_extends);
54746 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54747
54748 /* You should never ask for this much metadata */
54749 BUG_ON(bits_wanted >
54750 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54751 mlog_errno(status);
54752 goto bail;
54753 }
54754 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54755 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54756
54757 *suballoc_loc = res.sr_bg_blkno;
54758 *suballoc_bit_start = res.sr_bit_offset;
54759 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54760 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54761 res->sr_bits);
54762
54763 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54764 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54765
54766 BUG_ON(res->sr_bits != 1);
54767
54768 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54769 mlog_errno(status);
54770 goto bail;
54771 }
54772 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54773 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54774
54775 BUG_ON(res.sr_bits != 1);
54776
54777 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54778 cluster_start,
54779 num_clusters);
54780 if (!status)
54781 - atomic_inc(&osb->alloc_stats.local_data);
54782 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54783 } else {
54784 if (min_clusters > (osb->bitmap_cpg - 1)) {
54785 /* The only paths asking for contiguousness
54786 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54787 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54788 res.sr_bg_blkno,
54789 res.sr_bit_offset);
54790 - atomic_inc(&osb->alloc_stats.bitmap_data);
54791 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54792 *num_clusters = res.sr_bits;
54793 }
54794 }
54795 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54796 index 01b8516..579c4df 100644
54797 --- a/fs/ocfs2/super.c
54798 +++ b/fs/ocfs2/super.c
54799 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54800 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54801 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54802 "Stats",
54803 - atomic_read(&osb->alloc_stats.bitmap_data),
54804 - atomic_read(&osb->alloc_stats.local_data),
54805 - atomic_read(&osb->alloc_stats.bg_allocs),
54806 - atomic_read(&osb->alloc_stats.moves),
54807 - atomic_read(&osb->alloc_stats.bg_extends));
54808 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54809 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54810 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54811 + atomic_read_unchecked(&osb->alloc_stats.moves),
54812 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54813
54814 out += snprintf(buf + out, len - out,
54815 "%10s => State: %u Descriptor: %llu Size: %u bits "
54816 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54817 spin_lock_init(&osb->osb_xattr_lock);
54818 ocfs2_init_steal_slots(osb);
54819
54820 - atomic_set(&osb->alloc_stats.moves, 0);
54821 - atomic_set(&osb->alloc_stats.local_data, 0);
54822 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54823 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54824 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54825 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54826 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54827 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54828 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54829 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54830
54831 /* Copy the blockcheck stats from the superblock probe */
54832 osb->osb_ecc_stats = *stats;
54833 diff --git a/fs/open.c b/fs/open.c
54834 index 8c74100..4239c48 100644
54835 --- a/fs/open.c
54836 +++ b/fs/open.c
54837 @@ -32,6 +32,8 @@
54838 #include <linux/dnotify.h>
54839 #include <linux/compat.h>
54840
54841 +#define CREATE_TRACE_POINTS
54842 +#include <trace/events/fs.h>
54843 #include "internal.h"
54844
54845 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54846 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54847 error = locks_verify_truncate(inode, NULL, length);
54848 if (!error)
54849 error = security_path_truncate(path);
54850 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54851 + error = -EACCES;
54852 if (!error)
54853 error = do_truncate(path->dentry, length, 0, NULL);
54854
54855 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54856 error = locks_verify_truncate(inode, f.file, length);
54857 if (!error)
54858 error = security_path_truncate(&f.file->f_path);
54859 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54860 + error = -EACCES;
54861 if (!error)
54862 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54863 sb_end_write(inode->i_sb);
54864 @@ -360,6 +366,9 @@ retry:
54865 if (__mnt_is_readonly(path.mnt))
54866 res = -EROFS;
54867
54868 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54869 + res = -EACCES;
54870 +
54871 out_path_release:
54872 path_put(&path);
54873 if (retry_estale(res, lookup_flags)) {
54874 @@ -391,6 +400,8 @@ retry:
54875 if (error)
54876 goto dput_and_out;
54877
54878 + gr_log_chdir(path.dentry, path.mnt);
54879 +
54880 set_fs_pwd(current->fs, &path);
54881
54882 dput_and_out:
54883 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54884 goto out_putf;
54885
54886 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54887 +
54888 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54889 + error = -EPERM;
54890 +
54891 + if (!error)
54892 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54893 +
54894 if (!error)
54895 set_fs_pwd(current->fs, &f.file->f_path);
54896 out_putf:
54897 @@ -449,7 +467,13 @@ retry:
54898 if (error)
54899 goto dput_and_out;
54900
54901 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54902 + goto dput_and_out;
54903 +
54904 set_fs_root(current->fs, &path);
54905 +
54906 + gr_handle_chroot_chdir(&path);
54907 +
54908 error = 0;
54909 dput_and_out:
54910 path_put(&path);
54911 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
54912 if (error)
54913 return error;
54914 mutex_lock(&inode->i_mutex);
54915 +
54916 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54917 + error = -EACCES;
54918 + goto out_unlock;
54919 + }
54920 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54921 + error = -EACCES;
54922 + goto out_unlock;
54923 + }
54924 +
54925 error = security_path_chmod(path, mode);
54926 if (error)
54927 goto out_unlock;
54928 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54929 uid = make_kuid(current_user_ns(), user);
54930 gid = make_kgid(current_user_ns(), group);
54931
54932 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54933 + return -EACCES;
54934 +
54935 newattrs.ia_valid = ATTR_CTIME;
54936 if (user != (uid_t) -1) {
54937 if (!uid_valid(uid))
54938 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54939 } else {
54940 fsnotify_open(f);
54941 fd_install(fd, f);
54942 + trace_do_sys_open(tmp->name, flags, mode);
54943 }
54944 }
54945 putname(tmp);
54946 diff --git a/fs/pipe.c b/fs/pipe.c
54947 index d2c45e1..009fe1c 100644
54948 --- a/fs/pipe.c
54949 +++ b/fs/pipe.c
54950 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
54951
54952 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
54953 {
54954 - if (pipe->files)
54955 + if (atomic_read(&pipe->files))
54956 mutex_lock_nested(&pipe->mutex, subclass);
54957 }
54958
54959 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
54960
54961 void pipe_unlock(struct pipe_inode_info *pipe)
54962 {
54963 - if (pipe->files)
54964 + if (atomic_read(&pipe->files))
54965 mutex_unlock(&pipe->mutex);
54966 }
54967 EXPORT_SYMBOL(pipe_unlock);
54968 @@ -449,9 +449,9 @@ redo:
54969 }
54970 if (bufs) /* More to do? */
54971 continue;
54972 - if (!pipe->writers)
54973 + if (!atomic_read(&pipe->writers))
54974 break;
54975 - if (!pipe->waiting_writers) {
54976 + if (!atomic_read(&pipe->waiting_writers)) {
54977 /* syscall merging: Usually we must not sleep
54978 * if O_NONBLOCK is set, or if we got some data.
54979 * But if a writer sleeps in kernel space, then
54980 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54981 ret = 0;
54982 __pipe_lock(pipe);
54983
54984 - if (!pipe->readers) {
54985 + if (!atomic_read(&pipe->readers)) {
54986 send_sig(SIGPIPE, current, 0);
54987 ret = -EPIPE;
54988 goto out;
54989 @@ -562,7 +562,7 @@ redo1:
54990 for (;;) {
54991 int bufs;
54992
54993 - if (!pipe->readers) {
54994 + if (!atomic_read(&pipe->readers)) {
54995 send_sig(SIGPIPE, current, 0);
54996 if (!ret)
54997 ret = -EPIPE;
54998 @@ -653,9 +653,9 @@ redo2:
54999 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55000 do_wakeup = 0;
55001 }
55002 - pipe->waiting_writers++;
55003 + atomic_inc(&pipe->waiting_writers);
55004 pipe_wait(pipe);
55005 - pipe->waiting_writers--;
55006 + atomic_dec(&pipe->waiting_writers);
55007 }
55008 out:
55009 __pipe_unlock(pipe);
55010 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
55011 mask = 0;
55012 if (filp->f_mode & FMODE_READ) {
55013 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
55014 - if (!pipe->writers && filp->f_version != pipe->w_counter)
55015 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
55016 mask |= POLLHUP;
55017 }
55018
55019 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
55020 * Most Unices do not set POLLERR for FIFOs but on Linux they
55021 * behave exactly like pipes for poll().
55022 */
55023 - if (!pipe->readers)
55024 + if (!atomic_read(&pipe->readers))
55025 mask |= POLLERR;
55026 }
55027
55028 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
55029
55030 __pipe_lock(pipe);
55031 if (file->f_mode & FMODE_READ)
55032 - pipe->readers--;
55033 + atomic_dec(&pipe->readers);
55034 if (file->f_mode & FMODE_WRITE)
55035 - pipe->writers--;
55036 + atomic_dec(&pipe->writers);
55037
55038 - if (pipe->readers || pipe->writers) {
55039 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
55040 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
55041 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55042 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
55043 }
55044 spin_lock(&inode->i_lock);
55045 - if (!--pipe->files) {
55046 + if (atomic_dec_and_test(&pipe->files)) {
55047 inode->i_pipe = NULL;
55048 kill = 1;
55049 }
55050 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
55051 kfree(pipe);
55052 }
55053
55054 -static struct vfsmount *pipe_mnt __read_mostly;
55055 +struct vfsmount *pipe_mnt __read_mostly;
55056
55057 /*
55058 * pipefs_dname() is called from d_path().
55059 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
55060 goto fail_iput;
55061
55062 inode->i_pipe = pipe;
55063 - pipe->files = 2;
55064 - pipe->readers = pipe->writers = 1;
55065 + atomic_set(&pipe->files, 2);
55066 + atomic_set(&pipe->readers, 1);
55067 + atomic_set(&pipe->writers, 1);
55068 inode->i_fop = &pipefifo_fops;
55069
55070 /*
55071 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
55072 spin_lock(&inode->i_lock);
55073 if (inode->i_pipe) {
55074 pipe = inode->i_pipe;
55075 - pipe->files++;
55076 + atomic_inc(&pipe->files);
55077 spin_unlock(&inode->i_lock);
55078 } else {
55079 spin_unlock(&inode->i_lock);
55080 pipe = alloc_pipe_info();
55081 if (!pipe)
55082 return -ENOMEM;
55083 - pipe->files = 1;
55084 + atomic_set(&pipe->files, 1);
55085 spin_lock(&inode->i_lock);
55086 if (unlikely(inode->i_pipe)) {
55087 - inode->i_pipe->files++;
55088 + atomic_inc(&inode->i_pipe->files);
55089 spin_unlock(&inode->i_lock);
55090 free_pipe_info(pipe);
55091 pipe = inode->i_pipe;
55092 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
55093 * opened, even when there is no process writing the FIFO.
55094 */
55095 pipe->r_counter++;
55096 - if (pipe->readers++ == 0)
55097 + if (atomic_inc_return(&pipe->readers) == 1)
55098 wake_up_partner(pipe);
55099
55100 - if (!is_pipe && !pipe->writers) {
55101 + if (!is_pipe && !atomic_read(&pipe->writers)) {
55102 if ((filp->f_flags & O_NONBLOCK)) {
55103 /* suppress POLLHUP until we have
55104 * seen a writer */
55105 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
55106 * errno=ENXIO when there is no process reading the FIFO.
55107 */
55108 ret = -ENXIO;
55109 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
55110 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
55111 goto err;
55112
55113 pipe->w_counter++;
55114 - if (!pipe->writers++)
55115 + if (atomic_inc_return(&pipe->writers) == 1)
55116 wake_up_partner(pipe);
55117
55118 - if (!is_pipe && !pipe->readers) {
55119 + if (!is_pipe && !atomic_read(&pipe->readers)) {
55120 if (wait_for_partner(pipe, &pipe->r_counter))
55121 goto err_wr;
55122 }
55123 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
55124 * the process can at least talk to itself.
55125 */
55126
55127 - pipe->readers++;
55128 - pipe->writers++;
55129 + atomic_inc(&pipe->readers);
55130 + atomic_inc(&pipe->writers);
55131 pipe->r_counter++;
55132 pipe->w_counter++;
55133 - if (pipe->readers == 1 || pipe->writers == 1)
55134 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
55135 wake_up_partner(pipe);
55136 break;
55137
55138 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
55139 return 0;
55140
55141 err_rd:
55142 - if (!--pipe->readers)
55143 + if (atomic_dec_and_test(&pipe->readers))
55144 wake_up_interruptible(&pipe->wait);
55145 ret = -ERESTARTSYS;
55146 goto err;
55147
55148 err_wr:
55149 - if (!--pipe->writers)
55150 + if (atomic_dec_and_test(&pipe->writers))
55151 wake_up_interruptible(&pipe->wait);
55152 ret = -ERESTARTSYS;
55153 goto err;
55154
55155 err:
55156 spin_lock(&inode->i_lock);
55157 - if (!--pipe->files) {
55158 + if (atomic_dec_and_test(&pipe->files)) {
55159 inode->i_pipe = NULL;
55160 kill = 1;
55161 }
55162 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
55163 index 15af622..0e9f4467 100644
55164 --- a/fs/proc/Kconfig
55165 +++ b/fs/proc/Kconfig
55166 @@ -30,12 +30,12 @@ config PROC_FS
55167
55168 config PROC_KCORE
55169 bool "/proc/kcore support" if !ARM
55170 - depends on PROC_FS && MMU
55171 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
55172
55173 config PROC_VMCORE
55174 bool "/proc/vmcore support"
55175 - depends on PROC_FS && CRASH_DUMP
55176 - default y
55177 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
55178 + default n
55179 help
55180 Exports the dump image of crashed kernel in ELF format.
55181
55182 @@ -59,8 +59,8 @@ config PROC_SYSCTL
55183 limited in memory.
55184
55185 config PROC_PAGE_MONITOR
55186 - default y
55187 - depends on PROC_FS && MMU
55188 + default n
55189 + depends on PROC_FS && MMU && !GRKERNSEC
55190 bool "Enable /proc page monitoring" if EXPERT
55191 help
55192 Various /proc files exist to monitor process memory utilization:
55193 diff --git a/fs/proc/array.c b/fs/proc/array.c
55194 index cbd0f1b..adec3f0 100644
55195 --- a/fs/proc/array.c
55196 +++ b/fs/proc/array.c
55197 @@ -60,6 +60,7 @@
55198 #include <linux/tty.h>
55199 #include <linux/string.h>
55200 #include <linux/mman.h>
55201 +#include <linux/grsecurity.h>
55202 #include <linux/proc_fs.h>
55203 #include <linux/ioport.h>
55204 #include <linux/uaccess.h>
55205 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55206 seq_putc(m, '\n');
55207 }
55208
55209 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55210 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55211 +{
55212 + if (p->mm)
55213 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55214 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55215 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55216 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55217 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55218 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55219 + else
55220 + seq_printf(m, "PaX:\t-----\n");
55221 +}
55222 +#endif
55223 +
55224 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55225 struct pid *pid, struct task_struct *task)
55226 {
55227 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55228 task_cpus_allowed(m, task);
55229 cpuset_task_status_allowed(m, task);
55230 task_context_switch_counts(m, task);
55231 +
55232 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55233 + task_pax(m, task);
55234 +#endif
55235 +
55236 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55237 + task_grsec_rbac(m, task);
55238 +#endif
55239 +
55240 return 0;
55241 }
55242
55243 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55244 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55245 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55246 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55247 +#endif
55248 +
55249 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55250 struct pid *pid, struct task_struct *task, int whole)
55251 {
55252 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55253 char tcomm[sizeof(task->comm)];
55254 unsigned long flags;
55255
55256 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55257 + if (current->exec_id != m->exec_id) {
55258 + gr_log_badprocpid("stat");
55259 + return 0;
55260 + }
55261 +#endif
55262 +
55263 state = *get_task_state(task);
55264 vsize = eip = esp = 0;
55265 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55266 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55267 gtime = task_gtime(task);
55268 }
55269
55270 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55271 + if (PAX_RAND_FLAGS(mm)) {
55272 + eip = 0;
55273 + esp = 0;
55274 + wchan = 0;
55275 + }
55276 +#endif
55277 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55278 + wchan = 0;
55279 + eip =0;
55280 + esp =0;
55281 +#endif
55282 +
55283 /* scale priority and nice values from timeslices to -20..20 */
55284 /* to make it look like a "normal" Unix priority/nice value */
55285 priority = task_prio(task);
55286 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55287 seq_put_decimal_ull(m, ' ', vsize);
55288 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55289 seq_put_decimal_ull(m, ' ', rsslim);
55290 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55291 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55292 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55293 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55294 +#else
55295 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55296 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55297 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55298 +#endif
55299 seq_put_decimal_ull(m, ' ', esp);
55300 seq_put_decimal_ull(m, ' ', eip);
55301 /* The signal information here is obsolete.
55302 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55303 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55304 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55305
55306 - if (mm && permitted) {
55307 + if (mm && permitted
55308 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55309 + && !PAX_RAND_FLAGS(mm)
55310 +#endif
55311 + ) {
55312 seq_put_decimal_ull(m, ' ', mm->start_data);
55313 seq_put_decimal_ull(m, ' ', mm->end_data);
55314 seq_put_decimal_ull(m, ' ', mm->start_brk);
55315 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55316 struct pid *pid, struct task_struct *task)
55317 {
55318 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55319 - struct mm_struct *mm = get_task_mm(task);
55320 + struct mm_struct *mm;
55321
55322 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55323 + if (current->exec_id != m->exec_id) {
55324 + gr_log_badprocpid("statm");
55325 + return 0;
55326 + }
55327 +#endif
55328 + mm = get_task_mm(task);
55329 if (mm) {
55330 size = task_statm(mm, &shared, &text, &data, &resident);
55331 mmput(mm);
55332 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55333 return 0;
55334 }
55335
55336 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55337 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55338 +{
55339 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55340 +}
55341 +#endif
55342 +
55343 #ifdef CONFIG_CHECKPOINT_RESTORE
55344 static struct pid *
55345 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55346 diff --git a/fs/proc/base.c b/fs/proc/base.c
55347 index c3834da..b402b2b 100644
55348 --- a/fs/proc/base.c
55349 +++ b/fs/proc/base.c
55350 @@ -113,6 +113,14 @@ struct pid_entry {
55351 union proc_op op;
55352 };
55353
55354 +struct getdents_callback {
55355 + struct linux_dirent __user * current_dir;
55356 + struct linux_dirent __user * previous;
55357 + struct file * file;
55358 + int count;
55359 + int error;
55360 +};
55361 +
55362 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55363 .name = (NAME), \
55364 .len = sizeof(NAME) - 1, \
55365 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55366 if (!mm->arg_end)
55367 goto out_mm; /* Shh! No looking before we're done */
55368
55369 + if (gr_acl_handle_procpidmem(task))
55370 + goto out_mm;
55371 +
55372 len = mm->arg_end - mm->arg_start;
55373
55374 if (len > PAGE_SIZE)
55375 @@ -237,12 +248,28 @@ out:
55376 return res;
55377 }
55378
55379 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55380 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55381 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55382 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55383 +#endif
55384 +
55385 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55386 {
55387 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55388 int res = PTR_ERR(mm);
55389 if (mm && !IS_ERR(mm)) {
55390 unsigned int nwords = 0;
55391 +
55392 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55393 + /* allow if we're currently ptracing this task */
55394 + if (PAX_RAND_FLAGS(mm) &&
55395 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55396 + mmput(mm);
55397 + return 0;
55398 + }
55399 +#endif
55400 +
55401 do {
55402 nwords += 2;
55403 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55404 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55405 }
55406
55407
55408 -#ifdef CONFIG_KALLSYMS
55409 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55410 /*
55411 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55412 * Returns the resolved symbol. If that fails, simply return the address.
55413 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
55414 mutex_unlock(&task->signal->cred_guard_mutex);
55415 }
55416
55417 -#ifdef CONFIG_STACKTRACE
55418 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55419
55420 #define MAX_STACK_TRACE_DEPTH 64
55421
55422 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55423 return count;
55424 }
55425
55426 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55427 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55428 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55429 {
55430 long nr;
55431 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55432 /************************************************************************/
55433
55434 /* permission checks */
55435 -static int proc_fd_access_allowed(struct inode *inode)
55436 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55437 {
55438 struct task_struct *task;
55439 int allowed = 0;
55440 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55441 */
55442 task = get_proc_task(inode);
55443 if (task) {
55444 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55445 + if (log)
55446 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55447 + else
55448 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55449 put_task_struct(task);
55450 }
55451 return allowed;
55452 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55453 struct task_struct *task,
55454 int hide_pid_min)
55455 {
55456 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55457 + return false;
55458 +
55459 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55460 + rcu_read_lock();
55461 + {
55462 + const struct cred *tmpcred = current_cred();
55463 + const struct cred *cred = __task_cred(task);
55464 +
55465 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55466 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55467 + || in_group_p(grsec_proc_gid)
55468 +#endif
55469 + ) {
55470 + rcu_read_unlock();
55471 + return true;
55472 + }
55473 + }
55474 + rcu_read_unlock();
55475 +
55476 + if (!pid->hide_pid)
55477 + return false;
55478 +#endif
55479 +
55480 if (pid->hide_pid < hide_pid_min)
55481 return true;
55482 if (in_group_p(pid->pid_gid))
55483 return true;
55484 +
55485 return ptrace_may_access(task, PTRACE_MODE_READ);
55486 }
55487
55488 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55489 put_task_struct(task);
55490
55491 if (!has_perms) {
55492 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55493 + {
55494 +#else
55495 if (pid->hide_pid == 2) {
55496 +#endif
55497 /*
55498 * Let's make getdents(), stat(), and open()
55499 * consistent with each other. If a process
55500 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55501 if (!task)
55502 return -ESRCH;
55503
55504 + if (gr_acl_handle_procpidmem(task)) {
55505 + put_task_struct(task);
55506 + return -EPERM;
55507 + }
55508 +
55509 mm = mm_access(task, mode);
55510 put_task_struct(task);
55511
55512 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55513
55514 file->private_data = mm;
55515
55516 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55517 + file->f_version = current->exec_id;
55518 +#endif
55519 +
55520 return 0;
55521 }
55522
55523 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55524 ssize_t copied;
55525 char *page;
55526
55527 +#ifdef CONFIG_GRKERNSEC
55528 + if (write)
55529 + return -EPERM;
55530 +#endif
55531 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55532 + if (file->f_version != current->exec_id) {
55533 + gr_log_badprocpid("mem");
55534 + return 0;
55535 + }
55536 +#endif
55537 +
55538 if (!mm)
55539 return 0;
55540
55541 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55542 goto free;
55543
55544 while (count > 0) {
55545 - int this_len = min_t(int, count, PAGE_SIZE);
55546 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55547
55548 if (write && copy_from_user(page, buf, this_len)) {
55549 copied = -EFAULT;
55550 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55551 if (!mm)
55552 return 0;
55553
55554 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55555 + if (file->f_version != current->exec_id) {
55556 + gr_log_badprocpid("environ");
55557 + return 0;
55558 + }
55559 +#endif
55560 +
55561 page = (char *)__get_free_page(GFP_TEMPORARY);
55562 if (!page)
55563 return -ENOMEM;
55564 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55565 goto free;
55566 while (count > 0) {
55567 size_t this_len, max_len;
55568 - int retval;
55569 + ssize_t retval;
55570
55571 if (src >= (mm->env_end - mm->env_start))
55572 break;
55573 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55574 int error = -EACCES;
55575
55576 /* Are we allowed to snoop on the tasks file descriptors? */
55577 - if (!proc_fd_access_allowed(inode))
55578 + if (!proc_fd_access_allowed(inode, 0))
55579 goto out;
55580
55581 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55582 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55583 struct path path;
55584
55585 /* Are we allowed to snoop on the tasks file descriptors? */
55586 - if (!proc_fd_access_allowed(inode))
55587 - goto out;
55588 + /* logging this is needed for learning on chromium to work properly,
55589 + but we don't want to flood the logs from 'ps' which does a readlink
55590 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55591 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55592 + */
55593 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55594 + if (!proc_fd_access_allowed(inode,0))
55595 + goto out;
55596 + } else {
55597 + if (!proc_fd_access_allowed(inode,1))
55598 + goto out;
55599 + }
55600
55601 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55602 if (error)
55603 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55604 rcu_read_lock();
55605 cred = __task_cred(task);
55606 inode->i_uid = cred->euid;
55607 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55608 + inode->i_gid = grsec_proc_gid;
55609 +#else
55610 inode->i_gid = cred->egid;
55611 +#endif
55612 rcu_read_unlock();
55613 }
55614 security_task_to_inode(task, inode);
55615 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55616 return -ENOENT;
55617 }
55618 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55619 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55620 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55621 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55622 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55623 +#endif
55624 task_dumpable(task)) {
55625 cred = __task_cred(task);
55626 stat->uid = cred->euid;
55627 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55628 + stat->gid = grsec_proc_gid;
55629 +#else
55630 stat->gid = cred->egid;
55631 +#endif
55632 }
55633 }
55634 rcu_read_unlock();
55635 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55636
55637 if (task) {
55638 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55639 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55640 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55641 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55642 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55643 +#endif
55644 task_dumpable(task)) {
55645 rcu_read_lock();
55646 cred = __task_cred(task);
55647 inode->i_uid = cred->euid;
55648 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55649 + inode->i_gid = grsec_proc_gid;
55650 +#else
55651 inode->i_gid = cred->egid;
55652 +#endif
55653 rcu_read_unlock();
55654 } else {
55655 inode->i_uid = GLOBAL_ROOT_UID;
55656 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55657 if (!task)
55658 goto out_no_task;
55659
55660 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55661 + goto out;
55662 +
55663 /*
55664 * Yes, it does not scale. And it should not. Don't add
55665 * new entries into /proc/<tgid>/ without very good reasons.
55666 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
55667 if (!task)
55668 goto out_no_task;
55669
55670 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55671 + goto out;
55672 +
55673 ret = 0;
55674 i = filp->f_pos;
55675 switch (i) {
55676 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55677 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55678 #endif
55679 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55680 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55681 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55682 INF("syscall", S_IRUGO, proc_pid_syscall),
55683 #endif
55684 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55685 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55686 #ifdef CONFIG_SECURITY
55687 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55688 #endif
55689 -#ifdef CONFIG_KALLSYMS
55690 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55691 INF("wchan", S_IRUGO, proc_pid_wchan),
55692 #endif
55693 -#ifdef CONFIG_STACKTRACE
55694 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55695 ONE("stack", S_IRUGO, proc_pid_stack),
55696 #endif
55697 #ifdef CONFIG_SCHEDSTATS
55698 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55699 #ifdef CONFIG_HARDWALL
55700 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55701 #endif
55702 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55703 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55704 +#endif
55705 #ifdef CONFIG_USER_NS
55706 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55707 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55708 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55709 if (!inode)
55710 goto out;
55711
55712 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55713 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55714 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55715 + inode->i_gid = grsec_proc_gid;
55716 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55717 +#else
55718 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55719 +#endif
55720 inode->i_op = &proc_tgid_base_inode_operations;
55721 inode->i_fop = &proc_tgid_base_operations;
55722 inode->i_flags|=S_IMMUTABLE;
55723 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55724 if (!task)
55725 goto out;
55726
55727 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55728 + goto out_put_task;
55729 +
55730 result = proc_pid_instantiate(dir, dentry, task, NULL);
55731 +out_put_task:
55732 put_task_struct(task);
55733 out:
55734 return result;
55735 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55736 static int fake_filldir(void *buf, const char *name, int namelen,
55737 loff_t offset, u64 ino, unsigned d_type)
55738 {
55739 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55740 + __buf->error = -EINVAL;
55741 return 0;
55742 }
55743
55744 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
55745 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55746 #endif
55747 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55748 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55749 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55750 INF("syscall", S_IRUGO, proc_pid_syscall),
55751 #endif
55752 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55753 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
55754 #ifdef CONFIG_SECURITY
55755 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55756 #endif
55757 -#ifdef CONFIG_KALLSYMS
55758 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55759 INF("wchan", S_IRUGO, proc_pid_wchan),
55760 #endif
55761 -#ifdef CONFIG_STACKTRACE
55762 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55763 ONE("stack", S_IRUGO, proc_pid_stack),
55764 #endif
55765 #ifdef CONFIG_SCHEDSTATS
55766 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55767 index 82676e3..5f8518a 100644
55768 --- a/fs/proc/cmdline.c
55769 +++ b/fs/proc/cmdline.c
55770 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55771
55772 static int __init proc_cmdline_init(void)
55773 {
55774 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55775 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55776 +#else
55777 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55778 +#endif
55779 return 0;
55780 }
55781 module_init(proc_cmdline_init);
55782 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55783 index b143471..bb105e5 100644
55784 --- a/fs/proc/devices.c
55785 +++ b/fs/proc/devices.c
55786 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55787
55788 static int __init proc_devices_init(void)
55789 {
55790 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55791 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55792 +#else
55793 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55794 +#endif
55795 return 0;
55796 }
55797 module_init(proc_devices_init);
55798 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55799 index d7a4a28..0201742 100644
55800 --- a/fs/proc/fd.c
55801 +++ b/fs/proc/fd.c
55802 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55803 if (!task)
55804 return -ENOENT;
55805
55806 - files = get_files_struct(task);
55807 + if (!gr_acl_handle_procpidmem(task))
55808 + files = get_files_struct(task);
55809 put_task_struct(task);
55810
55811 if (files) {
55812 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55813 */
55814 int proc_fd_permission(struct inode *inode, int mask)
55815 {
55816 + struct task_struct *task;
55817 int rv = generic_permission(inode, mask);
55818 - if (rv == 0)
55819 - return 0;
55820 +
55821 if (task_pid(current) == proc_pid(inode))
55822 rv = 0;
55823 +
55824 + task = get_proc_task(inode);
55825 + if (task == NULL)
55826 + return rv;
55827 +
55828 + if (gr_acl_handle_procpidmem(task))
55829 + rv = -EACCES;
55830 +
55831 + put_task_struct(task);
55832 +
55833 return rv;
55834 }
55835
55836 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55837 index 073aea6..0630370 100644
55838 --- a/fs/proc/inode.c
55839 +++ b/fs/proc/inode.c
55840 @@ -23,11 +23,17 @@
55841 #include <linux/slab.h>
55842 #include <linux/mount.h>
55843 #include <linux/magic.h>
55844 +#include <linux/grsecurity.h>
55845
55846 #include <asm/uaccess.h>
55847
55848 #include "internal.h"
55849
55850 +#ifdef CONFIG_PROC_SYSCTL
55851 +extern const struct inode_operations proc_sys_inode_operations;
55852 +extern const struct inode_operations proc_sys_dir_operations;
55853 +#endif
55854 +
55855 static void proc_evict_inode(struct inode *inode)
55856 {
55857 struct proc_dir_entry *de;
55858 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
55859 ns = PROC_I(inode)->ns.ns;
55860 if (ns_ops && ns)
55861 ns_ops->put(ns);
55862 +
55863 +#ifdef CONFIG_PROC_SYSCTL
55864 + if (inode->i_op == &proc_sys_inode_operations ||
55865 + inode->i_op == &proc_sys_dir_operations)
55866 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55867 +#endif
55868 +
55869 }
55870
55871 static struct kmem_cache * proc_inode_cachep;
55872 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55873 if (de->mode) {
55874 inode->i_mode = de->mode;
55875 inode->i_uid = de->uid;
55876 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55877 + inode->i_gid = grsec_proc_gid;
55878 +#else
55879 inode->i_gid = de->gid;
55880 +#endif
55881 }
55882 if (de->size)
55883 inode->i_size = de->size;
55884 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55885 index d600fb0..3b495fe 100644
55886 --- a/fs/proc/internal.h
55887 +++ b/fs/proc/internal.h
55888 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
55889 struct pid *, struct task_struct *);
55890 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
55891 struct pid *, struct task_struct *);
55892 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55893 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55894 +#endif
55895
55896 /*
55897 * base.c
55898 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55899 index 0a22194..a9fc8c1 100644
55900 --- a/fs/proc/kcore.c
55901 +++ b/fs/proc/kcore.c
55902 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55903 * the addresses in the elf_phdr on our list.
55904 */
55905 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55906 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55907 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55908 + if (tsz > buflen)
55909 tsz = buflen;
55910 -
55911 +
55912 while (buflen) {
55913 struct kcore_list *m;
55914
55915 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55916 kfree(elf_buf);
55917 } else {
55918 if (kern_addr_valid(start)) {
55919 - unsigned long n;
55920 + char *elf_buf;
55921 + mm_segment_t oldfs;
55922
55923 - n = copy_to_user(buffer, (char *)start, tsz);
55924 - /*
55925 - * We cannot distinguish between fault on source
55926 - * and fault on destination. When this happens
55927 - * we clear too and hope it will trigger the
55928 - * EFAULT again.
55929 - */
55930 - if (n) {
55931 - if (clear_user(buffer + tsz - n,
55932 - n))
55933 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55934 + if (!elf_buf)
55935 + return -ENOMEM;
55936 + oldfs = get_fs();
55937 + set_fs(KERNEL_DS);
55938 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55939 + set_fs(oldfs);
55940 + if (copy_to_user(buffer, elf_buf, tsz)) {
55941 + kfree(elf_buf);
55942 return -EFAULT;
55943 + }
55944 }
55945 + set_fs(oldfs);
55946 + kfree(elf_buf);
55947 } else {
55948 if (clear_user(buffer, tsz))
55949 return -EFAULT;
55950 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55951
55952 static int open_kcore(struct inode *inode, struct file *filp)
55953 {
55954 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55955 + return -EPERM;
55956 +#endif
55957 if (!capable(CAP_SYS_RAWIO))
55958 return -EPERM;
55959 if (kcore_need_update)
55960 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55961 index 5aa847a..f77c8d4 100644
55962 --- a/fs/proc/meminfo.c
55963 +++ b/fs/proc/meminfo.c
55964 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55965 vmi.used >> 10,
55966 vmi.largest_chunk >> 10
55967 #ifdef CONFIG_MEMORY_FAILURE
55968 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55969 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55970 #endif
55971 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55972 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55973 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55974 index ccfd99b..1b7e255 100644
55975 --- a/fs/proc/nommu.c
55976 +++ b/fs/proc/nommu.c
55977 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55978 if (len < 1)
55979 len = 1;
55980 seq_printf(m, "%*c", len, ' ');
55981 - seq_path(m, &file->f_path, "");
55982 + seq_path(m, &file->f_path, "\n\\");
55983 }
55984
55985 seq_putc(m, '\n');
55986 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55987 index 986e832..6e8e859 100644
55988 --- a/fs/proc/proc_net.c
55989 +++ b/fs/proc/proc_net.c
55990 @@ -23,6 +23,7 @@
55991 #include <linux/nsproxy.h>
55992 #include <net/net_namespace.h>
55993 #include <linux/seq_file.h>
55994 +#include <linux/grsecurity.h>
55995
55996 #include "internal.h"
55997
55998 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55999 struct task_struct *task;
56000 struct nsproxy *ns;
56001 struct net *net = NULL;
56002 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56003 + const struct cred *cred = current_cred();
56004 +#endif
56005 +
56006 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56007 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
56008 + return net;
56009 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56010 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
56011 + return net;
56012 +#endif
56013
56014 rcu_read_lock();
56015 task = pid_task(proc_pid(dir), PIDTYPE_PID);
56016 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
56017 index ac05f33..1e6dc7e 100644
56018 --- a/fs/proc/proc_sysctl.c
56019 +++ b/fs/proc/proc_sysctl.c
56020 @@ -13,11 +13,15 @@
56021 #include <linux/module.h>
56022 #include "internal.h"
56023
56024 +extern int gr_handle_chroot_sysctl(const int op);
56025 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
56026 + const int op);
56027 +
56028 static const struct dentry_operations proc_sys_dentry_operations;
56029 static const struct file_operations proc_sys_file_operations;
56030 -static const struct inode_operations proc_sys_inode_operations;
56031 +const struct inode_operations proc_sys_inode_operations;
56032 static const struct file_operations proc_sys_dir_file_operations;
56033 -static const struct inode_operations proc_sys_dir_operations;
56034 +const struct inode_operations proc_sys_dir_operations;
56035
56036 void proc_sys_poll_notify(struct ctl_table_poll *poll)
56037 {
56038 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
56039
56040 err = NULL;
56041 d_set_d_op(dentry, &proc_sys_dentry_operations);
56042 +
56043 + gr_handle_proc_create(dentry, inode);
56044 +
56045 d_add(dentry, inode);
56046
56047 out:
56048 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56049 struct inode *inode = file_inode(filp);
56050 struct ctl_table_header *head = grab_header(inode);
56051 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
56052 + int op = write ? MAY_WRITE : MAY_READ;
56053 ssize_t error;
56054 size_t res;
56055
56056 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56057 * and won't be until we finish.
56058 */
56059 error = -EPERM;
56060 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
56061 + if (sysctl_perm(head, table, op))
56062 goto out;
56063
56064 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
56065 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56066 if (!table->proc_handler)
56067 goto out;
56068
56069 +#ifdef CONFIG_GRKERNSEC
56070 + error = -EPERM;
56071 + if (gr_handle_chroot_sysctl(op))
56072 + goto out;
56073 + dget(filp->f_path.dentry);
56074 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
56075 + dput(filp->f_path.dentry);
56076 + goto out;
56077 + }
56078 + dput(filp->f_path.dentry);
56079 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
56080 + goto out;
56081 + if (write && !capable(CAP_SYS_ADMIN))
56082 + goto out;
56083 +#endif
56084 +
56085 /* careful: calling conventions are nasty here */
56086 res = count;
56087 error = table->proc_handler(table, write, buf, &res, ppos);
56088 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
56089 return -ENOMEM;
56090 } else {
56091 d_set_d_op(child, &proc_sys_dentry_operations);
56092 +
56093 + gr_handle_proc_create(child, inode);
56094 +
56095 d_add(child, inode);
56096 }
56097 } else {
56098 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
56099 if ((*pos)++ < file->f_pos)
56100 return 0;
56101
56102 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
56103 + return 0;
56104 +
56105 if (unlikely(S_ISLNK(table->mode)))
56106 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
56107 else
56108 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
56109 if (IS_ERR(head))
56110 return PTR_ERR(head);
56111
56112 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
56113 + return -ENOENT;
56114 +
56115 generic_fillattr(inode, stat);
56116 if (table)
56117 stat->mode = (stat->mode & S_IFMT) | table->mode;
56118 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
56119 .llseek = generic_file_llseek,
56120 };
56121
56122 -static const struct inode_operations proc_sys_inode_operations = {
56123 +const struct inode_operations proc_sys_inode_operations = {
56124 .permission = proc_sys_permission,
56125 .setattr = proc_sys_setattr,
56126 .getattr = proc_sys_getattr,
56127 };
56128
56129 -static const struct inode_operations proc_sys_dir_operations = {
56130 +const struct inode_operations proc_sys_dir_operations = {
56131 .lookup = proc_sys_lookup,
56132 .permission = proc_sys_permission,
56133 .setattr = proc_sys_setattr,
56134 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
56135 static struct ctl_dir *new_dir(struct ctl_table_set *set,
56136 const char *name, int namelen)
56137 {
56138 - struct ctl_table *table;
56139 + ctl_table_no_const *table;
56140 struct ctl_dir *new;
56141 struct ctl_node *node;
56142 char *new_name;
56143 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
56144 return NULL;
56145
56146 node = (struct ctl_node *)(new + 1);
56147 - table = (struct ctl_table *)(node + 1);
56148 + table = (ctl_table_no_const *)(node + 1);
56149 new_name = (char *)(table + 2);
56150 memcpy(new_name, name, namelen);
56151 new_name[namelen] = '\0';
56152 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
56153 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
56154 struct ctl_table_root *link_root)
56155 {
56156 - struct ctl_table *link_table, *entry, *link;
56157 + ctl_table_no_const *link_table, *link;
56158 + struct ctl_table *entry;
56159 struct ctl_table_header *links;
56160 struct ctl_node *node;
56161 char *link_name;
56162 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
56163 return NULL;
56164
56165 node = (struct ctl_node *)(links + 1);
56166 - link_table = (struct ctl_table *)(node + nr_entries);
56167 + link_table = (ctl_table_no_const *)(node + nr_entries);
56168 link_name = (char *)&link_table[nr_entries + 1];
56169
56170 for (link = link_table, entry = table; entry->procname; link++, entry++) {
56171 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56172 struct ctl_table_header ***subheader, struct ctl_table_set *set,
56173 struct ctl_table *table)
56174 {
56175 - struct ctl_table *ctl_table_arg = NULL;
56176 - struct ctl_table *entry, *files;
56177 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
56178 + struct ctl_table *entry;
56179 int nr_files = 0;
56180 int nr_dirs = 0;
56181 int err = -ENOMEM;
56182 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56183 nr_files++;
56184 }
56185
56186 - files = table;
56187 /* If there are mixed files and directories we need a new table */
56188 if (nr_dirs && nr_files) {
56189 - struct ctl_table *new;
56190 + ctl_table_no_const *new;
56191 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
56192 GFP_KERNEL);
56193 if (!files)
56194 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56195 /* Register everything except a directory full of subdirectories */
56196 if (nr_files || !nr_dirs) {
56197 struct ctl_table_header *header;
56198 - header = __register_sysctl_table(set, path, files);
56199 + header = __register_sysctl_table(set, path, files ? files : table);
56200 if (!header) {
56201 kfree(ctl_table_arg);
56202 goto out;
56203 diff --git a/fs/proc/root.c b/fs/proc/root.c
56204 index 41a6ea9..23eaa92 100644
56205 --- a/fs/proc/root.c
56206 +++ b/fs/proc/root.c
56207 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
56208 #ifdef CONFIG_PROC_DEVICETREE
56209 proc_device_tree_init();
56210 #endif
56211 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56212 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56213 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56214 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56215 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56216 +#endif
56217 +#else
56218 proc_mkdir("bus", NULL);
56219 +#endif
56220 proc_sys_init();
56221 }
56222
56223 diff --git a/fs/proc/self.c b/fs/proc/self.c
56224 index 6b6a993..807cccc 100644
56225 --- a/fs/proc/self.c
56226 +++ b/fs/proc/self.c
56227 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56228 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56229 void *cookie)
56230 {
56231 - char *s = nd_get_link(nd);
56232 + const char *s = nd_get_link(nd);
56233 if (!IS_ERR(s))
56234 kfree(s);
56235 }
56236 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56237 index 3e636d8..83e3b71 100644
56238 --- a/fs/proc/task_mmu.c
56239 +++ b/fs/proc/task_mmu.c
56240 @@ -11,12 +11,19 @@
56241 #include <linux/rmap.h>
56242 #include <linux/swap.h>
56243 #include <linux/swapops.h>
56244 +#include <linux/grsecurity.h>
56245
56246 #include <asm/elf.h>
56247 #include <asm/uaccess.h>
56248 #include <asm/tlbflush.h>
56249 #include "internal.h"
56250
56251 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56252 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56253 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56254 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56255 +#endif
56256 +
56257 void task_mem(struct seq_file *m, struct mm_struct *mm)
56258 {
56259 unsigned long data, text, lib, swap;
56260 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56261 "VmExe:\t%8lu kB\n"
56262 "VmLib:\t%8lu kB\n"
56263 "VmPTE:\t%8lu kB\n"
56264 - "VmSwap:\t%8lu kB\n",
56265 - hiwater_vm << (PAGE_SHIFT-10),
56266 + "VmSwap:\t%8lu kB\n"
56267 +
56268 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56269 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56270 +#endif
56271 +
56272 + ,hiwater_vm << (PAGE_SHIFT-10),
56273 total_vm << (PAGE_SHIFT-10),
56274 mm->locked_vm << (PAGE_SHIFT-10),
56275 mm->pinned_vm << (PAGE_SHIFT-10),
56276 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56277 data << (PAGE_SHIFT-10),
56278 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56279 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56280 - swap << (PAGE_SHIFT-10));
56281 + swap << (PAGE_SHIFT-10)
56282 +
56283 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56284 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56285 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56286 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56287 +#else
56288 + , mm->context.user_cs_base
56289 + , mm->context.user_cs_limit
56290 +#endif
56291 +#endif
56292 +
56293 + );
56294 }
56295
56296 unsigned long task_vsize(struct mm_struct *mm)
56297 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56298 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56299 }
56300
56301 - /* We don't show the stack guard page in /proc/maps */
56302 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56303 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56304 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56305 +#else
56306 start = vma->vm_start;
56307 - if (stack_guard_page_start(vma, start))
56308 - start += PAGE_SIZE;
56309 end = vma->vm_end;
56310 - if (stack_guard_page_end(vma, end))
56311 - end -= PAGE_SIZE;
56312 +#endif
56313
56314 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56315 start,
56316 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56317 flags & VM_WRITE ? 'w' : '-',
56318 flags & VM_EXEC ? 'x' : '-',
56319 flags & VM_MAYSHARE ? 's' : 'p',
56320 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56321 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56322 +#else
56323 pgoff,
56324 +#endif
56325 MAJOR(dev), MINOR(dev), ino, &len);
56326
56327 /*
56328 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56329 */
56330 if (file) {
56331 pad_len_spaces(m, len);
56332 - seq_path(m, &file->f_path, "\n");
56333 + seq_path(m, &file->f_path, "\n\\");
56334 goto done;
56335 }
56336
56337 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56338 * Thread stack in /proc/PID/task/TID/maps or
56339 * the main process stack.
56340 */
56341 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56342 - vma->vm_end >= mm->start_stack)) {
56343 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56344 + (vma->vm_start <= mm->start_stack &&
56345 + vma->vm_end >= mm->start_stack)) {
56346 name = "[stack]";
56347 } else {
56348 /* Thread stack in /proc/PID/maps */
56349 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56350 struct proc_maps_private *priv = m->private;
56351 struct task_struct *task = priv->task;
56352
56353 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56354 + if (current->exec_id != m->exec_id) {
56355 + gr_log_badprocpid("maps");
56356 + return 0;
56357 + }
56358 +#endif
56359 +
56360 show_map_vma(m, vma, is_pid);
56361
56362 if (m->count < m->size) /* vma is copied successfully */
56363 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56364 .private = &mss,
56365 };
56366
56367 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56368 + if (current->exec_id != m->exec_id) {
56369 + gr_log_badprocpid("smaps");
56370 + return 0;
56371 + }
56372 +#endif
56373 memset(&mss, 0, sizeof mss);
56374 - mss.vma = vma;
56375 - /* mmap_sem is held in m_start */
56376 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56377 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56378 -
56379 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56380 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56381 +#endif
56382 + mss.vma = vma;
56383 + /* mmap_sem is held in m_start */
56384 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56385 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56386 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56387 + }
56388 +#endif
56389 show_map_vma(m, vma, is_pid);
56390
56391 seq_printf(m,
56392 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56393 "KernelPageSize: %8lu kB\n"
56394 "MMUPageSize: %8lu kB\n"
56395 "Locked: %8lu kB\n",
56396 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56397 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56398 +#else
56399 (vma->vm_end - vma->vm_start) >> 10,
56400 +#endif
56401 mss.resident >> 10,
56402 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56403 mss.shared_clean >> 10,
56404 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56405 int n;
56406 char buffer[50];
56407
56408 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56409 + if (current->exec_id != m->exec_id) {
56410 + gr_log_badprocpid("numa_maps");
56411 + return 0;
56412 + }
56413 +#endif
56414 +
56415 if (!mm)
56416 return 0;
56417
56418 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56419 mpol_to_str(buffer, sizeof(buffer), pol);
56420 mpol_cond_put(pol);
56421
56422 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56423 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56424 +#else
56425 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56426 +#endif
56427
56428 if (file) {
56429 seq_printf(m, " file=");
56430 - seq_path(m, &file->f_path, "\n\t= ");
56431 + seq_path(m, &file->f_path, "\n\t\\= ");
56432 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56433 seq_printf(m, " heap");
56434 } else {
56435 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56436 index 56123a6..5a2f6ec 100644
56437 --- a/fs/proc/task_nommu.c
56438 +++ b/fs/proc/task_nommu.c
56439 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56440 else
56441 bytes += kobjsize(mm);
56442
56443 - if (current->fs && current->fs->users > 1)
56444 + if (current->fs && atomic_read(&current->fs->users) > 1)
56445 sbytes += kobjsize(current->fs);
56446 else
56447 bytes += kobjsize(current->fs);
56448 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56449
56450 if (file) {
56451 pad_len_spaces(m, len);
56452 - seq_path(m, &file->f_path, "");
56453 + seq_path(m, &file->f_path, "\n\\");
56454 } else if (mm) {
56455 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56456
56457 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
56458 index 17f7e08..e4b1529 100644
56459 --- a/fs/proc/vmcore.c
56460 +++ b/fs/proc/vmcore.c
56461 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
56462 nr_bytes = count;
56463
56464 /* If pfn is not ram, return zeros for sparse dump files */
56465 - if (pfn_is_ram(pfn) == 0)
56466 - memset(buf, 0, nr_bytes);
56467 - else {
56468 + if (pfn_is_ram(pfn) == 0) {
56469 + if (userbuf) {
56470 + if (clear_user((char __force_user *)buf, nr_bytes))
56471 + return -EFAULT;
56472 + } else
56473 + memset(buf, 0, nr_bytes);
56474 + } else {
56475 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
56476 offset, userbuf);
56477 if (tmp < 0)
56478 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
56479 if (tsz > nr_bytes)
56480 tsz = nr_bytes;
56481
56482 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
56483 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
56484 if (tmp < 0)
56485 return tmp;
56486 buflen -= tsz;
56487 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56488 index b00fcc9..e0c6381 100644
56489 --- a/fs/qnx6/qnx6.h
56490 +++ b/fs/qnx6/qnx6.h
56491 @@ -74,7 +74,7 @@ enum {
56492 BYTESEX_BE,
56493 };
56494
56495 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56496 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56497 {
56498 if (sbi->s_bytesex == BYTESEX_LE)
56499 return le64_to_cpu((__force __le64)n);
56500 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56501 return (__force __fs64)cpu_to_be64(n);
56502 }
56503
56504 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56505 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56506 {
56507 if (sbi->s_bytesex == BYTESEX_LE)
56508 return le32_to_cpu((__force __le32)n);
56509 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56510 index 16e8abb..2dcf914 100644
56511 --- a/fs/quota/netlink.c
56512 +++ b/fs/quota/netlink.c
56513 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56514 void quota_send_warning(struct kqid qid, dev_t dev,
56515 const char warntype)
56516 {
56517 - static atomic_t seq;
56518 + static atomic_unchecked_t seq;
56519 struct sk_buff *skb;
56520 void *msg_head;
56521 int ret;
56522 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56523 "VFS: Not enough memory to send quota warning.\n");
56524 return;
56525 }
56526 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56527 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56528 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56529 if (!msg_head) {
56530 printk(KERN_ERR
56531 diff --git a/fs/read_write.c b/fs/read_write.c
56532 index 2cefa41..c7e2fe0 100644
56533 --- a/fs/read_write.c
56534 +++ b/fs/read_write.c
56535 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
56536
56537 old_fs = get_fs();
56538 set_fs(get_ds());
56539 - p = (__force const char __user *)buf;
56540 + p = (const char __force_user *)buf;
56541 if (count > MAX_RW_COUNT)
56542 count = MAX_RW_COUNT;
56543 if (file->f_op->write)
56544 diff --git a/fs/readdir.c b/fs/readdir.c
56545 index fee38e0..12fdf47 100644
56546 --- a/fs/readdir.c
56547 +++ b/fs/readdir.c
56548 @@ -17,6 +17,7 @@
56549 #include <linux/security.h>
56550 #include <linux/syscalls.h>
56551 #include <linux/unistd.h>
56552 +#include <linux/namei.h>
56553
56554 #include <asm/uaccess.h>
56555
56556 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56557
56558 struct readdir_callback {
56559 struct old_linux_dirent __user * dirent;
56560 + struct file * file;
56561 int result;
56562 };
56563
56564 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56565 buf->result = -EOVERFLOW;
56566 return -EOVERFLOW;
56567 }
56568 +
56569 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56570 + return 0;
56571 +
56572 buf->result++;
56573 dirent = buf->dirent;
56574 if (!access_ok(VERIFY_WRITE, dirent,
56575 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56576
56577 buf.result = 0;
56578 buf.dirent = dirent;
56579 + buf.file = f.file;
56580
56581 error = vfs_readdir(f.file, fillonedir, &buf);
56582 if (buf.result)
56583 @@ -139,6 +146,7 @@ struct linux_dirent {
56584 struct getdents_callback {
56585 struct linux_dirent __user * current_dir;
56586 struct linux_dirent __user * previous;
56587 + struct file * file;
56588 int count;
56589 int error;
56590 };
56591 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56592 buf->error = -EOVERFLOW;
56593 return -EOVERFLOW;
56594 }
56595 +
56596 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56597 + return 0;
56598 +
56599 dirent = buf->previous;
56600 if (dirent) {
56601 if (__put_user(offset, &dirent->d_off))
56602 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56603 buf.previous = NULL;
56604 buf.count = count;
56605 buf.error = 0;
56606 + buf.file = f.file;
56607
56608 error = vfs_readdir(f.file, filldir, &buf);
56609 if (error >= 0)
56610 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56611 struct getdents_callback64 {
56612 struct linux_dirent64 __user * current_dir;
56613 struct linux_dirent64 __user * previous;
56614 + struct file *file;
56615 int count;
56616 int error;
56617 };
56618 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56619 buf->error = -EINVAL; /* only used if we fail.. */
56620 if (reclen > buf->count)
56621 return -EINVAL;
56622 +
56623 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56624 + return 0;
56625 +
56626 dirent = buf->previous;
56627 if (dirent) {
56628 if (__put_user(offset, &dirent->d_off))
56629 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56630
56631 buf.current_dir = dirent;
56632 buf.previous = NULL;
56633 + buf.file = f.file;
56634 buf.count = count;
56635 buf.error = 0;
56636
56637 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56638 error = buf.error;
56639 lastdirent = buf.previous;
56640 if (lastdirent) {
56641 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56642 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56643 if (__put_user(d_off, &lastdirent->d_off))
56644 error = -EFAULT;
56645 else
56646 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56647 index 2b7882b..1c5ef48 100644
56648 --- a/fs/reiserfs/do_balan.c
56649 +++ b/fs/reiserfs/do_balan.c
56650 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56651 return;
56652 }
56653
56654 - atomic_inc(&(fs_generation(tb->tb_sb)));
56655 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56656 do_balance_starts(tb);
56657
56658 /* balance leaf returns 0 except if combining L R and S into
56659 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56660 index 33532f7..4846ade 100644
56661 --- a/fs/reiserfs/procfs.c
56662 +++ b/fs/reiserfs/procfs.c
56663 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56664 "SMALL_TAILS " : "NO_TAILS ",
56665 replay_only(sb) ? "REPLAY_ONLY " : "",
56666 convert_reiserfs(sb) ? "CONV " : "",
56667 - atomic_read(&r->s_generation_counter),
56668 + atomic_read_unchecked(&r->s_generation_counter),
56669 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56670 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56671 SF(s_good_search_by_key_reada), SF(s_bmaps),
56672 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56673 index 157e474..65a6114 100644
56674 --- a/fs/reiserfs/reiserfs.h
56675 +++ b/fs/reiserfs/reiserfs.h
56676 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56677 /* Comment? -Hans */
56678 wait_queue_head_t s_wait;
56679 /* To be obsoleted soon by per buffer seals.. -Hans */
56680 - atomic_t s_generation_counter; // increased by one every time the
56681 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56682 // tree gets re-balanced
56683 unsigned long s_properties; /* File system properties. Currently holds
56684 on-disk FS format */
56685 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56686 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56687
56688 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56689 -#define get_generation(s) atomic_read (&fs_generation(s))
56690 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56691 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56692 #define __fs_changed(gen,s) (gen != get_generation (s))
56693 #define fs_changed(gen,s) \
56694 diff --git a/fs/select.c b/fs/select.c
56695 index 8c1c96c..a0f9b6d 100644
56696 --- a/fs/select.c
56697 +++ b/fs/select.c
56698 @@ -20,6 +20,7 @@
56699 #include <linux/export.h>
56700 #include <linux/slab.h>
56701 #include <linux/poll.h>
56702 +#include <linux/security.h>
56703 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56704 #include <linux/file.h>
56705 #include <linux/fdtable.h>
56706 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56707 struct poll_list *walk = head;
56708 unsigned long todo = nfds;
56709
56710 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56711 if (nfds > rlimit(RLIMIT_NOFILE))
56712 return -EINVAL;
56713
56714 diff --git a/fs/seq_file.c b/fs/seq_file.c
56715 index 774c1eb..b67582a 100644
56716 --- a/fs/seq_file.c
56717 +++ b/fs/seq_file.c
56718 @@ -10,6 +10,7 @@
56719 #include <linux/seq_file.h>
56720 #include <linux/slab.h>
56721 #include <linux/cred.h>
56722 +#include <linux/sched.h>
56723
56724 #include <asm/uaccess.h>
56725 #include <asm/page.h>
56726 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56727 #ifdef CONFIG_USER_NS
56728 p->user_ns = file->f_cred->user_ns;
56729 #endif
56730 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56731 + p->exec_id = current->exec_id;
56732 +#endif
56733
56734 /*
56735 * Wrappers around seq_open(e.g. swaps_open) need to be
56736 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56737 return 0;
56738 }
56739 if (!m->buf) {
56740 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56741 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56742 if (!m->buf)
56743 return -ENOMEM;
56744 }
56745 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56746 Eoverflow:
56747 m->op->stop(m, p);
56748 kfree(m->buf);
56749 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56750 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56751 return !m->buf ? -ENOMEM : -EAGAIN;
56752 }
56753
56754 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56755
56756 /* grab buffer if we didn't have one */
56757 if (!m->buf) {
56758 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56759 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56760 if (!m->buf)
56761 goto Enomem;
56762 }
56763 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56764 goto Fill;
56765 m->op->stop(m, p);
56766 kfree(m->buf);
56767 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56768 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56769 if (!m->buf)
56770 goto Enomem;
56771 m->count = 0;
56772 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56773 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56774 void *data)
56775 {
56776 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56777 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56778 int res = -ENOMEM;
56779
56780 if (op) {
56781 diff --git a/fs/splice.c b/fs/splice.c
56782 index d37431d..81c3044 100644
56783 --- a/fs/splice.c
56784 +++ b/fs/splice.c
56785 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56786 pipe_lock(pipe);
56787
56788 for (;;) {
56789 - if (!pipe->readers) {
56790 + if (!atomic_read(&pipe->readers)) {
56791 send_sig(SIGPIPE, current, 0);
56792 if (!ret)
56793 ret = -EPIPE;
56794 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56795 page_nr++;
56796 ret += buf->len;
56797
56798 - if (pipe->files)
56799 + if (atomic_read(&pipe->files))
56800 do_wakeup = 1;
56801
56802 if (!--spd->nr_pages)
56803 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56804 do_wakeup = 0;
56805 }
56806
56807 - pipe->waiting_writers++;
56808 + atomic_inc(&pipe->waiting_writers);
56809 pipe_wait(pipe);
56810 - pipe->waiting_writers--;
56811 + atomic_dec(&pipe->waiting_writers);
56812 }
56813
56814 pipe_unlock(pipe);
56815 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56816 old_fs = get_fs();
56817 set_fs(get_ds());
56818 /* The cast to a user pointer is valid due to the set_fs() */
56819 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56820 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56821 set_fs(old_fs);
56822
56823 return res;
56824 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56825 old_fs = get_fs();
56826 set_fs(get_ds());
56827 /* The cast to a user pointer is valid due to the set_fs() */
56828 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56829 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56830 set_fs(old_fs);
56831
56832 return res;
56833 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56834 goto err;
56835
56836 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56837 - vec[i].iov_base = (void __user *) page_address(page);
56838 + vec[i].iov_base = (void __force_user *) page_address(page);
56839 vec[i].iov_len = this_len;
56840 spd.pages[i] = page;
56841 spd.nr_pages++;
56842 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
56843 ops->release(pipe, buf);
56844 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
56845 pipe->nrbufs--;
56846 - if (pipe->files)
56847 + if (atomic_read(&pipe->files))
56848 sd->need_wakeup = true;
56849 }
56850
56851 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56852 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56853 {
56854 while (!pipe->nrbufs) {
56855 - if (!pipe->writers)
56856 + if (!atomic_read(&pipe->writers))
56857 return 0;
56858
56859 - if (!pipe->waiting_writers && sd->num_spliced)
56860 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56861 return 0;
56862
56863 if (sd->flags & SPLICE_F_NONBLOCK)
56864 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56865 * out of the pipe right after the splice_to_pipe(). So set
56866 * PIPE_READERS appropriately.
56867 */
56868 - pipe->readers = 1;
56869 + atomic_set(&pipe->readers, 1);
56870
56871 current->splice_pipe = pipe;
56872 }
56873 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56874 ret = -ERESTARTSYS;
56875 break;
56876 }
56877 - if (!pipe->writers)
56878 + if (!atomic_read(&pipe->writers))
56879 break;
56880 - if (!pipe->waiting_writers) {
56881 + if (!atomic_read(&pipe->waiting_writers)) {
56882 if (flags & SPLICE_F_NONBLOCK) {
56883 ret = -EAGAIN;
56884 break;
56885 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56886 pipe_lock(pipe);
56887
56888 while (pipe->nrbufs >= pipe->buffers) {
56889 - if (!pipe->readers) {
56890 + if (!atomic_read(&pipe->readers)) {
56891 send_sig(SIGPIPE, current, 0);
56892 ret = -EPIPE;
56893 break;
56894 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56895 ret = -ERESTARTSYS;
56896 break;
56897 }
56898 - pipe->waiting_writers++;
56899 + atomic_inc(&pipe->waiting_writers);
56900 pipe_wait(pipe);
56901 - pipe->waiting_writers--;
56902 + atomic_dec(&pipe->waiting_writers);
56903 }
56904
56905 pipe_unlock(pipe);
56906 @@ -1854,14 +1854,14 @@ retry:
56907 pipe_double_lock(ipipe, opipe);
56908
56909 do {
56910 - if (!opipe->readers) {
56911 + if (!atomic_read(&opipe->readers)) {
56912 send_sig(SIGPIPE, current, 0);
56913 if (!ret)
56914 ret = -EPIPE;
56915 break;
56916 }
56917
56918 - if (!ipipe->nrbufs && !ipipe->writers)
56919 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56920 break;
56921
56922 /*
56923 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56924 pipe_double_lock(ipipe, opipe);
56925
56926 do {
56927 - if (!opipe->readers) {
56928 + if (!atomic_read(&opipe->readers)) {
56929 send_sig(SIGPIPE, current, 0);
56930 if (!ret)
56931 ret = -EPIPE;
56932 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56933 * return EAGAIN if we have the potential of some data in the
56934 * future, otherwise just return 0
56935 */
56936 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56937 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56938 ret = -EAGAIN;
56939
56940 pipe_unlock(ipipe);
56941 diff --git a/fs/stat.c b/fs/stat.c
56942 index 04ce1ac..a13dd1e 100644
56943 --- a/fs/stat.c
56944 +++ b/fs/stat.c
56945 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56946 stat->gid = inode->i_gid;
56947 stat->rdev = inode->i_rdev;
56948 stat->size = i_size_read(inode);
56949 - stat->atime = inode->i_atime;
56950 - stat->mtime = inode->i_mtime;
56951 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56952 + stat->atime = inode->i_ctime;
56953 + stat->mtime = inode->i_ctime;
56954 + } else {
56955 + stat->atime = inode->i_atime;
56956 + stat->mtime = inode->i_mtime;
56957 + }
56958 stat->ctime = inode->i_ctime;
56959 stat->blksize = (1 << inode->i_blkbits);
56960 stat->blocks = inode->i_blocks;
56961 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56962 if (retval)
56963 return retval;
56964
56965 - if (inode->i_op->getattr)
56966 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56967 + if (inode->i_op->getattr) {
56968 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56969 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56970 + stat->atime = stat->ctime;
56971 + stat->mtime = stat->ctime;
56972 + }
56973 + return retval;
56974 + }
56975
56976 generic_fillattr(inode, stat);
56977 return 0;
56978 diff --git a/fs/super.c b/fs/super.c
56979 index 7465d43..68307c0 100644
56980 --- a/fs/super.c
56981 +++ b/fs/super.c
56982 @@ -336,19 +336,19 @@ EXPORT_SYMBOL(deactivate_super);
56983 * and want to turn it into a full-blown active reference. grab_super()
56984 * is called with sb_lock held and drops it. Returns 1 in case of
56985 * success, 0 if we had failed (superblock contents was already dead or
56986 - * dying when grab_super() had been called).
56987 + * dying when grab_super() had been called). Note that this is only
56988 + * called for superblocks not in rundown mode (== ones still on ->fs_supers
56989 + * of their type), so increment of ->s_count is OK here.
56990 */
56991 static int grab_super(struct super_block *s) __releases(sb_lock)
56992 {
56993 - if (atomic_inc_not_zero(&s->s_active)) {
56994 - spin_unlock(&sb_lock);
56995 - return 1;
56996 - }
56997 - /* it's going away */
56998 s->s_count++;
56999 spin_unlock(&sb_lock);
57000 - /* wait for it to die */
57001 down_write(&s->s_umount);
57002 + if ((s->s_flags & MS_BORN) && atomic_inc_not_zero(&s->s_active)) {
57003 + put_super(s);
57004 + return 1;
57005 + }
57006 up_write(&s->s_umount);
57007 put_super(s);
57008 return 0;
57009 @@ -463,11 +463,6 @@ retry:
57010 destroy_super(s);
57011 s = NULL;
57012 }
57013 - down_write(&old->s_umount);
57014 - if (unlikely(!(old->s_flags & MS_BORN))) {
57015 - deactivate_locked_super(old);
57016 - goto retry;
57017 - }
57018 return old;
57019 }
57020 }
57021 @@ -660,10 +655,10 @@ restart:
57022 if (hlist_unhashed(&sb->s_instances))
57023 continue;
57024 if (sb->s_bdev == bdev) {
57025 - if (grab_super(sb)) /* drops sb_lock */
57026 - return sb;
57027 - else
57028 + if (!grab_super(sb))
57029 goto restart;
57030 + up_write(&sb->s_umount);
57031 + return sb;
57032 }
57033 }
57034 spin_unlock(&sb_lock);
57035 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
57036 index 15c68f9..36a8b3e 100644
57037 --- a/fs/sysfs/bin.c
57038 +++ b/fs/sysfs/bin.c
57039 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
57040 return ret;
57041 }
57042
57043 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
57044 - void *buf, int len, int write)
57045 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
57046 + void *buf, size_t len, int write)
57047 {
57048 struct file *file = vma->vm_file;
57049 struct bin_buffer *bb = file->private_data;
57050 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
57051 - int ret;
57052 + ssize_t ret;
57053
57054 if (!bb->vm_ops)
57055 return -EINVAL;
57056 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
57057 index e8e0e71..79c28ac5 100644
57058 --- a/fs/sysfs/dir.c
57059 +++ b/fs/sysfs/dir.c
57060 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
57061 *
57062 * Returns 31 bit hash of ns + name (so it fits in an off_t )
57063 */
57064 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
57065 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
57066 {
57067 unsigned long hash = init_name_hash();
57068 unsigned int len = strlen(name);
57069 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
57070 struct sysfs_dirent *sd;
57071 int rc;
57072
57073 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
57074 + const char *parent_name = parent_sd->s_name;
57075 +
57076 + mode = S_IFDIR | S_IRWXU;
57077 +
57078 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
57079 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
57080 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
57081 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
57082 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
57083 +#endif
57084 +
57085 /* allocate */
57086 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
57087 if (!sd)
57088 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
57089 index 602f56d..6853db8 100644
57090 --- a/fs/sysfs/file.c
57091 +++ b/fs/sysfs/file.c
57092 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
57093
57094 struct sysfs_open_dirent {
57095 atomic_t refcnt;
57096 - atomic_t event;
57097 + atomic_unchecked_t event;
57098 wait_queue_head_t poll;
57099 struct list_head buffers; /* goes through sysfs_buffer.list */
57100 };
57101 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
57102 if (!sysfs_get_active(attr_sd))
57103 return -ENODEV;
57104
57105 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
57106 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
57107 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
57108
57109 sysfs_put_active(attr_sd);
57110 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
57111 return -ENOMEM;
57112
57113 atomic_set(&new_od->refcnt, 0);
57114 - atomic_set(&new_od->event, 1);
57115 + atomic_set_unchecked(&new_od->event, 1);
57116 init_waitqueue_head(&new_od->poll);
57117 INIT_LIST_HEAD(&new_od->buffers);
57118 goto retry;
57119 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
57120
57121 sysfs_put_active(attr_sd);
57122
57123 - if (buffer->event != atomic_read(&od->event))
57124 + if (buffer->event != atomic_read_unchecked(&od->event))
57125 goto trigger;
57126
57127 return DEFAULT_POLLMASK;
57128 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
57129
57130 od = sd->s_attr.open;
57131 if (od) {
57132 - atomic_inc(&od->event);
57133 + atomic_inc_unchecked(&od->event);
57134 wake_up_interruptible(&od->poll);
57135 }
57136
57137 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
57138 index 8c940df..25b733e 100644
57139 --- a/fs/sysfs/symlink.c
57140 +++ b/fs/sysfs/symlink.c
57141 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
57142
57143 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
57144 {
57145 - char *page = nd_get_link(nd);
57146 + const char *page = nd_get_link(nd);
57147 if (!IS_ERR(page))
57148 free_page((unsigned long)page);
57149 }
57150 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
57151 index 69d4889..a810bd4 100644
57152 --- a/fs/sysv/sysv.h
57153 +++ b/fs/sysv/sysv.h
57154 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
57155 #endif
57156 }
57157
57158 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
57159 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
57160 {
57161 if (sbi->s_bytesex == BYTESEX_PDP)
57162 return PDP_swab((__force __u32)n);
57163 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
57164 index e18b988..f1d4ad0f 100644
57165 --- a/fs/ubifs/io.c
57166 +++ b/fs/ubifs/io.c
57167 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
57168 return err;
57169 }
57170
57171 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
57172 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
57173 {
57174 int err;
57175
57176 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
57177 index c175b4d..8f36a16 100644
57178 --- a/fs/udf/misc.c
57179 +++ b/fs/udf/misc.c
57180 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
57181
57182 u8 udf_tag_checksum(const struct tag *t)
57183 {
57184 - u8 *data = (u8 *)t;
57185 + const u8 *data = (const u8 *)t;
57186 u8 checksum = 0;
57187 int i;
57188 for (i = 0; i < sizeof(struct tag); ++i)
57189 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
57190 index 8d974c4..b82f6ec 100644
57191 --- a/fs/ufs/swab.h
57192 +++ b/fs/ufs/swab.h
57193 @@ -22,7 +22,7 @@ enum {
57194 BYTESEX_BE
57195 };
57196
57197 -static inline u64
57198 +static inline u64 __intentional_overflow(-1)
57199 fs64_to_cpu(struct super_block *sbp, __fs64 n)
57200 {
57201 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
57202 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
57203 return (__force __fs64)cpu_to_be64(n);
57204 }
57205
57206 -static inline u32
57207 +static inline u32 __intentional_overflow(-1)
57208 fs32_to_cpu(struct super_block *sbp, __fs32 n)
57209 {
57210 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
57211 diff --git a/fs/utimes.c b/fs/utimes.c
57212 index f4fb7ec..3fe03c0 100644
57213 --- a/fs/utimes.c
57214 +++ b/fs/utimes.c
57215 @@ -1,6 +1,7 @@
57216 #include <linux/compiler.h>
57217 #include <linux/file.h>
57218 #include <linux/fs.h>
57219 +#include <linux/security.h>
57220 #include <linux/linkage.h>
57221 #include <linux/mount.h>
57222 #include <linux/namei.h>
57223 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
57224 goto mnt_drop_write_and_out;
57225 }
57226 }
57227 +
57228 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
57229 + error = -EACCES;
57230 + goto mnt_drop_write_and_out;
57231 + }
57232 +
57233 mutex_lock(&inode->i_mutex);
57234 error = notify_change(path->dentry, &newattrs);
57235 mutex_unlock(&inode->i_mutex);
57236 diff --git a/fs/xattr.c b/fs/xattr.c
57237 index 3377dff..4d074d9 100644
57238 --- a/fs/xattr.c
57239 +++ b/fs/xattr.c
57240 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
57241 return rc;
57242 }
57243
57244 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
57245 +ssize_t
57246 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
57247 +{
57248 + struct inode *inode = dentry->d_inode;
57249 + ssize_t error;
57250 +
57251 + error = inode_permission(inode, MAY_EXEC);
57252 + if (error)
57253 + return error;
57254 +
57255 + if (inode->i_op->getxattr)
57256 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
57257 + else
57258 + error = -EOPNOTSUPP;
57259 +
57260 + return error;
57261 +}
57262 +EXPORT_SYMBOL(pax_getxattr);
57263 +#endif
57264 +
57265 ssize_t
57266 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
57267 {
57268 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
57269 * Extended attribute SET operations
57270 */
57271 static long
57272 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
57273 +setxattr(struct path *path, const char __user *name, const void __user *value,
57274 size_t size, int flags)
57275 {
57276 int error;
57277 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
57278 posix_acl_fix_xattr_from_user(kvalue, size);
57279 }
57280
57281 - error = vfs_setxattr(d, kname, kvalue, size, flags);
57282 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
57283 + error = -EACCES;
57284 + goto out;
57285 + }
57286 +
57287 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
57288 out:
57289 if (vvalue)
57290 vfree(vvalue);
57291 @@ -377,7 +403,7 @@ retry:
57292 return error;
57293 error = mnt_want_write(path.mnt);
57294 if (!error) {
57295 - error = setxattr(path.dentry, name, value, size, flags);
57296 + error = setxattr(&path, name, value, size, flags);
57297 mnt_drop_write(path.mnt);
57298 }
57299 path_put(&path);
57300 @@ -401,7 +427,7 @@ retry:
57301 return error;
57302 error = mnt_want_write(path.mnt);
57303 if (!error) {
57304 - error = setxattr(path.dentry, name, value, size, flags);
57305 + error = setxattr(&path, name, value, size, flags);
57306 mnt_drop_write(path.mnt);
57307 }
57308 path_put(&path);
57309 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
57310 const void __user *,value, size_t, size, int, flags)
57311 {
57312 struct fd f = fdget(fd);
57313 - struct dentry *dentry;
57314 int error = -EBADF;
57315
57316 if (!f.file)
57317 return error;
57318 - dentry = f.file->f_path.dentry;
57319 - audit_inode(NULL, dentry, 0);
57320 + audit_inode(NULL, f.file->f_path.dentry, 0);
57321 error = mnt_want_write_file(f.file);
57322 if (!error) {
57323 - error = setxattr(dentry, name, value, size, flags);
57324 + error = setxattr(&f.file->f_path, name, value, size, flags);
57325 mnt_drop_write_file(f.file);
57326 }
57327 fdput(f);
57328 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57329 index 9fbea87..6b19972 100644
57330 --- a/fs/xattr_acl.c
57331 +++ b/fs/xattr_acl.c
57332 @@ -76,8 +76,8 @@ struct posix_acl *
57333 posix_acl_from_xattr(struct user_namespace *user_ns,
57334 const void *value, size_t size)
57335 {
57336 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57337 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57338 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57339 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57340 int count;
57341 struct posix_acl *acl;
57342 struct posix_acl_entry *acl_e;
57343 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57344 index 8904284..ee0e14b 100644
57345 --- a/fs/xfs/xfs_bmap.c
57346 +++ b/fs/xfs/xfs_bmap.c
57347 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
57348
57349 #else
57350 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
57351 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57352 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
57353 #endif /* DEBUG */
57354
57355 /*
57356 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57357 index 6157424..ac98f6d 100644
57358 --- a/fs/xfs/xfs_dir2_sf.c
57359 +++ b/fs/xfs/xfs_dir2_sf.c
57360 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57361 }
57362
57363 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57364 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57365 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57366 + char name[sfep->namelen];
57367 + memcpy(name, sfep->name, sfep->namelen);
57368 + if (filldir(dirent, name, sfep->namelen,
57369 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57370 + *offset = off & 0x7fffffff;
57371 + return 0;
57372 + }
57373 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57374 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57375 *offset = off & 0x7fffffff;
57376 return 0;
57377 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57378 index 5e99968..45bd327 100644
57379 --- a/fs/xfs/xfs_ioctl.c
57380 +++ b/fs/xfs/xfs_ioctl.c
57381 @@ -127,7 +127,7 @@ xfs_find_handle(
57382 }
57383
57384 error = -EFAULT;
57385 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57386 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57387 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57388 goto out_put;
57389
57390 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57391 index ca9ecaa..60100c7 100644
57392 --- a/fs/xfs/xfs_iops.c
57393 +++ b/fs/xfs/xfs_iops.c
57394 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57395 struct nameidata *nd,
57396 void *p)
57397 {
57398 - char *s = nd_get_link(nd);
57399 + const char *s = nd_get_link(nd);
57400
57401 if (!IS_ERR(s))
57402 kfree(s);
57403 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57404 new file mode 100644
57405 index 0000000..712a85d
57406 --- /dev/null
57407 +++ b/grsecurity/Kconfig
57408 @@ -0,0 +1,1043 @@
57409 +#
57410 +# grecurity configuration
57411 +#
57412 +menu "Memory Protections"
57413 +depends on GRKERNSEC
57414 +
57415 +config GRKERNSEC_KMEM
57416 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57417 + default y if GRKERNSEC_CONFIG_AUTO
57418 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57419 + help
57420 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57421 + be written to or read from to modify or leak the contents of the running
57422 + kernel. /dev/port will also not be allowed to be opened and support
57423 + for /dev/cpu/*/msr will be removed. If you have module
57424 + support disabled, enabling this will close up five ways that are
57425 + currently used to insert malicious code into the running kernel.
57426 +
57427 + Even with all these features enabled, we still highly recommend that
57428 + you use the RBAC system, as it is still possible for an attacker to
57429 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57430 +
57431 + If you are not using XFree86, you may be able to stop this additional
57432 + case by enabling the 'Disable privileged I/O' option. Though nothing
57433 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57434 + but only to video memory, which is the only writing we allow in this
57435 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57436 + not be allowed to mprotect it with PROT_WRITE later.
57437 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57438 + from working.
57439 +
57440 + It is highly recommended that you say Y here if you meet all the
57441 + conditions above.
57442 +
57443 +config GRKERNSEC_VM86
57444 + bool "Restrict VM86 mode"
57445 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57446 + depends on X86_32
57447 +
57448 + help
57449 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57450 + make use of a special execution mode on 32bit x86 processors called
57451 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57452 + video cards and will still work with this option enabled. The purpose
57453 + of the option is to prevent exploitation of emulation errors in
57454 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57455 + Nearly all users should be able to enable this option.
57456 +
57457 +config GRKERNSEC_IO
57458 + bool "Disable privileged I/O"
57459 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57460 + depends on X86
57461 + select RTC_CLASS
57462 + select RTC_INTF_DEV
57463 + select RTC_DRV_CMOS
57464 +
57465 + help
57466 + If you say Y here, all ioperm and iopl calls will return an error.
57467 + Ioperm and iopl can be used to modify the running kernel.
57468 + Unfortunately, some programs need this access to operate properly,
57469 + the most notable of which are XFree86 and hwclock. hwclock can be
57470 + remedied by having RTC support in the kernel, so real-time
57471 + clock support is enabled if this option is enabled, to ensure
57472 + that hwclock operates correctly. XFree86 still will not
57473 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57474 + IF YOU USE XFree86. If you use XFree86 and you still want to
57475 + protect your kernel against modification, use the RBAC system.
57476 +
57477 +config GRKERNSEC_JIT_HARDEN
57478 + bool "Harden BPF JIT against spray attacks"
57479 + default y if GRKERNSEC_CONFIG_AUTO
57480 + depends on BPF_JIT
57481 + help
57482 + If you say Y here, the native code generated by the kernel's Berkeley
57483 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57484 + attacks that attempt to fit attacker-beneficial instructions in
57485 + 32bit immediate fields of JIT-generated native instructions. The
57486 + attacker will generally aim to cause an unintended instruction sequence
57487 + of JIT-generated native code to execute by jumping into the middle of
57488 + a generated instruction. This feature effectively randomizes the 32bit
57489 + immediate constants present in the generated code to thwart such attacks.
57490 +
57491 + If you're using KERNEXEC, it's recommended that you enable this option
57492 + to supplement the hardening of the kernel.
57493 +
57494 +config GRKERNSEC_PERF_HARDEN
57495 + bool "Disable unprivileged PERF_EVENTS usage by default"
57496 + default y if GRKERNSEC_CONFIG_AUTO
57497 + depends on PERF_EVENTS
57498 + help
57499 + If you say Y here, the range of acceptable values for the
57500 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
57501 + default to a new value: 3. When the sysctl is set to this value, no
57502 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
57503 +
57504 + Though PERF_EVENTS can be used legitimately for performance monitoring
57505 + and low-level application profiling, it is forced on regardless of
57506 + configuration, has been at fault for several vulnerabilities, and
57507 + creates new opportunities for side channels and other information leaks.
57508 +
57509 + This feature puts PERF_EVENTS into a secure default state and permits
57510 + the administrator to change out of it temporarily if unprivileged
57511 + application profiling is needed.
57512 +
57513 +config GRKERNSEC_RAND_THREADSTACK
57514 + bool "Insert random gaps between thread stacks"
57515 + default y if GRKERNSEC_CONFIG_AUTO
57516 + depends on PAX_RANDMMAP && !PPC
57517 + help
57518 + If you say Y here, a random-sized gap will be enforced between allocated
57519 + thread stacks. Glibc's NPTL and other threading libraries that
57520 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57521 + The implementation currently provides 8 bits of entropy for the gap.
57522 +
57523 + Many distributions do not compile threaded remote services with the
57524 + -fstack-check argument to GCC, causing the variable-sized stack-based
57525 + allocator, alloca(), to not probe the stack on allocation. This
57526 + permits an unbounded alloca() to skip over any guard page and potentially
57527 + modify another thread's stack reliably. An enforced random gap
57528 + reduces the reliability of such an attack and increases the chance
57529 + that such a read/write to another thread's stack instead lands in
57530 + an unmapped area, causing a crash and triggering grsecurity's
57531 + anti-bruteforcing logic.
57532 +
57533 +config GRKERNSEC_PROC_MEMMAP
57534 + bool "Harden ASLR against information leaks and entropy reduction"
57535 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57536 + depends on PAX_NOEXEC || PAX_ASLR
57537 + help
57538 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57539 + give no information about the addresses of its mappings if
57540 + PaX features that rely on random addresses are enabled on the task.
57541 + In addition to sanitizing this information and disabling other
57542 + dangerous sources of information, this option causes reads of sensitive
57543 + /proc/<pid> entries where the file descriptor was opened in a different
57544 + task than the one performing the read. Such attempts are logged.
57545 + This option also limits argv/env strings for suid/sgid binaries
57546 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57547 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57548 + binaries to prevent alternative mmap layouts from being abused.
57549 +
57550 + If you use PaX it is essential that you say Y here as it closes up
57551 + several holes that make full ASLR useless locally.
57552 +
57553 +config GRKERNSEC_BRUTE
57554 + bool "Deter exploit bruteforcing"
57555 + default y if GRKERNSEC_CONFIG_AUTO
57556 + help
57557 + If you say Y here, attempts to bruteforce exploits against forking
57558 + daemons such as apache or sshd, as well as against suid/sgid binaries
57559 + will be deterred. When a child of a forking daemon is killed by PaX
57560 + or crashes due to an illegal instruction or other suspicious signal,
57561 + the parent process will be delayed 30 seconds upon every subsequent
57562 + fork until the administrator is able to assess the situation and
57563 + restart the daemon.
57564 + In the suid/sgid case, the attempt is logged, the user has all their
57565 + existing instances of the suid/sgid binary terminated and will
57566 + be unable to execute any suid/sgid binaries for 15 minutes.
57567 +
57568 + It is recommended that you also enable signal logging in the auditing
57569 + section so that logs are generated when a process triggers a suspicious
57570 + signal.
57571 + If the sysctl option is enabled, a sysctl option with name
57572 + "deter_bruteforce" is created.
57573 +
57574 +
57575 +config GRKERNSEC_MODHARDEN
57576 + bool "Harden module auto-loading"
57577 + default y if GRKERNSEC_CONFIG_AUTO
57578 + depends on MODULES
57579 + help
57580 + If you say Y here, module auto-loading in response to use of some
57581 + feature implemented by an unloaded module will be restricted to
57582 + root users. Enabling this option helps defend against attacks
57583 + by unprivileged users who abuse the auto-loading behavior to
57584 + cause a vulnerable module to load that is then exploited.
57585 +
57586 + If this option prevents a legitimate use of auto-loading for a
57587 + non-root user, the administrator can execute modprobe manually
57588 + with the exact name of the module mentioned in the alert log.
57589 + Alternatively, the administrator can add the module to the list
57590 + of modules loaded at boot by modifying init scripts.
57591 +
57592 + Modification of init scripts will most likely be needed on
57593 + Ubuntu servers with encrypted home directory support enabled,
57594 + as the first non-root user logging in will cause the ecb(aes),
57595 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57596 +
57597 +config GRKERNSEC_HIDESYM
57598 + bool "Hide kernel symbols"
57599 + default y if GRKERNSEC_CONFIG_AUTO
57600 + select PAX_USERCOPY_SLABS
57601 + help
57602 + If you say Y here, getting information on loaded modules, and
57603 + displaying all kernel symbols through a syscall will be restricted
57604 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57605 + /proc/kallsyms will be restricted to the root user. The RBAC
57606 + system can hide that entry even from root.
57607 +
57608 + This option also prevents leaking of kernel addresses through
57609 + several /proc entries.
57610 +
57611 + Note that this option is only effective provided the following
57612 + conditions are met:
57613 + 1) The kernel using grsecurity is not precompiled by some distribution
57614 + 2) You have also enabled GRKERNSEC_DMESG
57615 + 3) You are using the RBAC system and hiding other files such as your
57616 + kernel image and System.map. Alternatively, enabling this option
57617 + causes the permissions on /boot, /lib/modules, and the kernel
57618 + source directory to change at compile time to prevent
57619 + reading by non-root users.
57620 + If the above conditions are met, this option will aid in providing a
57621 + useful protection against local kernel exploitation of overflows
57622 + and arbitrary read/write vulnerabilities.
57623 +
57624 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
57625 + in addition to this feature.
57626 +
57627 +config GRKERNSEC_KERN_LOCKOUT
57628 + bool "Active kernel exploit response"
57629 + default y if GRKERNSEC_CONFIG_AUTO
57630 + depends on X86 || ARM || PPC || SPARC
57631 + help
57632 + If you say Y here, when a PaX alert is triggered due to suspicious
57633 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57634 + or an OOPS occurs due to bad memory accesses, instead of just
57635 + terminating the offending process (and potentially allowing
57636 + a subsequent exploit from the same user), we will take one of two
57637 + actions:
57638 + If the user was root, we will panic the system
57639 + If the user was non-root, we will log the attempt, terminate
57640 + all processes owned by the user, then prevent them from creating
57641 + any new processes until the system is restarted
57642 + This deters repeated kernel exploitation/bruteforcing attempts
57643 + and is useful for later forensics.
57644 +
57645 +endmenu
57646 +menu "Role Based Access Control Options"
57647 +depends on GRKERNSEC
57648 +
57649 +config GRKERNSEC_RBAC_DEBUG
57650 + bool
57651 +
57652 +config GRKERNSEC_NO_RBAC
57653 + bool "Disable RBAC system"
57654 + help
57655 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57656 + preventing the RBAC system from being enabled. You should only say Y
57657 + here if you have no intention of using the RBAC system, so as to prevent
57658 + an attacker with root access from misusing the RBAC system to hide files
57659 + and processes when loadable module support and /dev/[k]mem have been
57660 + locked down.
57661 +
57662 +config GRKERNSEC_ACL_HIDEKERN
57663 + bool "Hide kernel processes"
57664 + help
57665 + If you say Y here, all kernel threads will be hidden to all
57666 + processes but those whose subject has the "view hidden processes"
57667 + flag.
57668 +
57669 +config GRKERNSEC_ACL_MAXTRIES
57670 + int "Maximum tries before password lockout"
57671 + default 3
57672 + help
57673 + This option enforces the maximum number of times a user can attempt
57674 + to authorize themselves with the grsecurity RBAC system before being
57675 + denied the ability to attempt authorization again for a specified time.
57676 + The lower the number, the harder it will be to brute-force a password.
57677 +
57678 +config GRKERNSEC_ACL_TIMEOUT
57679 + int "Time to wait after max password tries, in seconds"
57680 + default 30
57681 + help
57682 + This option specifies the time the user must wait after attempting to
57683 + authorize to the RBAC system with the maximum number of invalid
57684 + passwords. The higher the number, the harder it will be to brute-force
57685 + a password.
57686 +
57687 +endmenu
57688 +menu "Filesystem Protections"
57689 +depends on GRKERNSEC
57690 +
57691 +config GRKERNSEC_PROC
57692 + bool "Proc restrictions"
57693 + default y if GRKERNSEC_CONFIG_AUTO
57694 + help
57695 + If you say Y here, the permissions of the /proc filesystem
57696 + will be altered to enhance system security and privacy. You MUST
57697 + choose either a user only restriction or a user and group restriction.
57698 + Depending upon the option you choose, you can either restrict users to
57699 + see only the processes they themselves run, or choose a group that can
57700 + view all processes and files normally restricted to root if you choose
57701 + the "restrict to user only" option. NOTE: If you're running identd or
57702 + ntpd as a non-root user, you will have to run it as the group you
57703 + specify here.
57704 +
57705 +config GRKERNSEC_PROC_USER
57706 + bool "Restrict /proc to user only"
57707 + depends on GRKERNSEC_PROC
57708 + help
57709 + If you say Y here, non-root users will only be able to view their own
57710 + processes, and restricts them from viewing network-related information,
57711 + and viewing kernel symbol and module information.
57712 +
57713 +config GRKERNSEC_PROC_USERGROUP
57714 + bool "Allow special group"
57715 + default y if GRKERNSEC_CONFIG_AUTO
57716 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57717 + help
57718 + If you say Y here, you will be able to select a group that will be
57719 + able to view all processes and network-related information. If you've
57720 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57721 + remain hidden. This option is useful if you want to run identd as
57722 + a non-root user. The group you select may also be chosen at boot time
57723 + via "grsec_proc_gid=" on the kernel commandline.
57724 +
57725 +config GRKERNSEC_PROC_GID
57726 + int "GID for special group"
57727 + depends on GRKERNSEC_PROC_USERGROUP
57728 + default 1001
57729 +
57730 +config GRKERNSEC_PROC_ADD
57731 + bool "Additional restrictions"
57732 + default y if GRKERNSEC_CONFIG_AUTO
57733 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57734 + help
57735 + If you say Y here, additional restrictions will be placed on
57736 + /proc that keep normal users from viewing device information and
57737 + slabinfo information that could be useful for exploits.
57738 +
57739 +config GRKERNSEC_LINK
57740 + bool "Linking restrictions"
57741 + default y if GRKERNSEC_CONFIG_AUTO
57742 + help
57743 + If you say Y here, /tmp race exploits will be prevented, since users
57744 + will no longer be able to follow symlinks owned by other users in
57745 + world-writable +t directories (e.g. /tmp), unless the owner of the
57746 + symlink is the owner of the directory. users will also not be
57747 + able to hardlink to files they do not own. If the sysctl option is
57748 + enabled, a sysctl option with name "linking_restrictions" is created.
57749 +
57750 +config GRKERNSEC_SYMLINKOWN
57751 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57752 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57753 + help
57754 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57755 + that prevents it from being used as a security feature. As Apache
57756 + verifies the symlink by performing a stat() against the target of
57757 + the symlink before it is followed, an attacker can setup a symlink
57758 + to point to a same-owned file, then replace the symlink with one
57759 + that targets another user's file just after Apache "validates" the
57760 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57761 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57762 + will be in place for the group you specify. If the sysctl option
57763 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57764 + created.
57765 +
57766 +config GRKERNSEC_SYMLINKOWN_GID
57767 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57768 + depends on GRKERNSEC_SYMLINKOWN
57769 + default 1006
57770 + help
57771 + Setting this GID determines what group kernel-enforced
57772 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57773 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57774 +
57775 +config GRKERNSEC_FIFO
57776 + bool "FIFO restrictions"
57777 + default y if GRKERNSEC_CONFIG_AUTO
57778 + help
57779 + If you say Y here, users will not be able to write to FIFOs they don't
57780 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57781 + the FIFO is the same owner of the directory it's held in. If the sysctl
57782 + option is enabled, a sysctl option with name "fifo_restrictions" is
57783 + created.
57784 +
57785 +config GRKERNSEC_SYSFS_RESTRICT
57786 + bool "Sysfs/debugfs restriction"
57787 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57788 + depends on SYSFS
57789 + help
57790 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57791 + any filesystem normally mounted under it (e.g. debugfs) will be
57792 + mostly accessible only by root. These filesystems generally provide access
57793 + to hardware and debug information that isn't appropriate for unprivileged
57794 + users of the system. Sysfs and debugfs have also become a large source
57795 + of new vulnerabilities, ranging from infoleaks to local compromise.
57796 + There has been very little oversight with an eye toward security involved
57797 + in adding new exporters of information to these filesystems, so their
57798 + use is discouraged.
57799 + For reasons of compatibility, a few directories have been whitelisted
57800 + for access by non-root users:
57801 + /sys/fs/selinux
57802 + /sys/fs/fuse
57803 + /sys/devices/system/cpu
57804 +
57805 +config GRKERNSEC_ROFS
57806 + bool "Runtime read-only mount protection"
57807 + help
57808 + If you say Y here, a sysctl option with name "romount_protect" will
57809 + be created. By setting this option to 1 at runtime, filesystems
57810 + will be protected in the following ways:
57811 + * No new writable mounts will be allowed
57812 + * Existing read-only mounts won't be able to be remounted read/write
57813 + * Write operations will be denied on all block devices
57814 + This option acts independently of grsec_lock: once it is set to 1,
57815 + it cannot be turned off. Therefore, please be mindful of the resulting
57816 + behavior if this option is enabled in an init script on a read-only
57817 + filesystem. This feature is mainly intended for secure embedded systems.
57818 +
57819 +config GRKERNSEC_DEVICE_SIDECHANNEL
57820 + bool "Eliminate stat/notify-based device sidechannels"
57821 + default y if GRKERNSEC_CONFIG_AUTO
57822 + help
57823 + If you say Y here, timing analyses on block or character
57824 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57825 + will be thwarted for unprivileged users. If a process without
57826 + CAP_MKNOD stats such a device, the last access and last modify times
57827 + will match the device's create time. No access or modify events
57828 + will be triggered through inotify/dnotify/fanotify for such devices.
57829 + This feature will prevent attacks that may at a minimum
57830 + allow an attacker to determine the administrator's password length.
57831 +
57832 +config GRKERNSEC_CHROOT
57833 + bool "Chroot jail restrictions"
57834 + default y if GRKERNSEC_CONFIG_AUTO
57835 + help
57836 + If you say Y here, you will be able to choose several options that will
57837 + make breaking out of a chrooted jail much more difficult. If you
57838 + encounter no software incompatibilities with the following options, it
57839 + is recommended that you enable each one.
57840 +
57841 +config GRKERNSEC_CHROOT_MOUNT
57842 + bool "Deny mounts"
57843 + default y if GRKERNSEC_CONFIG_AUTO
57844 + depends on GRKERNSEC_CHROOT
57845 + help
57846 + If you say Y here, processes inside a chroot will not be able to
57847 + mount or remount filesystems. If the sysctl option is enabled, a
57848 + sysctl option with name "chroot_deny_mount" is created.
57849 +
57850 +config GRKERNSEC_CHROOT_DOUBLE
57851 + bool "Deny double-chroots"
57852 + default y if GRKERNSEC_CONFIG_AUTO
57853 + depends on GRKERNSEC_CHROOT
57854 + help
57855 + If you say Y here, processes inside a chroot will not be able to chroot
57856 + again outside the chroot. This is a widely used method of breaking
57857 + out of a chroot jail and should not be allowed. If the sysctl
57858 + option is enabled, a sysctl option with name
57859 + "chroot_deny_chroot" is created.
57860 +
57861 +config GRKERNSEC_CHROOT_PIVOT
57862 + bool "Deny pivot_root in chroot"
57863 + default y if GRKERNSEC_CONFIG_AUTO
57864 + depends on GRKERNSEC_CHROOT
57865 + help
57866 + If you say Y here, processes inside a chroot will not be able to use
57867 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57868 + works similar to chroot in that it changes the root filesystem. This
57869 + function could be misused in a chrooted process to attempt to break out
57870 + of the chroot, and therefore should not be allowed. If the sysctl
57871 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57872 + created.
57873 +
57874 +config GRKERNSEC_CHROOT_CHDIR
57875 + bool "Enforce chdir(\"/\") on all chroots"
57876 + default y if GRKERNSEC_CONFIG_AUTO
57877 + depends on GRKERNSEC_CHROOT
57878 + help
57879 + If you say Y here, the current working directory of all newly-chrooted
57880 + applications will be set to the the root directory of the chroot.
57881 + The man page on chroot(2) states:
57882 + Note that this call does not change the current working
57883 + directory, so that `.' can be outside the tree rooted at
57884 + `/'. In particular, the super-user can escape from a
57885 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57886 +
57887 + It is recommended that you say Y here, since it's not known to break
57888 + any software. If the sysctl option is enabled, a sysctl option with
57889 + name "chroot_enforce_chdir" is created.
57890 +
57891 +config GRKERNSEC_CHROOT_CHMOD
57892 + bool "Deny (f)chmod +s"
57893 + default y if GRKERNSEC_CONFIG_AUTO
57894 + depends on GRKERNSEC_CHROOT
57895 + help
57896 + If you say Y here, processes inside a chroot will not be able to chmod
57897 + or fchmod files to make them have suid or sgid bits. This protects
57898 + against another published method of breaking a chroot. If the sysctl
57899 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57900 + created.
57901 +
57902 +config GRKERNSEC_CHROOT_FCHDIR
57903 + bool "Deny fchdir out of chroot"
57904 + default y if GRKERNSEC_CONFIG_AUTO
57905 + depends on GRKERNSEC_CHROOT
57906 + help
57907 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57908 + to a file descriptor of the chrooting process that points to a directory
57909 + outside the filesystem will be stopped. If the sysctl option
57910 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57911 +
57912 +config GRKERNSEC_CHROOT_MKNOD
57913 + bool "Deny mknod"
57914 + default y if GRKERNSEC_CONFIG_AUTO
57915 + depends on GRKERNSEC_CHROOT
57916 + help
57917 + If you say Y here, processes inside a chroot will not be allowed to
57918 + mknod. The problem with using mknod inside a chroot is that it
57919 + would allow an attacker to create a device entry that is the same
57920 + as one on the physical root of your system, which could range from
57921 + anything from the console device to a device for your harddrive (which
57922 + they could then use to wipe the drive or steal data). It is recommended
57923 + that you say Y here, unless you run into software incompatibilities.
57924 + If the sysctl option is enabled, a sysctl option with name
57925 + "chroot_deny_mknod" is created.
57926 +
57927 +config GRKERNSEC_CHROOT_SHMAT
57928 + bool "Deny shmat() out of chroot"
57929 + default y if GRKERNSEC_CONFIG_AUTO
57930 + depends on GRKERNSEC_CHROOT
57931 + help
57932 + If you say Y here, processes inside a chroot will not be able to attach
57933 + to shared memory segments that were created outside of the chroot jail.
57934 + It is recommended that you say Y here. If the sysctl option is enabled,
57935 + a sysctl option with name "chroot_deny_shmat" is created.
57936 +
57937 +config GRKERNSEC_CHROOT_UNIX
57938 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57939 + default y if GRKERNSEC_CONFIG_AUTO
57940 + depends on GRKERNSEC_CHROOT
57941 + help
57942 + If you say Y here, processes inside a chroot will not be able to
57943 + connect to abstract (meaning not belonging to a filesystem) Unix
57944 + domain sockets that were bound outside of a chroot. It is recommended
57945 + that you say Y here. If the sysctl option is enabled, a sysctl option
57946 + with name "chroot_deny_unix" is created.
57947 +
57948 +config GRKERNSEC_CHROOT_FINDTASK
57949 + bool "Protect outside processes"
57950 + default y if GRKERNSEC_CONFIG_AUTO
57951 + depends on GRKERNSEC_CHROOT
57952 + help
57953 + If you say Y here, processes inside a chroot will not be able to
57954 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57955 + getsid, or view any process outside of the chroot. If the sysctl
57956 + option is enabled, a sysctl option with name "chroot_findtask" is
57957 + created.
57958 +
57959 +config GRKERNSEC_CHROOT_NICE
57960 + bool "Restrict priority changes"
57961 + default y if GRKERNSEC_CONFIG_AUTO
57962 + depends on GRKERNSEC_CHROOT
57963 + help
57964 + If you say Y here, processes inside a chroot will not be able to raise
57965 + the priority of processes in the chroot, or alter the priority of
57966 + processes outside the chroot. This provides more security than simply
57967 + removing CAP_SYS_NICE from the process' capability set. If the
57968 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57969 + is created.
57970 +
57971 +config GRKERNSEC_CHROOT_SYSCTL
57972 + bool "Deny sysctl writes"
57973 + default y if GRKERNSEC_CONFIG_AUTO
57974 + depends on GRKERNSEC_CHROOT
57975 + help
57976 + If you say Y here, an attacker in a chroot will not be able to
57977 + write to sysctl entries, either by sysctl(2) or through a /proc
57978 + interface. It is strongly recommended that you say Y here. If the
57979 + sysctl option is enabled, a sysctl option with name
57980 + "chroot_deny_sysctl" is created.
57981 +
57982 +config GRKERNSEC_CHROOT_CAPS
57983 + bool "Capability restrictions"
57984 + default y if GRKERNSEC_CONFIG_AUTO
57985 + depends on GRKERNSEC_CHROOT
57986 + help
57987 + If you say Y here, the capabilities on all processes within a
57988 + chroot jail will be lowered to stop module insertion, raw i/o,
57989 + system and net admin tasks, rebooting the system, modifying immutable
57990 + files, modifying IPC owned by another, and changing the system time.
57991 + This is left an option because it can break some apps. Disable this
57992 + if your chrooted apps are having problems performing those kinds of
57993 + tasks. If the sysctl option is enabled, a sysctl option with
57994 + name "chroot_caps" is created.
57995 +
57996 +config GRKERNSEC_CHROOT_INITRD
57997 + bool "Exempt initrd tasks from restrictions"
57998 + default y if GRKERNSEC_CONFIG_AUTO
57999 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
58000 + help
58001 + If you say Y here, tasks started prior to init will be exempted from
58002 + grsecurity's chroot restrictions. This option is mainly meant to
58003 + resolve Plymouth's performing privileged operations unnecessarily
58004 + in a chroot.
58005 +
58006 +endmenu
58007 +menu "Kernel Auditing"
58008 +depends on GRKERNSEC
58009 +
58010 +config GRKERNSEC_AUDIT_GROUP
58011 + bool "Single group for auditing"
58012 + help
58013 + If you say Y here, the exec and chdir logging features will only operate
58014 + on a group you specify. This option is recommended if you only want to
58015 + watch certain users instead of having a large amount of logs from the
58016 + entire system. If the sysctl option is enabled, a sysctl option with
58017 + name "audit_group" is created.
58018 +
58019 +config GRKERNSEC_AUDIT_GID
58020 + int "GID for auditing"
58021 + depends on GRKERNSEC_AUDIT_GROUP
58022 + default 1007
58023 +
58024 +config GRKERNSEC_EXECLOG
58025 + bool "Exec logging"
58026 + help
58027 + If you say Y here, all execve() calls will be logged (since the
58028 + other exec*() calls are frontends to execve(), all execution
58029 + will be logged). Useful for shell-servers that like to keep track
58030 + of their users. If the sysctl option is enabled, a sysctl option with
58031 + name "exec_logging" is created.
58032 + WARNING: This option when enabled will produce a LOT of logs, especially
58033 + on an active system.
58034 +
58035 +config GRKERNSEC_RESLOG
58036 + bool "Resource logging"
58037 + default y if GRKERNSEC_CONFIG_AUTO
58038 + help
58039 + If you say Y here, all attempts to overstep resource limits will
58040 + be logged with the resource name, the requested size, and the current
58041 + limit. It is highly recommended that you say Y here. If the sysctl
58042 + option is enabled, a sysctl option with name "resource_logging" is
58043 + created. If the RBAC system is enabled, the sysctl value is ignored.
58044 +
58045 +config GRKERNSEC_CHROOT_EXECLOG
58046 + bool "Log execs within chroot"
58047 + help
58048 + If you say Y here, all executions inside a chroot jail will be logged
58049 + to syslog. This can cause a large amount of logs if certain
58050 + applications (eg. djb's daemontools) are installed on the system, and
58051 + is therefore left as an option. If the sysctl option is enabled, a
58052 + sysctl option with name "chroot_execlog" is created.
58053 +
58054 +config GRKERNSEC_AUDIT_PTRACE
58055 + bool "Ptrace logging"
58056 + help
58057 + If you say Y here, all attempts to attach to a process via ptrace
58058 + will be logged. If the sysctl option is enabled, a sysctl option
58059 + with name "audit_ptrace" is created.
58060 +
58061 +config GRKERNSEC_AUDIT_CHDIR
58062 + bool "Chdir logging"
58063 + help
58064 + If you say Y here, all chdir() calls will be logged. If the sysctl
58065 + option is enabled, a sysctl option with name "audit_chdir" is created.
58066 +
58067 +config GRKERNSEC_AUDIT_MOUNT
58068 + bool "(Un)Mount logging"
58069 + help
58070 + If you say Y here, all mounts and unmounts will be logged. If the
58071 + sysctl option is enabled, a sysctl option with name "audit_mount" is
58072 + created.
58073 +
58074 +config GRKERNSEC_SIGNAL
58075 + bool "Signal logging"
58076 + default y if GRKERNSEC_CONFIG_AUTO
58077 + help
58078 + If you say Y here, certain important signals will be logged, such as
58079 + SIGSEGV, which will as a result inform you of when a error in a program
58080 + occurred, which in some cases could mean a possible exploit attempt.
58081 + If the sysctl option is enabled, a sysctl option with name
58082 + "signal_logging" is created.
58083 +
58084 +config GRKERNSEC_FORKFAIL
58085 + bool "Fork failure logging"
58086 + help
58087 + If you say Y here, all failed fork() attempts will be logged.
58088 + This could suggest a fork bomb, or someone attempting to overstep
58089 + their process limit. If the sysctl option is enabled, a sysctl option
58090 + with name "forkfail_logging" is created.
58091 +
58092 +config GRKERNSEC_TIME
58093 + bool "Time change logging"
58094 + default y if GRKERNSEC_CONFIG_AUTO
58095 + help
58096 + If you say Y here, any changes of the system clock will be logged.
58097 + If the sysctl option is enabled, a sysctl option with name
58098 + "timechange_logging" is created.
58099 +
58100 +config GRKERNSEC_PROC_IPADDR
58101 + bool "/proc/<pid>/ipaddr support"
58102 + default y if GRKERNSEC_CONFIG_AUTO
58103 + help
58104 + If you say Y here, a new entry will be added to each /proc/<pid>
58105 + directory that contains the IP address of the person using the task.
58106 + The IP is carried across local TCP and AF_UNIX stream sockets.
58107 + This information can be useful for IDS/IPSes to perform remote response
58108 + to a local attack. The entry is readable by only the owner of the
58109 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
58110 + the RBAC system), and thus does not create privacy concerns.
58111 +
58112 +config GRKERNSEC_RWXMAP_LOG
58113 + bool 'Denied RWX mmap/mprotect logging'
58114 + default y if GRKERNSEC_CONFIG_AUTO
58115 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
58116 + help
58117 + If you say Y here, calls to mmap() and mprotect() with explicit
58118 + usage of PROT_WRITE and PROT_EXEC together will be logged when
58119 + denied by the PAX_MPROTECT feature. This feature will also
58120 + log other problematic scenarios that can occur when PAX_MPROTECT
58121 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
58122 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
58123 + is created.
58124 +
58125 +endmenu
58126 +
58127 +menu "Executable Protections"
58128 +depends on GRKERNSEC
58129 +
58130 +config GRKERNSEC_DMESG
58131 + bool "Dmesg(8) restriction"
58132 + default y if GRKERNSEC_CONFIG_AUTO
58133 + help
58134 + If you say Y here, non-root users will not be able to use dmesg(8)
58135 + to view the contents of the kernel's circular log buffer.
58136 + The kernel's log buffer often contains kernel addresses and other
58137 + identifying information useful to an attacker in fingerprinting a
58138 + system for a targeted exploit.
58139 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
58140 + created.
58141 +
58142 +config GRKERNSEC_HARDEN_PTRACE
58143 + bool "Deter ptrace-based process snooping"
58144 + default y if GRKERNSEC_CONFIG_AUTO
58145 + help
58146 + If you say Y here, TTY sniffers and other malicious monitoring
58147 + programs implemented through ptrace will be defeated. If you
58148 + have been using the RBAC system, this option has already been
58149 + enabled for several years for all users, with the ability to make
58150 + fine-grained exceptions.
58151 +
58152 + This option only affects the ability of non-root users to ptrace
58153 + processes that are not a descendent of the ptracing process.
58154 + This means that strace ./binary and gdb ./binary will still work,
58155 + but attaching to arbitrary processes will not. If the sysctl
58156 + option is enabled, a sysctl option with name "harden_ptrace" is
58157 + created.
58158 +
58159 +config GRKERNSEC_PTRACE_READEXEC
58160 + bool "Require read access to ptrace sensitive binaries"
58161 + default y if GRKERNSEC_CONFIG_AUTO
58162 + help
58163 + If you say Y here, unprivileged users will not be able to ptrace unreadable
58164 + binaries. This option is useful in environments that
58165 + remove the read bits (e.g. file mode 4711) from suid binaries to
58166 + prevent infoleaking of their contents. This option adds
58167 + consistency to the use of that file mode, as the binary could normally
58168 + be read out when run without privileges while ptracing.
58169 +
58170 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
58171 + is created.
58172 +
58173 +config GRKERNSEC_SETXID
58174 + bool "Enforce consistent multithreaded privileges"
58175 + default y if GRKERNSEC_CONFIG_AUTO
58176 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
58177 + help
58178 + If you say Y here, a change from a root uid to a non-root uid
58179 + in a multithreaded application will cause the resulting uids,
58180 + gids, supplementary groups, and capabilities in that thread
58181 + to be propagated to the other threads of the process. In most
58182 + cases this is unnecessary, as glibc will emulate this behavior
58183 + on behalf of the application. Other libcs do not act in the
58184 + same way, allowing the other threads of the process to continue
58185 + running with root privileges. If the sysctl option is enabled,
58186 + a sysctl option with name "consistent_setxid" is created.
58187 +
58188 +config GRKERNSEC_TPE
58189 + bool "Trusted Path Execution (TPE)"
58190 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
58191 + help
58192 + If you say Y here, you will be able to choose a gid to add to the
58193 + supplementary groups of users you want to mark as "untrusted."
58194 + These users will not be able to execute any files that are not in
58195 + root-owned directories writable only by root. If the sysctl option
58196 + is enabled, a sysctl option with name "tpe" is created.
58197 +
58198 +config GRKERNSEC_TPE_ALL
58199 + bool "Partially restrict all non-root users"
58200 + depends on GRKERNSEC_TPE
58201 + help
58202 + If you say Y here, all non-root users will be covered under
58203 + a weaker TPE restriction. This is separate from, and in addition to,
58204 + the main TPE options that you have selected elsewhere. Thus, if a
58205 + "trusted" GID is chosen, this restriction applies to even that GID.
58206 + Under this restriction, all non-root users will only be allowed to
58207 + execute files in directories they own that are not group or
58208 + world-writable, or in directories owned by root and writable only by
58209 + root. If the sysctl option is enabled, a sysctl option with name
58210 + "tpe_restrict_all" is created.
58211 +
58212 +config GRKERNSEC_TPE_INVERT
58213 + bool "Invert GID option"
58214 + depends on GRKERNSEC_TPE
58215 + help
58216 + If you say Y here, the group you specify in the TPE configuration will
58217 + decide what group TPE restrictions will be *disabled* for. This
58218 + option is useful if you want TPE restrictions to be applied to most
58219 + users on the system. If the sysctl option is enabled, a sysctl option
58220 + with name "tpe_invert" is created. Unlike other sysctl options, this
58221 + entry will default to on for backward-compatibility.
58222 +
58223 +config GRKERNSEC_TPE_GID
58224 + int
58225 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
58226 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
58227 +
58228 +config GRKERNSEC_TPE_UNTRUSTED_GID
58229 + int "GID for TPE-untrusted users"
58230 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
58231 + default 1005
58232 + help
58233 + Setting this GID determines what group TPE restrictions will be
58234 + *enabled* for. If the sysctl option is enabled, a sysctl option
58235 + with name "tpe_gid" is created.
58236 +
58237 +config GRKERNSEC_TPE_TRUSTED_GID
58238 + int "GID for TPE-trusted users"
58239 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
58240 + default 1005
58241 + help
58242 + Setting this GID determines what group TPE restrictions will be
58243 + *disabled* for. If the sysctl option is enabled, a sysctl option
58244 + with name "tpe_gid" is created.
58245 +
58246 +endmenu
58247 +menu "Network Protections"
58248 +depends on GRKERNSEC
58249 +
58250 +config GRKERNSEC_RANDNET
58251 + bool "Larger entropy pools"
58252 + default y if GRKERNSEC_CONFIG_AUTO
58253 + help
58254 + If you say Y here, the entropy pools used for many features of Linux
58255 + and grsecurity will be doubled in size. Since several grsecurity
58256 + features use additional randomness, it is recommended that you say Y
58257 + here. Saying Y here has a similar effect as modifying
58258 + /proc/sys/kernel/random/poolsize.
58259 +
58260 +config GRKERNSEC_BLACKHOLE
58261 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
58262 + default y if GRKERNSEC_CONFIG_AUTO
58263 + depends on NET
58264 + help
58265 + If you say Y here, neither TCP resets nor ICMP
58266 + destination-unreachable packets will be sent in response to packets
58267 + sent to ports for which no associated listening process exists.
58268 + This feature supports both IPV4 and IPV6 and exempts the
58269 + loopback interface from blackholing. Enabling this feature
58270 + makes a host more resilient to DoS attacks and reduces network
58271 + visibility against scanners.
58272 +
58273 + The blackhole feature as-implemented is equivalent to the FreeBSD
58274 + blackhole feature, as it prevents RST responses to all packets, not
58275 + just SYNs. Under most application behavior this causes no
58276 + problems, but applications (like haproxy) may not close certain
58277 + connections in a way that cleanly terminates them on the remote
58278 + end, leaving the remote host in LAST_ACK state. Because of this
58279 + side-effect and to prevent intentional LAST_ACK DoSes, this
58280 + feature also adds automatic mitigation against such attacks.
58281 + The mitigation drastically reduces the amount of time a socket
58282 + can spend in LAST_ACK state. If you're using haproxy and not
58283 + all servers it connects to have this option enabled, consider
58284 + disabling this feature on the haproxy host.
58285 +
58286 + If the sysctl option is enabled, two sysctl options with names
58287 + "ip_blackhole" and "lastack_retries" will be created.
58288 + While "ip_blackhole" takes the standard zero/non-zero on/off
58289 + toggle, "lastack_retries" uses the same kinds of values as
58290 + "tcp_retries1" and "tcp_retries2". The default value of 4
58291 + prevents a socket from lasting more than 45 seconds in LAST_ACK
58292 + state.
58293 +
58294 +config GRKERNSEC_NO_SIMULT_CONNECT
58295 + bool "Disable TCP Simultaneous Connect"
58296 + default y if GRKERNSEC_CONFIG_AUTO
58297 + depends on NET
58298 + help
58299 + If you say Y here, a feature by Willy Tarreau will be enabled that
58300 + removes a weakness in Linux's strict implementation of TCP that
58301 + allows two clients to connect to each other without either entering
58302 + a listening state. The weakness allows an attacker to easily prevent
58303 + a client from connecting to a known server provided the source port
58304 + for the connection is guessed correctly.
58305 +
58306 + As the weakness could be used to prevent an antivirus or IPS from
58307 + fetching updates, or prevent an SSL gateway from fetching a CRL,
58308 + it should be eliminated by enabling this option. Though Linux is
58309 + one of few operating systems supporting simultaneous connect, it
58310 + has no legitimate use in practice and is rarely supported by firewalls.
58311 +
58312 +config GRKERNSEC_SOCKET
58313 + bool "Socket restrictions"
58314 + depends on NET
58315 + help
58316 + If you say Y here, you will be able to choose from several options.
58317 + If you assign a GID on your system and add it to the supplementary
58318 + groups of users you want to restrict socket access to, this patch
58319 + will perform up to three things, based on the option(s) you choose.
58320 +
58321 +config GRKERNSEC_SOCKET_ALL
58322 + bool "Deny any sockets to group"
58323 + depends on GRKERNSEC_SOCKET
58324 + help
58325 + If you say Y here, you will be able to choose a GID of whose users will
58326 + be unable to connect to other hosts from your machine or run server
58327 + applications from your machine. If the sysctl option is enabled, a
58328 + sysctl option with name "socket_all" is created.
58329 +
58330 +config GRKERNSEC_SOCKET_ALL_GID
58331 + int "GID to deny all sockets for"
58332 + depends on GRKERNSEC_SOCKET_ALL
58333 + default 1004
58334 + help
58335 + Here you can choose the GID to disable socket access for. Remember to
58336 + add the users you want socket access disabled for to the GID
58337 + specified here. If the sysctl option is enabled, a sysctl option
58338 + with name "socket_all_gid" is created.
58339 +
58340 +config GRKERNSEC_SOCKET_CLIENT
58341 + bool "Deny client sockets to group"
58342 + depends on GRKERNSEC_SOCKET
58343 + help
58344 + If you say Y here, you will be able to choose a GID of whose users will
58345 + be unable to connect to other hosts from your machine, but will be
58346 + able to run servers. If this option is enabled, all users in the group
58347 + you specify will have to use passive mode when initiating ftp transfers
58348 + from the shell on your machine. If the sysctl option is enabled, a
58349 + sysctl option with name "socket_client" is created.
58350 +
58351 +config GRKERNSEC_SOCKET_CLIENT_GID
58352 + int "GID to deny client sockets for"
58353 + depends on GRKERNSEC_SOCKET_CLIENT
58354 + default 1003
58355 + help
58356 + Here you can choose the GID to disable client socket access for.
58357 + Remember to add the users you want client socket access disabled for to
58358 + the GID specified here. If the sysctl option is enabled, a sysctl
58359 + option with name "socket_client_gid" is created.
58360 +
58361 +config GRKERNSEC_SOCKET_SERVER
58362 + bool "Deny server sockets to group"
58363 + depends on GRKERNSEC_SOCKET
58364 + help
58365 + If you say Y here, you will be able to choose a GID of whose users will
58366 + be unable to run server applications from your machine. If the sysctl
58367 + option is enabled, a sysctl option with name "socket_server" is created.
58368 +
58369 +config GRKERNSEC_SOCKET_SERVER_GID
58370 + int "GID to deny server sockets for"
58371 + depends on GRKERNSEC_SOCKET_SERVER
58372 + default 1002
58373 + help
58374 + Here you can choose the GID to disable server socket access for.
58375 + Remember to add the users you want server socket access disabled for to
58376 + the GID specified here. If the sysctl option is enabled, a sysctl
58377 + option with name "socket_server_gid" is created.
58378 +
58379 +endmenu
58380 +menu "Sysctl Support"
58381 +depends on GRKERNSEC && SYSCTL
58382 +
58383 +config GRKERNSEC_SYSCTL
58384 + bool "Sysctl support"
58385 + default y if GRKERNSEC_CONFIG_AUTO
58386 + help
58387 + If you say Y here, you will be able to change the options that
58388 + grsecurity runs with at bootup, without having to recompile your
58389 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58390 + to enable (1) or disable (0) various features. All the sysctl entries
58391 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58392 + All features enabled in the kernel configuration are disabled at boot
58393 + if you do not say Y to the "Turn on features by default" option.
58394 + All options should be set at startup, and the grsec_lock entry should
58395 + be set to a non-zero value after all the options are set.
58396 + *THIS IS EXTREMELY IMPORTANT*
58397 +
58398 +config GRKERNSEC_SYSCTL_DISTRO
58399 + bool "Extra sysctl support for distro makers (READ HELP)"
58400 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58401 + help
58402 + If you say Y here, additional sysctl options will be created
58403 + for features that affect processes running as root. Therefore,
58404 + it is critical when using this option that the grsec_lock entry be
58405 + enabled after boot. Only distros with prebuilt kernel packages
58406 + with this option enabled that can ensure grsec_lock is enabled
58407 + after boot should use this option.
58408 + *Failure to set grsec_lock after boot makes all grsec features
58409 + this option covers useless*
58410 +
58411 + Currently this option creates the following sysctl entries:
58412 + "Disable Privileged I/O": "disable_priv_io"
58413 +
58414 +config GRKERNSEC_SYSCTL_ON
58415 + bool "Turn on features by default"
58416 + default y if GRKERNSEC_CONFIG_AUTO
58417 + depends on GRKERNSEC_SYSCTL
58418 + help
58419 + If you say Y here, instead of having all features enabled in the
58420 + kernel configuration disabled at boot time, the features will be
58421 + enabled at boot time. It is recommended you say Y here unless
58422 + there is some reason you would want all sysctl-tunable features to
58423 + be disabled by default. As mentioned elsewhere, it is important
58424 + to enable the grsec_lock entry once you have finished modifying
58425 + the sysctl entries.
58426 +
58427 +endmenu
58428 +menu "Logging Options"
58429 +depends on GRKERNSEC
58430 +
58431 +config GRKERNSEC_FLOODTIME
58432 + int "Seconds in between log messages (minimum)"
58433 + default 10
58434 + help
58435 + This option allows you to enforce the number of seconds between
58436 + grsecurity log messages. The default should be suitable for most
58437 + people, however, if you choose to change it, choose a value small enough
58438 + to allow informative logs to be produced, but large enough to
58439 + prevent flooding.
58440 +
58441 +config GRKERNSEC_FLOODBURST
58442 + int "Number of messages in a burst (maximum)"
58443 + default 6
58444 + help
58445 + This option allows you to choose the maximum number of messages allowed
58446 + within the flood time interval you chose in a separate option. The
58447 + default should be suitable for most people, however if you find that
58448 + many of your logs are being interpreted as flooding, you may want to
58449 + raise this value.
58450 +
58451 +endmenu
58452 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58453 new file mode 100644
58454 index 0000000..36845aa
58455 --- /dev/null
58456 +++ b/grsecurity/Makefile
58457 @@ -0,0 +1,42 @@
58458 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58459 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58460 +# into an RBAC system
58461 +#
58462 +# All code in this directory and various hooks inserted throughout the kernel
58463 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58464 +# under the GPL v2 or higher
58465 +
58466 +KBUILD_CFLAGS += -Werror
58467 +
58468 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58469 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58470 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58471 +
58472 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58473 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58474 + gracl_learn.o grsec_log.o
58475 +ifdef CONFIG_COMPAT
58476 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
58477 +endif
58478 +
58479 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58480 +
58481 +ifdef CONFIG_NET
58482 +obj-y += grsec_sock.o
58483 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58484 +endif
58485 +
58486 +ifndef CONFIG_GRKERNSEC
58487 +obj-y += grsec_disabled.o
58488 +endif
58489 +
58490 +ifdef CONFIG_GRKERNSEC_HIDESYM
58491 +extra-y := grsec_hidesym.o
58492 +$(obj)/grsec_hidesym.o:
58493 + @-chmod -f 500 /boot
58494 + @-chmod -f 500 /lib/modules
58495 + @-chmod -f 500 /lib64/modules
58496 + @-chmod -f 500 /lib32/modules
58497 + @-chmod -f 700 .
58498 + @echo ' grsec: protected kernel image paths'
58499 +endif
58500 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58501 new file mode 100644
58502 index 0000000..6907918
58503 --- /dev/null
58504 +++ b/grsecurity/gracl.c
58505 @@ -0,0 +1,4178 @@
58506 +#include <linux/kernel.h>
58507 +#include <linux/module.h>
58508 +#include <linux/sched.h>
58509 +#include <linux/mm.h>
58510 +#include <linux/file.h>
58511 +#include <linux/fs.h>
58512 +#include <linux/namei.h>
58513 +#include <linux/mount.h>
58514 +#include <linux/tty.h>
58515 +#include <linux/proc_fs.h>
58516 +#include <linux/lglock.h>
58517 +#include <linux/slab.h>
58518 +#include <linux/vmalloc.h>
58519 +#include <linux/types.h>
58520 +#include <linux/sysctl.h>
58521 +#include <linux/netdevice.h>
58522 +#include <linux/ptrace.h>
58523 +#include <linux/gracl.h>
58524 +#include <linux/gralloc.h>
58525 +#include <linux/security.h>
58526 +#include <linux/grinternal.h>
58527 +#include <linux/pid_namespace.h>
58528 +#include <linux/stop_machine.h>
58529 +#include <linux/fdtable.h>
58530 +#include <linux/percpu.h>
58531 +#include <linux/lglock.h>
58532 +#include <linux/hugetlb.h>
58533 +#include <linux/posix-timers.h>
58534 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58535 +#include <linux/magic.h>
58536 +#include <linux/pagemap.h>
58537 +#include "../fs/btrfs/async-thread.h"
58538 +#include "../fs/btrfs/ctree.h"
58539 +#include "../fs/btrfs/btrfs_inode.h"
58540 +#endif
58541 +#include "../fs/mount.h"
58542 +
58543 +#include <asm/uaccess.h>
58544 +#include <asm/errno.h>
58545 +#include <asm/mman.h>
58546 +
58547 +extern struct lglock vfsmount_lock;
58548 +
58549 +static struct acl_role_db acl_role_set;
58550 +static struct name_db name_set;
58551 +static struct inodev_db inodev_set;
58552 +
58553 +/* for keeping track of userspace pointers used for subjects, so we
58554 + can share references in the kernel as well
58555 +*/
58556 +
58557 +static struct path real_root;
58558 +
58559 +static struct acl_subj_map_db subj_map_set;
58560 +
58561 +static struct acl_role_label *default_role;
58562 +
58563 +static struct acl_role_label *role_list;
58564 +
58565 +static u16 acl_sp_role_value;
58566 +
58567 +extern char *gr_shared_page[4];
58568 +static DEFINE_MUTEX(gr_dev_mutex);
58569 +DEFINE_RWLOCK(gr_inode_lock);
58570 +
58571 +struct gr_arg *gr_usermode;
58572 +
58573 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58574 +
58575 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58576 +extern void gr_clear_learn_entries(void);
58577 +
58578 +unsigned char *gr_system_salt;
58579 +unsigned char *gr_system_sum;
58580 +
58581 +static struct sprole_pw **acl_special_roles = NULL;
58582 +static __u16 num_sprole_pws = 0;
58583 +
58584 +static struct acl_role_label *kernel_role = NULL;
58585 +
58586 +static unsigned int gr_auth_attempts = 0;
58587 +static unsigned long gr_auth_expires = 0UL;
58588 +
58589 +#ifdef CONFIG_NET
58590 +extern struct vfsmount *sock_mnt;
58591 +#endif
58592 +
58593 +extern struct vfsmount *pipe_mnt;
58594 +extern struct vfsmount *shm_mnt;
58595 +
58596 +#ifdef CONFIG_HUGETLBFS
58597 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58598 +#endif
58599 +
58600 +static struct acl_object_label *fakefs_obj_rw;
58601 +static struct acl_object_label *fakefs_obj_rwx;
58602 +
58603 +extern int gr_init_uidset(void);
58604 +extern void gr_free_uidset(void);
58605 +extern void gr_remove_uid(uid_t uid);
58606 +extern int gr_find_uid(uid_t uid);
58607 +
58608 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
58609 +{
58610 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
58611 + return -EFAULT;
58612 +
58613 + return 0;
58614 +}
58615 +
58616 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
58617 +{
58618 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
58619 + return -EFAULT;
58620 +
58621 + return 0;
58622 +}
58623 +
58624 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
58625 +{
58626 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
58627 + return -EFAULT;
58628 +
58629 + return 0;
58630 +}
58631 +
58632 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
58633 +{
58634 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
58635 + return -EFAULT;
58636 +
58637 + return 0;
58638 +}
58639 +
58640 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
58641 +{
58642 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
58643 + return -EFAULT;
58644 +
58645 + return 0;
58646 +}
58647 +
58648 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
58649 +{
58650 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
58651 + return -EFAULT;
58652 +
58653 + return 0;
58654 +}
58655 +
58656 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
58657 +{
58658 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
58659 + return -EFAULT;
58660 +
58661 + return 0;
58662 +}
58663 +
58664 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
58665 +{
58666 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
58667 + return -EFAULT;
58668 +
58669 + return 0;
58670 +}
58671 +
58672 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
58673 +{
58674 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
58675 + return -EFAULT;
58676 +
58677 + return 0;
58678 +}
58679 +
58680 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
58681 +{
58682 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
58683 + return -EFAULT;
58684 +
58685 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
58686 + return -EINVAL;
58687 +
58688 + return 0;
58689 +}
58690 +
58691 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
58692 +{
58693 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
58694 + return -EFAULT;
58695 +
58696 + return 0;
58697 +}
58698 +
58699 +static size_t get_gr_arg_wrapper_size_normal(void)
58700 +{
58701 + return sizeof(struct gr_arg_wrapper);
58702 +}
58703 +
58704 +#ifdef CONFIG_COMPAT
58705 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
58706 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
58707 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
58708 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
58709 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
58710 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
58711 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
58712 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
58713 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
58714 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
58715 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
58716 +extern size_t get_gr_arg_wrapper_size_compat(void);
58717 +
58718 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
58719 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
58720 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
58721 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
58722 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
58723 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
58724 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
58725 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
58726 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
58727 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
58728 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
58729 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
58730 +
58731 +#else
58732 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
58733 +#define copy_gr_arg copy_gr_arg_normal
58734 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
58735 +#define copy_acl_object_label copy_acl_object_label_normal
58736 +#define copy_acl_subject_label copy_acl_subject_label_normal
58737 +#define copy_acl_role_label copy_acl_role_label_normal
58738 +#define copy_acl_ip_label copy_acl_ip_label_normal
58739 +#define copy_pointer_from_array copy_pointer_from_array_normal
58740 +#define copy_sprole_pw copy_sprole_pw_normal
58741 +#define copy_role_transition copy_role_transition_normal
58742 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
58743 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
58744 +#endif
58745 +
58746 +__inline__ int
58747 +gr_acl_is_enabled(void)
58748 +{
58749 + return (gr_status & GR_READY);
58750 +}
58751 +
58752 +static inline dev_t __get_dev(const struct dentry *dentry)
58753 +{
58754 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58755 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
58756 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
58757 + else
58758 +#endif
58759 + return dentry->d_sb->s_dev;
58760 +}
58761 +
58762 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58763 +{
58764 + return __get_dev(dentry);
58765 +}
58766 +
58767 +static char gr_task_roletype_to_char(struct task_struct *task)
58768 +{
58769 + switch (task->role->roletype &
58770 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58771 + GR_ROLE_SPECIAL)) {
58772 + case GR_ROLE_DEFAULT:
58773 + return 'D';
58774 + case GR_ROLE_USER:
58775 + return 'U';
58776 + case GR_ROLE_GROUP:
58777 + return 'G';
58778 + case GR_ROLE_SPECIAL:
58779 + return 'S';
58780 + }
58781 +
58782 + return 'X';
58783 +}
58784 +
58785 +char gr_roletype_to_char(void)
58786 +{
58787 + return gr_task_roletype_to_char(current);
58788 +}
58789 +
58790 +__inline__ int
58791 +gr_acl_tpe_check(void)
58792 +{
58793 + if (unlikely(!(gr_status & GR_READY)))
58794 + return 0;
58795 + if (current->role->roletype & GR_ROLE_TPE)
58796 + return 1;
58797 + else
58798 + return 0;
58799 +}
58800 +
58801 +int
58802 +gr_handle_rawio(const struct inode *inode)
58803 +{
58804 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58805 + if (inode && S_ISBLK(inode->i_mode) &&
58806 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58807 + !capable(CAP_SYS_RAWIO))
58808 + return 1;
58809 +#endif
58810 + return 0;
58811 +}
58812 +
58813 +static int
58814 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58815 +{
58816 + if (likely(lena != lenb))
58817 + return 0;
58818 +
58819 + return !memcmp(a, b, lena);
58820 +}
58821 +
58822 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58823 +{
58824 + *buflen -= namelen;
58825 + if (*buflen < 0)
58826 + return -ENAMETOOLONG;
58827 + *buffer -= namelen;
58828 + memcpy(*buffer, str, namelen);
58829 + return 0;
58830 +}
58831 +
58832 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58833 +{
58834 + return prepend(buffer, buflen, name->name, name->len);
58835 +}
58836 +
58837 +static int prepend_path(const struct path *path, struct path *root,
58838 + char **buffer, int *buflen)
58839 +{
58840 + struct dentry *dentry = path->dentry;
58841 + struct vfsmount *vfsmnt = path->mnt;
58842 + struct mount *mnt = real_mount(vfsmnt);
58843 + bool slash = false;
58844 + int error = 0;
58845 +
58846 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58847 + struct dentry * parent;
58848 +
58849 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58850 + /* Global root? */
58851 + if (!mnt_has_parent(mnt)) {
58852 + goto out;
58853 + }
58854 + dentry = mnt->mnt_mountpoint;
58855 + mnt = mnt->mnt_parent;
58856 + vfsmnt = &mnt->mnt;
58857 + continue;
58858 + }
58859 + parent = dentry->d_parent;
58860 + prefetch(parent);
58861 + spin_lock(&dentry->d_lock);
58862 + error = prepend_name(buffer, buflen, &dentry->d_name);
58863 + spin_unlock(&dentry->d_lock);
58864 + if (!error)
58865 + error = prepend(buffer, buflen, "/", 1);
58866 + if (error)
58867 + break;
58868 +
58869 + slash = true;
58870 + dentry = parent;
58871 + }
58872 +
58873 +out:
58874 + if (!error && !slash)
58875 + error = prepend(buffer, buflen, "/", 1);
58876 +
58877 + return error;
58878 +}
58879 +
58880 +/* this must be called with vfsmount_lock and rename_lock held */
58881 +
58882 +static char *__our_d_path(const struct path *path, struct path *root,
58883 + char *buf, int buflen)
58884 +{
58885 + char *res = buf + buflen;
58886 + int error;
58887 +
58888 + prepend(&res, &buflen, "\0", 1);
58889 + error = prepend_path(path, root, &res, &buflen);
58890 + if (error)
58891 + return ERR_PTR(error);
58892 +
58893 + return res;
58894 +}
58895 +
58896 +static char *
58897 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58898 +{
58899 + char *retval;
58900 +
58901 + retval = __our_d_path(path, root, buf, buflen);
58902 + if (unlikely(IS_ERR(retval)))
58903 + retval = strcpy(buf, "<path too long>");
58904 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58905 + retval[1] = '\0';
58906 +
58907 + return retval;
58908 +}
58909 +
58910 +static char *
58911 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58912 + char *buf, int buflen)
58913 +{
58914 + struct path path;
58915 + char *res;
58916 +
58917 + path.dentry = (struct dentry *)dentry;
58918 + path.mnt = (struct vfsmount *)vfsmnt;
58919 +
58920 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58921 + by the RBAC system */
58922 + res = gen_full_path(&path, &real_root, buf, buflen);
58923 +
58924 + return res;
58925 +}
58926 +
58927 +static char *
58928 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58929 + char *buf, int buflen)
58930 +{
58931 + char *res;
58932 + struct path path;
58933 + struct path root;
58934 + struct task_struct *reaper = init_pid_ns.child_reaper;
58935 +
58936 + path.dentry = (struct dentry *)dentry;
58937 + path.mnt = (struct vfsmount *)vfsmnt;
58938 +
58939 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58940 + get_fs_root(reaper->fs, &root);
58941 +
58942 + br_read_lock(&vfsmount_lock);
58943 + write_seqlock(&rename_lock);
58944 + res = gen_full_path(&path, &root, buf, buflen);
58945 + write_sequnlock(&rename_lock);
58946 + br_read_unlock(&vfsmount_lock);
58947 +
58948 + path_put(&root);
58949 + return res;
58950 +}
58951 +
58952 +static char *
58953 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58954 +{
58955 + char *ret;
58956 + br_read_lock(&vfsmount_lock);
58957 + write_seqlock(&rename_lock);
58958 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58959 + PAGE_SIZE);
58960 + write_sequnlock(&rename_lock);
58961 + br_read_unlock(&vfsmount_lock);
58962 + return ret;
58963 +}
58964 +
58965 +static char *
58966 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58967 +{
58968 + char *ret;
58969 + char *buf;
58970 + int buflen;
58971 +
58972 + br_read_lock(&vfsmount_lock);
58973 + write_seqlock(&rename_lock);
58974 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58975 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58976 + buflen = (int)(ret - buf);
58977 + if (buflen >= 5)
58978 + prepend(&ret, &buflen, "/proc", 5);
58979 + else
58980 + ret = strcpy(buf, "<path too long>");
58981 + write_sequnlock(&rename_lock);
58982 + br_read_unlock(&vfsmount_lock);
58983 + return ret;
58984 +}
58985 +
58986 +char *
58987 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58988 +{
58989 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58990 + PAGE_SIZE);
58991 +}
58992 +
58993 +char *
58994 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58995 +{
58996 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58997 + PAGE_SIZE);
58998 +}
58999 +
59000 +char *
59001 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
59002 +{
59003 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
59004 + PAGE_SIZE);
59005 +}
59006 +
59007 +char *
59008 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
59009 +{
59010 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
59011 + PAGE_SIZE);
59012 +}
59013 +
59014 +char *
59015 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
59016 +{
59017 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
59018 + PAGE_SIZE);
59019 +}
59020 +
59021 +__inline__ __u32
59022 +to_gr_audit(const __u32 reqmode)
59023 +{
59024 + /* masks off auditable permission flags, then shifts them to create
59025 + auditing flags, and adds the special case of append auditing if
59026 + we're requesting write */
59027 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
59028 +}
59029 +
59030 +struct acl_subject_label *
59031 +lookup_subject_map(const struct acl_subject_label *userp)
59032 +{
59033 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
59034 + struct subject_map *match;
59035 +
59036 + match = subj_map_set.s_hash[index];
59037 +
59038 + while (match && match->user != userp)
59039 + match = match->next;
59040 +
59041 + if (match != NULL)
59042 + return match->kernel;
59043 + else
59044 + return NULL;
59045 +}
59046 +
59047 +static void
59048 +insert_subj_map_entry(struct subject_map *subjmap)
59049 +{
59050 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
59051 + struct subject_map **curr;
59052 +
59053 + subjmap->prev = NULL;
59054 +
59055 + curr = &subj_map_set.s_hash[index];
59056 + if (*curr != NULL)
59057 + (*curr)->prev = subjmap;
59058 +
59059 + subjmap->next = *curr;
59060 + *curr = subjmap;
59061 +
59062 + return;
59063 +}
59064 +
59065 +static struct acl_role_label *
59066 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
59067 + const gid_t gid)
59068 +{
59069 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
59070 + struct acl_role_label *match;
59071 + struct role_allowed_ip *ipp;
59072 + unsigned int x;
59073 + u32 curr_ip = task->signal->curr_ip;
59074 +
59075 + task->signal->saved_ip = curr_ip;
59076 +
59077 + match = acl_role_set.r_hash[index];
59078 +
59079 + while (match) {
59080 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
59081 + for (x = 0; x < match->domain_child_num; x++) {
59082 + if (match->domain_children[x] == uid)
59083 + goto found;
59084 + }
59085 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
59086 + break;
59087 + match = match->next;
59088 + }
59089 +found:
59090 + if (match == NULL) {
59091 + try_group:
59092 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
59093 + match = acl_role_set.r_hash[index];
59094 +
59095 + while (match) {
59096 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
59097 + for (x = 0; x < match->domain_child_num; x++) {
59098 + if (match->domain_children[x] == gid)
59099 + goto found2;
59100 + }
59101 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
59102 + break;
59103 + match = match->next;
59104 + }
59105 +found2:
59106 + if (match == NULL)
59107 + match = default_role;
59108 + if (match->allowed_ips == NULL)
59109 + return match;
59110 + else {
59111 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
59112 + if (likely
59113 + ((ntohl(curr_ip) & ipp->netmask) ==
59114 + (ntohl(ipp->addr) & ipp->netmask)))
59115 + return match;
59116 + }
59117 + match = default_role;
59118 + }
59119 + } else if (match->allowed_ips == NULL) {
59120 + return match;
59121 + } else {
59122 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
59123 + if (likely
59124 + ((ntohl(curr_ip) & ipp->netmask) ==
59125 + (ntohl(ipp->addr) & ipp->netmask)))
59126 + return match;
59127 + }
59128 + goto try_group;
59129 + }
59130 +
59131 + return match;
59132 +}
59133 +
59134 +struct acl_subject_label *
59135 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
59136 + const struct acl_role_label *role)
59137 +{
59138 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
59139 + struct acl_subject_label *match;
59140 +
59141 + match = role->subj_hash[index];
59142 +
59143 + while (match && (match->inode != ino || match->device != dev ||
59144 + (match->mode & GR_DELETED))) {
59145 + match = match->next;
59146 + }
59147 +
59148 + if (match && !(match->mode & GR_DELETED))
59149 + return match;
59150 + else
59151 + return NULL;
59152 +}
59153 +
59154 +struct acl_subject_label *
59155 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
59156 + const struct acl_role_label *role)
59157 +{
59158 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
59159 + struct acl_subject_label *match;
59160 +
59161 + match = role->subj_hash[index];
59162 +
59163 + while (match && (match->inode != ino || match->device != dev ||
59164 + !(match->mode & GR_DELETED))) {
59165 + match = match->next;
59166 + }
59167 +
59168 + if (match && (match->mode & GR_DELETED))
59169 + return match;
59170 + else
59171 + return NULL;
59172 +}
59173 +
59174 +static struct acl_object_label *
59175 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
59176 + const struct acl_subject_label *subj)
59177 +{
59178 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
59179 + struct acl_object_label *match;
59180 +
59181 + match = subj->obj_hash[index];
59182 +
59183 + while (match && (match->inode != ino || match->device != dev ||
59184 + (match->mode & GR_DELETED))) {
59185 + match = match->next;
59186 + }
59187 +
59188 + if (match && !(match->mode & GR_DELETED))
59189 + return match;
59190 + else
59191 + return NULL;
59192 +}
59193 +
59194 +static struct acl_object_label *
59195 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
59196 + const struct acl_subject_label *subj)
59197 +{
59198 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
59199 + struct acl_object_label *match;
59200 +
59201 + match = subj->obj_hash[index];
59202 +
59203 + while (match && (match->inode != ino || match->device != dev ||
59204 + !(match->mode & GR_DELETED))) {
59205 + match = match->next;
59206 + }
59207 +
59208 + if (match && (match->mode & GR_DELETED))
59209 + return match;
59210 +
59211 + match = subj->obj_hash[index];
59212 +
59213 + while (match && (match->inode != ino || match->device != dev ||
59214 + (match->mode & GR_DELETED))) {
59215 + match = match->next;
59216 + }
59217 +
59218 + if (match && !(match->mode & GR_DELETED))
59219 + return match;
59220 + else
59221 + return NULL;
59222 +}
59223 +
59224 +static struct name_entry *
59225 +lookup_name_entry(const char *name)
59226 +{
59227 + unsigned int len = strlen(name);
59228 + unsigned int key = full_name_hash(name, len);
59229 + unsigned int index = key % name_set.n_size;
59230 + struct name_entry *match;
59231 +
59232 + match = name_set.n_hash[index];
59233 +
59234 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
59235 + match = match->next;
59236 +
59237 + return match;
59238 +}
59239 +
59240 +static struct name_entry *
59241 +lookup_name_entry_create(const char *name)
59242 +{
59243 + unsigned int len = strlen(name);
59244 + unsigned int key = full_name_hash(name, len);
59245 + unsigned int index = key % name_set.n_size;
59246 + struct name_entry *match;
59247 +
59248 + match = name_set.n_hash[index];
59249 +
59250 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
59251 + !match->deleted))
59252 + match = match->next;
59253 +
59254 + if (match && match->deleted)
59255 + return match;
59256 +
59257 + match = name_set.n_hash[index];
59258 +
59259 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
59260 + match->deleted))
59261 + match = match->next;
59262 +
59263 + if (match && !match->deleted)
59264 + return match;
59265 + else
59266 + return NULL;
59267 +}
59268 +
59269 +static struct inodev_entry *
59270 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
59271 +{
59272 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
59273 + struct inodev_entry *match;
59274 +
59275 + match = inodev_set.i_hash[index];
59276 +
59277 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
59278 + match = match->next;
59279 +
59280 + return match;
59281 +}
59282 +
59283 +static void
59284 +insert_inodev_entry(struct inodev_entry *entry)
59285 +{
59286 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
59287 + inodev_set.i_size);
59288 + struct inodev_entry **curr;
59289 +
59290 + entry->prev = NULL;
59291 +
59292 + curr = &inodev_set.i_hash[index];
59293 + if (*curr != NULL)
59294 + (*curr)->prev = entry;
59295 +
59296 + entry->next = *curr;
59297 + *curr = entry;
59298 +
59299 + return;
59300 +}
59301 +
59302 +static void
59303 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
59304 +{
59305 + unsigned int index =
59306 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
59307 + struct acl_role_label **curr;
59308 + struct acl_role_label *tmp, *tmp2;
59309 +
59310 + curr = &acl_role_set.r_hash[index];
59311 +
59312 + /* simple case, slot is empty, just set it to our role */
59313 + if (*curr == NULL) {
59314 + *curr = role;
59315 + } else {
59316 + /* example:
59317 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
59318 + 2 -> 3
59319 + */
59320 + /* first check to see if we can already be reached via this slot */
59321 + tmp = *curr;
59322 + while (tmp && tmp != role)
59323 + tmp = tmp->next;
59324 + if (tmp == role) {
59325 + /* we don't need to add ourselves to this slot's chain */
59326 + return;
59327 + }
59328 + /* we need to add ourselves to this chain, two cases */
59329 + if (role->next == NULL) {
59330 + /* simple case, append the current chain to our role */
59331 + role->next = *curr;
59332 + *curr = role;
59333 + } else {
59334 + /* 1 -> 2 -> 3 -> 4
59335 + 2 -> 3 -> 4
59336 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
59337 + */
59338 + /* trickier case: walk our role's chain until we find
59339 + the role for the start of the current slot's chain */
59340 + tmp = role;
59341 + tmp2 = *curr;
59342 + while (tmp->next && tmp->next != tmp2)
59343 + tmp = tmp->next;
59344 + if (tmp->next == tmp2) {
59345 + /* from example above, we found 3, so just
59346 + replace this slot's chain with ours */
59347 + *curr = role;
59348 + } else {
59349 + /* we didn't find a subset of our role's chain
59350 + in the current slot's chain, so append their
59351 + chain to ours, and set us as the first role in
59352 + the slot's chain
59353 +
59354 + we could fold this case with the case above,
59355 + but making it explicit for clarity
59356 + */
59357 + tmp->next = tmp2;
59358 + *curr = role;
59359 + }
59360 + }
59361 + }
59362 +
59363 + return;
59364 +}
59365 +
59366 +static void
59367 +insert_acl_role_label(struct acl_role_label *role)
59368 +{
59369 + int i;
59370 +
59371 + if (role_list == NULL) {
59372 + role_list = role;
59373 + role->prev = NULL;
59374 + } else {
59375 + role->prev = role_list;
59376 + role_list = role;
59377 + }
59378 +
59379 + /* used for hash chains */
59380 + role->next = NULL;
59381 +
59382 + if (role->roletype & GR_ROLE_DOMAIN) {
59383 + for (i = 0; i < role->domain_child_num; i++)
59384 + __insert_acl_role_label(role, role->domain_children[i]);
59385 + } else
59386 + __insert_acl_role_label(role, role->uidgid);
59387 +}
59388 +
59389 +static int
59390 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
59391 +{
59392 + struct name_entry **curr, *nentry;
59393 + struct inodev_entry *ientry;
59394 + unsigned int len = strlen(name);
59395 + unsigned int key = full_name_hash(name, len);
59396 + unsigned int index = key % name_set.n_size;
59397 +
59398 + curr = &name_set.n_hash[index];
59399 +
59400 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
59401 + curr = &((*curr)->next);
59402 +
59403 + if (*curr != NULL)
59404 + return 1;
59405 +
59406 + nentry = acl_alloc(sizeof (struct name_entry));
59407 + if (nentry == NULL)
59408 + return 0;
59409 + ientry = acl_alloc(sizeof (struct inodev_entry));
59410 + if (ientry == NULL)
59411 + return 0;
59412 + ientry->nentry = nentry;
59413 +
59414 + nentry->key = key;
59415 + nentry->name = name;
59416 + nentry->inode = inode;
59417 + nentry->device = device;
59418 + nentry->len = len;
59419 + nentry->deleted = deleted;
59420 +
59421 + nentry->prev = NULL;
59422 + curr = &name_set.n_hash[index];
59423 + if (*curr != NULL)
59424 + (*curr)->prev = nentry;
59425 + nentry->next = *curr;
59426 + *curr = nentry;
59427 +
59428 + /* insert us into the table searchable by inode/dev */
59429 + insert_inodev_entry(ientry);
59430 +
59431 + return 1;
59432 +}
59433 +
59434 +static void
59435 +insert_acl_obj_label(struct acl_object_label *obj,
59436 + struct acl_subject_label *subj)
59437 +{
59438 + unsigned int index =
59439 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
59440 + struct acl_object_label **curr;
59441 +
59442 +
59443 + obj->prev = NULL;
59444 +
59445 + curr = &subj->obj_hash[index];
59446 + if (*curr != NULL)
59447 + (*curr)->prev = obj;
59448 +
59449 + obj->next = *curr;
59450 + *curr = obj;
59451 +
59452 + return;
59453 +}
59454 +
59455 +static void
59456 +insert_acl_subj_label(struct acl_subject_label *obj,
59457 + struct acl_role_label *role)
59458 +{
59459 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
59460 + struct acl_subject_label **curr;
59461 +
59462 + obj->prev = NULL;
59463 +
59464 + curr = &role->subj_hash[index];
59465 + if (*curr != NULL)
59466 + (*curr)->prev = obj;
59467 +
59468 + obj->next = *curr;
59469 + *curr = obj;
59470 +
59471 + return;
59472 +}
59473 +
59474 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59475 +
59476 +static void *
59477 +create_table(__u32 * len, int elementsize)
59478 +{
59479 + unsigned int table_sizes[] = {
59480 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59481 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59482 + 4194301, 8388593, 16777213, 33554393, 67108859
59483 + };
59484 + void *newtable = NULL;
59485 + unsigned int pwr = 0;
59486 +
59487 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59488 + table_sizes[pwr] <= *len)
59489 + pwr++;
59490 +
59491 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59492 + return newtable;
59493 +
59494 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59495 + newtable =
59496 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59497 + else
59498 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59499 +
59500 + *len = table_sizes[pwr];
59501 +
59502 + return newtable;
59503 +}
59504 +
59505 +static int
59506 +init_variables(const struct gr_arg *arg)
59507 +{
59508 + struct task_struct *reaper = init_pid_ns.child_reaper;
59509 + unsigned int stacksize;
59510 +
59511 + subj_map_set.s_size = arg->role_db.num_subjects;
59512 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59513 + name_set.n_size = arg->role_db.num_objects;
59514 + inodev_set.i_size = arg->role_db.num_objects;
59515 +
59516 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59517 + !name_set.n_size || !inodev_set.i_size)
59518 + return 1;
59519 +
59520 + if (!gr_init_uidset())
59521 + return 1;
59522 +
59523 + /* set up the stack that holds allocation info */
59524 +
59525 + stacksize = arg->role_db.num_pointers + 5;
59526 +
59527 + if (!acl_alloc_stack_init(stacksize))
59528 + return 1;
59529 +
59530 + /* grab reference for the real root dentry and vfsmount */
59531 + get_fs_root(reaper->fs, &real_root);
59532 +
59533 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59534 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59535 +#endif
59536 +
59537 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59538 + if (fakefs_obj_rw == NULL)
59539 + return 1;
59540 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59541 +
59542 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59543 + if (fakefs_obj_rwx == NULL)
59544 + return 1;
59545 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59546 +
59547 + subj_map_set.s_hash =
59548 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59549 + acl_role_set.r_hash =
59550 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59551 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59552 + inodev_set.i_hash =
59553 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59554 +
59555 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59556 + !name_set.n_hash || !inodev_set.i_hash)
59557 + return 1;
59558 +
59559 + memset(subj_map_set.s_hash, 0,
59560 + sizeof(struct subject_map *) * subj_map_set.s_size);
59561 + memset(acl_role_set.r_hash, 0,
59562 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59563 + memset(name_set.n_hash, 0,
59564 + sizeof (struct name_entry *) * name_set.n_size);
59565 + memset(inodev_set.i_hash, 0,
59566 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59567 +
59568 + return 0;
59569 +}
59570 +
59571 +/* free information not needed after startup
59572 + currently contains user->kernel pointer mappings for subjects
59573 +*/
59574 +
59575 +static void
59576 +free_init_variables(void)
59577 +{
59578 + __u32 i;
59579 +
59580 + if (subj_map_set.s_hash) {
59581 + for (i = 0; i < subj_map_set.s_size; i++) {
59582 + if (subj_map_set.s_hash[i]) {
59583 + kfree(subj_map_set.s_hash[i]);
59584 + subj_map_set.s_hash[i] = NULL;
59585 + }
59586 + }
59587 +
59588 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59589 + PAGE_SIZE)
59590 + kfree(subj_map_set.s_hash);
59591 + else
59592 + vfree(subj_map_set.s_hash);
59593 + }
59594 +
59595 + return;
59596 +}
59597 +
59598 +static void
59599 +free_variables(void)
59600 +{
59601 + struct acl_subject_label *s;
59602 + struct acl_role_label *r;
59603 + struct task_struct *task, *task2;
59604 + unsigned int x;
59605 +
59606 + gr_clear_learn_entries();
59607 +
59608 + read_lock(&tasklist_lock);
59609 + do_each_thread(task2, task) {
59610 + task->acl_sp_role = 0;
59611 + task->acl_role_id = 0;
59612 + task->acl = NULL;
59613 + task->role = NULL;
59614 + } while_each_thread(task2, task);
59615 + read_unlock(&tasklist_lock);
59616 +
59617 + /* release the reference to the real root dentry and vfsmount */
59618 + path_put(&real_root);
59619 + memset(&real_root, 0, sizeof(real_root));
59620 +
59621 + /* free all object hash tables */
59622 +
59623 + FOR_EACH_ROLE_START(r)
59624 + if (r->subj_hash == NULL)
59625 + goto next_role;
59626 + FOR_EACH_SUBJECT_START(r, s, x)
59627 + if (s->obj_hash == NULL)
59628 + break;
59629 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59630 + kfree(s->obj_hash);
59631 + else
59632 + vfree(s->obj_hash);
59633 + FOR_EACH_SUBJECT_END(s, x)
59634 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59635 + if (s->obj_hash == NULL)
59636 + break;
59637 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59638 + kfree(s->obj_hash);
59639 + else
59640 + vfree(s->obj_hash);
59641 + FOR_EACH_NESTED_SUBJECT_END(s)
59642 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59643 + kfree(r->subj_hash);
59644 + else
59645 + vfree(r->subj_hash);
59646 + r->subj_hash = NULL;
59647 +next_role:
59648 + FOR_EACH_ROLE_END(r)
59649 +
59650 + acl_free_all();
59651 +
59652 + if (acl_role_set.r_hash) {
59653 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59654 + PAGE_SIZE)
59655 + kfree(acl_role_set.r_hash);
59656 + else
59657 + vfree(acl_role_set.r_hash);
59658 + }
59659 + if (name_set.n_hash) {
59660 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59661 + PAGE_SIZE)
59662 + kfree(name_set.n_hash);
59663 + else
59664 + vfree(name_set.n_hash);
59665 + }
59666 +
59667 + if (inodev_set.i_hash) {
59668 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59669 + PAGE_SIZE)
59670 + kfree(inodev_set.i_hash);
59671 + else
59672 + vfree(inodev_set.i_hash);
59673 + }
59674 +
59675 + gr_free_uidset();
59676 +
59677 + memset(&name_set, 0, sizeof (struct name_db));
59678 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59679 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59680 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59681 +
59682 + default_role = NULL;
59683 + kernel_role = NULL;
59684 + role_list = NULL;
59685 +
59686 + return;
59687 +}
59688 +
59689 +static struct acl_subject_label *
59690 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59691 +
59692 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
59693 +{
59694 + unsigned int len = strnlen_user(*name, maxlen);
59695 + char *tmp;
59696 +
59697 + if (!len || len >= maxlen)
59698 + return -EINVAL;
59699 +
59700 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59701 + return -ENOMEM;
59702 +
59703 + if (copy_from_user(tmp, *name, len))
59704 + return -EFAULT;
59705 +
59706 + tmp[len-1] = '\0';
59707 + *name = tmp;
59708 +
59709 + return 0;
59710 +}
59711 +
59712 +static int
59713 +copy_user_glob(struct acl_object_label *obj)
59714 +{
59715 + struct acl_object_label *g_tmp, **guser;
59716 + int error;
59717 +
59718 + if (obj->globbed == NULL)
59719 + return 0;
59720 +
59721 + guser = &obj->globbed;
59722 + while (*guser) {
59723 + g_tmp = (struct acl_object_label *)
59724 + acl_alloc(sizeof (struct acl_object_label));
59725 + if (g_tmp == NULL)
59726 + return -ENOMEM;
59727 +
59728 + if (copy_acl_object_label(g_tmp, *guser))
59729 + return -EFAULT;
59730 +
59731 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
59732 + if (error)
59733 + return error;
59734 +
59735 + *guser = g_tmp;
59736 + guser = &(g_tmp->next);
59737 + }
59738 +
59739 + return 0;
59740 +}
59741 +
59742 +static int
59743 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59744 + struct acl_role_label *role)
59745 +{
59746 + struct acl_object_label *o_tmp;
59747 + int ret;
59748 +
59749 + while (userp) {
59750 + if ((o_tmp = (struct acl_object_label *)
59751 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59752 + return -ENOMEM;
59753 +
59754 + if (copy_acl_object_label(o_tmp, userp))
59755 + return -EFAULT;
59756 +
59757 + userp = o_tmp->prev;
59758 +
59759 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
59760 + if (ret)
59761 + return ret;
59762 +
59763 + insert_acl_obj_label(o_tmp, subj);
59764 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59765 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59766 + return -ENOMEM;
59767 +
59768 + ret = copy_user_glob(o_tmp);
59769 + if (ret)
59770 + return ret;
59771 +
59772 + if (o_tmp->nested) {
59773 + int already_copied;
59774 +
59775 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59776 + if (IS_ERR(o_tmp->nested))
59777 + return PTR_ERR(o_tmp->nested);
59778 +
59779 + /* insert into nested subject list if we haven't copied this one yet
59780 + to prevent duplicate entries */
59781 + if (!already_copied) {
59782 + o_tmp->nested->next = role->hash->first;
59783 + role->hash->first = o_tmp->nested;
59784 + }
59785 + }
59786 + }
59787 +
59788 + return 0;
59789 +}
59790 +
59791 +static __u32
59792 +count_user_subjs(struct acl_subject_label *userp)
59793 +{
59794 + struct acl_subject_label s_tmp;
59795 + __u32 num = 0;
59796 +
59797 + while (userp) {
59798 + if (copy_acl_subject_label(&s_tmp, userp))
59799 + break;
59800 +
59801 + userp = s_tmp.prev;
59802 + }
59803 +
59804 + return num;
59805 +}
59806 +
59807 +static int
59808 +copy_user_allowedips(struct acl_role_label *rolep)
59809 +{
59810 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59811 +
59812 + ruserip = rolep->allowed_ips;
59813 +
59814 + while (ruserip) {
59815 + rlast = rtmp;
59816 +
59817 + if ((rtmp = (struct role_allowed_ip *)
59818 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59819 + return -ENOMEM;
59820 +
59821 + if (copy_role_allowed_ip(rtmp, ruserip))
59822 + return -EFAULT;
59823 +
59824 + ruserip = rtmp->prev;
59825 +
59826 + if (!rlast) {
59827 + rtmp->prev = NULL;
59828 + rolep->allowed_ips = rtmp;
59829 + } else {
59830 + rlast->next = rtmp;
59831 + rtmp->prev = rlast;
59832 + }
59833 +
59834 + if (!ruserip)
59835 + rtmp->next = NULL;
59836 + }
59837 +
59838 + return 0;
59839 +}
59840 +
59841 +static int
59842 +copy_user_transitions(struct acl_role_label *rolep)
59843 +{
59844 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59845 + int error;
59846 +
59847 + rusertp = rolep->transitions;
59848 +
59849 + while (rusertp) {
59850 + rlast = rtmp;
59851 +
59852 + if ((rtmp = (struct role_transition *)
59853 + acl_alloc(sizeof (struct role_transition))) == NULL)
59854 + return -ENOMEM;
59855 +
59856 + if (copy_role_transition(rtmp, rusertp))
59857 + return -EFAULT;
59858 +
59859 + rusertp = rtmp->prev;
59860 +
59861 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
59862 + if (error)
59863 + return error;
59864 +
59865 + if (!rlast) {
59866 + rtmp->prev = NULL;
59867 + rolep->transitions = rtmp;
59868 + } else {
59869 + rlast->next = rtmp;
59870 + rtmp->prev = rlast;
59871 + }
59872 +
59873 + if (!rusertp)
59874 + rtmp->next = NULL;
59875 + }
59876 +
59877 + return 0;
59878 +}
59879 +
59880 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
59881 +{
59882 + struct acl_object_label o_tmp;
59883 + __u32 num = 0;
59884 +
59885 + while (userp) {
59886 + if (copy_acl_object_label(&o_tmp, userp))
59887 + break;
59888 +
59889 + userp = o_tmp.prev;
59890 + num++;
59891 + }
59892 +
59893 + return num;
59894 +}
59895 +
59896 +static struct acl_subject_label *
59897 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59898 +{
59899 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59900 + __u32 num_objs;
59901 + struct acl_ip_label **i_tmp, *i_utmp2;
59902 + struct gr_hash_struct ghash;
59903 + struct subject_map *subjmap;
59904 + unsigned int i_num;
59905 + int err;
59906 +
59907 + if (already_copied != NULL)
59908 + *already_copied = 0;
59909 +
59910 + s_tmp = lookup_subject_map(userp);
59911 +
59912 + /* we've already copied this subject into the kernel, just return
59913 + the reference to it, and don't copy it over again
59914 + */
59915 + if (s_tmp) {
59916 + if (already_copied != NULL)
59917 + *already_copied = 1;
59918 + return(s_tmp);
59919 + }
59920 +
59921 + if ((s_tmp = (struct acl_subject_label *)
59922 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59923 + return ERR_PTR(-ENOMEM);
59924 +
59925 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59926 + if (subjmap == NULL)
59927 + return ERR_PTR(-ENOMEM);
59928 +
59929 + subjmap->user = userp;
59930 + subjmap->kernel = s_tmp;
59931 + insert_subj_map_entry(subjmap);
59932 +
59933 + if (copy_acl_subject_label(s_tmp, userp))
59934 + return ERR_PTR(-EFAULT);
59935 +
59936 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
59937 + if (err)
59938 + return ERR_PTR(err);
59939 +
59940 + if (!strcmp(s_tmp->filename, "/"))
59941 + role->root_label = s_tmp;
59942 +
59943 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
59944 + return ERR_PTR(-EFAULT);
59945 +
59946 + /* copy user and group transition tables */
59947 +
59948 + if (s_tmp->user_trans_num) {
59949 + uid_t *uidlist;
59950 +
59951 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59952 + if (uidlist == NULL)
59953 + return ERR_PTR(-ENOMEM);
59954 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59955 + return ERR_PTR(-EFAULT);
59956 +
59957 + s_tmp->user_transitions = uidlist;
59958 + }
59959 +
59960 + if (s_tmp->group_trans_num) {
59961 + gid_t *gidlist;
59962 +
59963 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59964 + if (gidlist == NULL)
59965 + return ERR_PTR(-ENOMEM);
59966 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59967 + return ERR_PTR(-EFAULT);
59968 +
59969 + s_tmp->group_transitions = gidlist;
59970 + }
59971 +
59972 + /* set up object hash table */
59973 + num_objs = count_user_objs(ghash.first);
59974 +
59975 + s_tmp->obj_hash_size = num_objs;
59976 + s_tmp->obj_hash =
59977 + (struct acl_object_label **)
59978 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59979 +
59980 + if (!s_tmp->obj_hash)
59981 + return ERR_PTR(-ENOMEM);
59982 +
59983 + memset(s_tmp->obj_hash, 0,
59984 + s_tmp->obj_hash_size *
59985 + sizeof (struct acl_object_label *));
59986 +
59987 + /* add in objects */
59988 + err = copy_user_objs(ghash.first, s_tmp, role);
59989 +
59990 + if (err)
59991 + return ERR_PTR(err);
59992 +
59993 + /* set pointer for parent subject */
59994 + if (s_tmp->parent_subject) {
59995 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59996 +
59997 + if (IS_ERR(s_tmp2))
59998 + return s_tmp2;
59999 +
60000 + s_tmp->parent_subject = s_tmp2;
60001 + }
60002 +
60003 + /* add in ip acls */
60004 +
60005 + if (!s_tmp->ip_num) {
60006 + s_tmp->ips = NULL;
60007 + goto insert;
60008 + }
60009 +
60010 + i_tmp =
60011 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
60012 + sizeof (struct acl_ip_label *));
60013 +
60014 + if (!i_tmp)
60015 + return ERR_PTR(-ENOMEM);
60016 +
60017 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
60018 + *(i_tmp + i_num) =
60019 + (struct acl_ip_label *)
60020 + acl_alloc(sizeof (struct acl_ip_label));
60021 + if (!*(i_tmp + i_num))
60022 + return ERR_PTR(-ENOMEM);
60023 +
60024 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
60025 + return ERR_PTR(-EFAULT);
60026 +
60027 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
60028 + return ERR_PTR(-EFAULT);
60029 +
60030 + if ((*(i_tmp + i_num))->iface == NULL)
60031 + continue;
60032 +
60033 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
60034 + if (err)
60035 + return ERR_PTR(err);
60036 + }
60037 +
60038 + s_tmp->ips = i_tmp;
60039 +
60040 +insert:
60041 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
60042 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
60043 + return ERR_PTR(-ENOMEM);
60044 +
60045 + return s_tmp;
60046 +}
60047 +
60048 +static int
60049 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
60050 +{
60051 + struct acl_subject_label s_pre;
60052 + struct acl_subject_label * ret;
60053 + int err;
60054 +
60055 + while (userp) {
60056 + if (copy_acl_subject_label(&s_pre, userp))
60057 + return -EFAULT;
60058 +
60059 + ret = do_copy_user_subj(userp, role, NULL);
60060 +
60061 + err = PTR_ERR(ret);
60062 + if (IS_ERR(ret))
60063 + return err;
60064 +
60065 + insert_acl_subj_label(ret, role);
60066 +
60067 + userp = s_pre.prev;
60068 + }
60069 +
60070 + return 0;
60071 +}
60072 +
60073 +static int
60074 +copy_user_acl(struct gr_arg *arg)
60075 +{
60076 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
60077 + struct acl_subject_label *subj_list;
60078 + struct sprole_pw *sptmp;
60079 + struct gr_hash_struct *ghash;
60080 + uid_t *domainlist;
60081 + unsigned int r_num;
60082 + int err = 0;
60083 + __u16 i;
60084 + __u32 num_subjs;
60085 +
60086 + /* we need a default and kernel role */
60087 + if (arg->role_db.num_roles < 2)
60088 + return -EINVAL;
60089 +
60090 + /* copy special role authentication info from userspace */
60091 +
60092 + num_sprole_pws = arg->num_sprole_pws;
60093 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
60094 +
60095 + if (!acl_special_roles && num_sprole_pws)
60096 + return -ENOMEM;
60097 +
60098 + for (i = 0; i < num_sprole_pws; i++) {
60099 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
60100 + if (!sptmp)
60101 + return -ENOMEM;
60102 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
60103 + return -EFAULT;
60104 +
60105 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
60106 + if (err)
60107 + return err;
60108 +
60109 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60110 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
60111 +#endif
60112 +
60113 + acl_special_roles[i] = sptmp;
60114 + }
60115 +
60116 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
60117 +
60118 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
60119 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
60120 +
60121 + if (!r_tmp)
60122 + return -ENOMEM;
60123 +
60124 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
60125 + return -EFAULT;
60126 +
60127 + if (copy_acl_role_label(r_tmp, r_utmp2))
60128 + return -EFAULT;
60129 +
60130 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
60131 + if (err)
60132 + return err;
60133 +
60134 + if (!strcmp(r_tmp->rolename, "default")
60135 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
60136 + default_role = r_tmp;
60137 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
60138 + kernel_role = r_tmp;
60139 + }
60140 +
60141 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
60142 + return -ENOMEM;
60143 +
60144 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
60145 + return -EFAULT;
60146 +
60147 + r_tmp->hash = ghash;
60148 +
60149 + num_subjs = count_user_subjs(r_tmp->hash->first);
60150 +
60151 + r_tmp->subj_hash_size = num_subjs;
60152 + r_tmp->subj_hash =
60153 + (struct acl_subject_label **)
60154 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
60155 +
60156 + if (!r_tmp->subj_hash)
60157 + return -ENOMEM;
60158 +
60159 + err = copy_user_allowedips(r_tmp);
60160 + if (err)
60161 + return err;
60162 +
60163 + /* copy domain info */
60164 + if (r_tmp->domain_children != NULL) {
60165 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
60166 + if (domainlist == NULL)
60167 + return -ENOMEM;
60168 +
60169 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
60170 + return -EFAULT;
60171 +
60172 + r_tmp->domain_children = domainlist;
60173 + }
60174 +
60175 + err = copy_user_transitions(r_tmp);
60176 + if (err)
60177 + return err;
60178 +
60179 + memset(r_tmp->subj_hash, 0,
60180 + r_tmp->subj_hash_size *
60181 + sizeof (struct acl_subject_label *));
60182 +
60183 + /* acquire the list of subjects, then NULL out
60184 + the list prior to parsing the subjects for this role,
60185 + as during this parsing the list is replaced with a list
60186 + of *nested* subjects for the role
60187 + */
60188 + subj_list = r_tmp->hash->first;
60189 +
60190 + /* set nested subject list to null */
60191 + r_tmp->hash->first = NULL;
60192 +
60193 + err = copy_user_subjs(subj_list, r_tmp);
60194 +
60195 + if (err)
60196 + return err;
60197 +
60198 + insert_acl_role_label(r_tmp);
60199 + }
60200 +
60201 + if (default_role == NULL || kernel_role == NULL)
60202 + return -EINVAL;
60203 +
60204 + return err;
60205 +}
60206 +
60207 +static int
60208 +gracl_init(struct gr_arg *args)
60209 +{
60210 + int error = 0;
60211 +
60212 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
60213 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
60214 +
60215 + if (init_variables(args)) {
60216 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
60217 + error = -ENOMEM;
60218 + free_variables();
60219 + goto out;
60220 + }
60221 +
60222 + error = copy_user_acl(args);
60223 + free_init_variables();
60224 + if (error) {
60225 + free_variables();
60226 + goto out;
60227 + }
60228 +
60229 + if ((error = gr_set_acls(0))) {
60230 + free_variables();
60231 + goto out;
60232 + }
60233 +
60234 + pax_open_kernel();
60235 + gr_status |= GR_READY;
60236 + pax_close_kernel();
60237 +
60238 + out:
60239 + return error;
60240 +}
60241 +
60242 +/* derived from glibc fnmatch() 0: match, 1: no match*/
60243 +
60244 +static int
60245 +glob_match(const char *p, const char *n)
60246 +{
60247 + char c;
60248 +
60249 + while ((c = *p++) != '\0') {
60250 + switch (c) {
60251 + case '?':
60252 + if (*n == '\0')
60253 + return 1;
60254 + else if (*n == '/')
60255 + return 1;
60256 + break;
60257 + case '\\':
60258 + if (*n != c)
60259 + return 1;
60260 + break;
60261 + case '*':
60262 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
60263 + if (*n == '/')
60264 + return 1;
60265 + else if (c == '?') {
60266 + if (*n == '\0')
60267 + return 1;
60268 + else
60269 + ++n;
60270 + }
60271 + }
60272 + if (c == '\0') {
60273 + return 0;
60274 + } else {
60275 + const char *endp;
60276 +
60277 + if ((endp = strchr(n, '/')) == NULL)
60278 + endp = n + strlen(n);
60279 +
60280 + if (c == '[') {
60281 + for (--p; n < endp; ++n)
60282 + if (!glob_match(p, n))
60283 + return 0;
60284 + } else if (c == '/') {
60285 + while (*n != '\0' && *n != '/')
60286 + ++n;
60287 + if (*n == '/' && !glob_match(p, n + 1))
60288 + return 0;
60289 + } else {
60290 + for (--p; n < endp; ++n)
60291 + if (*n == c && !glob_match(p, n))
60292 + return 0;
60293 + }
60294 +
60295 + return 1;
60296 + }
60297 + case '[':
60298 + {
60299 + int not;
60300 + char cold;
60301 +
60302 + if (*n == '\0' || *n == '/')
60303 + return 1;
60304 +
60305 + not = (*p == '!' || *p == '^');
60306 + if (not)
60307 + ++p;
60308 +
60309 + c = *p++;
60310 + for (;;) {
60311 + unsigned char fn = (unsigned char)*n;
60312 +
60313 + if (c == '\0')
60314 + return 1;
60315 + else {
60316 + if (c == fn)
60317 + goto matched;
60318 + cold = c;
60319 + c = *p++;
60320 +
60321 + if (c == '-' && *p != ']') {
60322 + unsigned char cend = *p++;
60323 +
60324 + if (cend == '\0')
60325 + return 1;
60326 +
60327 + if (cold <= fn && fn <= cend)
60328 + goto matched;
60329 +
60330 + c = *p++;
60331 + }
60332 + }
60333 +
60334 + if (c == ']')
60335 + break;
60336 + }
60337 + if (!not)
60338 + return 1;
60339 + break;
60340 + matched:
60341 + while (c != ']') {
60342 + if (c == '\0')
60343 + return 1;
60344 +
60345 + c = *p++;
60346 + }
60347 + if (not)
60348 + return 1;
60349 + }
60350 + break;
60351 + default:
60352 + if (c != *n)
60353 + return 1;
60354 + }
60355 +
60356 + ++n;
60357 + }
60358 +
60359 + if (*n == '\0')
60360 + return 0;
60361 +
60362 + if (*n == '/')
60363 + return 0;
60364 +
60365 + return 1;
60366 +}
60367 +
60368 +static struct acl_object_label *
60369 +chk_glob_label(struct acl_object_label *globbed,
60370 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
60371 +{
60372 + struct acl_object_label *tmp;
60373 +
60374 + if (*path == NULL)
60375 + *path = gr_to_filename_nolock(dentry, mnt);
60376 +
60377 + tmp = globbed;
60378 +
60379 + while (tmp) {
60380 + if (!glob_match(tmp->filename, *path))
60381 + return tmp;
60382 + tmp = tmp->next;
60383 + }
60384 +
60385 + return NULL;
60386 +}
60387 +
60388 +static struct acl_object_label *
60389 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60390 + const ino_t curr_ino, const dev_t curr_dev,
60391 + const struct acl_subject_label *subj, char **path, const int checkglob)
60392 +{
60393 + struct acl_subject_label *tmpsubj;
60394 + struct acl_object_label *retval;
60395 + struct acl_object_label *retval2;
60396 +
60397 + tmpsubj = (struct acl_subject_label *) subj;
60398 + read_lock(&gr_inode_lock);
60399 + do {
60400 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60401 + if (retval) {
60402 + if (checkglob && retval->globbed) {
60403 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60404 + if (retval2)
60405 + retval = retval2;
60406 + }
60407 + break;
60408 + }
60409 + } while ((tmpsubj = tmpsubj->parent_subject));
60410 + read_unlock(&gr_inode_lock);
60411 +
60412 + return retval;
60413 +}
60414 +
60415 +static __inline__ struct acl_object_label *
60416 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60417 + struct dentry *curr_dentry,
60418 + const struct acl_subject_label *subj, char **path, const int checkglob)
60419 +{
60420 + int newglob = checkglob;
60421 + ino_t inode;
60422 + dev_t device;
60423 +
60424 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60425 + as we don't want a / * rule to match instead of the / object
60426 + don't do this for create lookups that call this function though, since they're looking up
60427 + on the parent and thus need globbing checks on all paths
60428 + */
60429 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60430 + newglob = GR_NO_GLOB;
60431 +
60432 + spin_lock(&curr_dentry->d_lock);
60433 + inode = curr_dentry->d_inode->i_ino;
60434 + device = __get_dev(curr_dentry);
60435 + spin_unlock(&curr_dentry->d_lock);
60436 +
60437 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60438 +}
60439 +
60440 +#ifdef CONFIG_HUGETLBFS
60441 +static inline bool
60442 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60443 +{
60444 + int i;
60445 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60446 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60447 + return true;
60448 + }
60449 +
60450 + return false;
60451 +}
60452 +#endif
60453 +
60454 +static struct acl_object_label *
60455 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60456 + const struct acl_subject_label *subj, char *path, const int checkglob)
60457 +{
60458 + struct dentry *dentry = (struct dentry *) l_dentry;
60459 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60460 + struct mount *real_mnt = real_mount(mnt);
60461 + struct acl_object_label *retval;
60462 + struct dentry *parent;
60463 +
60464 + br_read_lock(&vfsmount_lock);
60465 + write_seqlock(&rename_lock);
60466 +
60467 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60468 +#ifdef CONFIG_NET
60469 + mnt == sock_mnt ||
60470 +#endif
60471 +#ifdef CONFIG_HUGETLBFS
60472 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60473 +#endif
60474 + /* ignore Eric Biederman */
60475 + IS_PRIVATE(l_dentry->d_inode))) {
60476 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60477 + goto out;
60478 + }
60479 +
60480 + for (;;) {
60481 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60482 + break;
60483 +
60484 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60485 + if (!mnt_has_parent(real_mnt))
60486 + break;
60487 +
60488 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60489 + if (retval != NULL)
60490 + goto out;
60491 +
60492 + dentry = real_mnt->mnt_mountpoint;
60493 + real_mnt = real_mnt->mnt_parent;
60494 + mnt = &real_mnt->mnt;
60495 + continue;
60496 + }
60497 +
60498 + parent = dentry->d_parent;
60499 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60500 + if (retval != NULL)
60501 + goto out;
60502 +
60503 + dentry = parent;
60504 + }
60505 +
60506 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60507 +
60508 + /* real_root is pinned so we don't have to hold a reference */
60509 + if (retval == NULL)
60510 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60511 +out:
60512 + write_sequnlock(&rename_lock);
60513 + br_read_unlock(&vfsmount_lock);
60514 +
60515 + BUG_ON(retval == NULL);
60516 +
60517 + return retval;
60518 +}
60519 +
60520 +static __inline__ struct acl_object_label *
60521 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60522 + const struct acl_subject_label *subj)
60523 +{
60524 + char *path = NULL;
60525 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60526 +}
60527 +
60528 +static __inline__ struct acl_object_label *
60529 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60530 + const struct acl_subject_label *subj)
60531 +{
60532 + char *path = NULL;
60533 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60534 +}
60535 +
60536 +static __inline__ struct acl_object_label *
60537 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60538 + const struct acl_subject_label *subj, char *path)
60539 +{
60540 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60541 +}
60542 +
60543 +static struct acl_subject_label *
60544 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60545 + const struct acl_role_label *role)
60546 +{
60547 + struct dentry *dentry = (struct dentry *) l_dentry;
60548 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60549 + struct mount *real_mnt = real_mount(mnt);
60550 + struct acl_subject_label *retval;
60551 + struct dentry *parent;
60552 +
60553 + br_read_lock(&vfsmount_lock);
60554 + write_seqlock(&rename_lock);
60555 +
60556 + for (;;) {
60557 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60558 + break;
60559 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60560 + if (!mnt_has_parent(real_mnt))
60561 + break;
60562 +
60563 + spin_lock(&dentry->d_lock);
60564 + read_lock(&gr_inode_lock);
60565 + retval =
60566 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60567 + __get_dev(dentry), role);
60568 + read_unlock(&gr_inode_lock);
60569 + spin_unlock(&dentry->d_lock);
60570 + if (retval != NULL)
60571 + goto out;
60572 +
60573 + dentry = real_mnt->mnt_mountpoint;
60574 + real_mnt = real_mnt->mnt_parent;
60575 + mnt = &real_mnt->mnt;
60576 + continue;
60577 + }
60578 +
60579 + spin_lock(&dentry->d_lock);
60580 + read_lock(&gr_inode_lock);
60581 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60582 + __get_dev(dentry), role);
60583 + read_unlock(&gr_inode_lock);
60584 + parent = dentry->d_parent;
60585 + spin_unlock(&dentry->d_lock);
60586 +
60587 + if (retval != NULL)
60588 + goto out;
60589 +
60590 + dentry = parent;
60591 + }
60592 +
60593 + spin_lock(&dentry->d_lock);
60594 + read_lock(&gr_inode_lock);
60595 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60596 + __get_dev(dentry), role);
60597 + read_unlock(&gr_inode_lock);
60598 + spin_unlock(&dentry->d_lock);
60599 +
60600 + if (unlikely(retval == NULL)) {
60601 + /* real_root is pinned, we don't need to hold a reference */
60602 + read_lock(&gr_inode_lock);
60603 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60604 + __get_dev(real_root.dentry), role);
60605 + read_unlock(&gr_inode_lock);
60606 + }
60607 +out:
60608 + write_sequnlock(&rename_lock);
60609 + br_read_unlock(&vfsmount_lock);
60610 +
60611 + BUG_ON(retval == NULL);
60612 +
60613 + return retval;
60614 +}
60615 +
60616 +static void
60617 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60618 +{
60619 + struct task_struct *task = current;
60620 + const struct cred *cred = current_cred();
60621 +
60622 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60623 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60624 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60625 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60626 +
60627 + return;
60628 +}
60629 +
60630 +static void
60631 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60632 +{
60633 + struct task_struct *task = current;
60634 + const struct cred *cred = current_cred();
60635 +
60636 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60637 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60638 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60639 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60640 +
60641 + return;
60642 +}
60643 +
60644 +static void
60645 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60646 +{
60647 + struct task_struct *task = current;
60648 + const struct cred *cred = current_cred();
60649 +
60650 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60651 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60652 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60653 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60654 +
60655 + return;
60656 +}
60657 +
60658 +__u32
60659 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60660 + const struct vfsmount * mnt)
60661 +{
60662 + __u32 retval = mode;
60663 + struct acl_subject_label *curracl;
60664 + struct acl_object_label *currobj;
60665 +
60666 + if (unlikely(!(gr_status & GR_READY)))
60667 + return (mode & ~GR_AUDITS);
60668 +
60669 + curracl = current->acl;
60670 +
60671 + currobj = chk_obj_label(dentry, mnt, curracl);
60672 + retval = currobj->mode & mode;
60673 +
60674 + /* if we're opening a specified transfer file for writing
60675 + (e.g. /dev/initctl), then transfer our role to init
60676 + */
60677 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60678 + current->role->roletype & GR_ROLE_PERSIST)) {
60679 + struct task_struct *task = init_pid_ns.child_reaper;
60680 +
60681 + if (task->role != current->role) {
60682 + task->acl_sp_role = 0;
60683 + task->acl_role_id = current->acl_role_id;
60684 + task->role = current->role;
60685 + rcu_read_lock();
60686 + read_lock(&grsec_exec_file_lock);
60687 + gr_apply_subject_to_task(task);
60688 + read_unlock(&grsec_exec_file_lock);
60689 + rcu_read_unlock();
60690 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60691 + }
60692 + }
60693 +
60694 + if (unlikely
60695 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60696 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60697 + __u32 new_mode = mode;
60698 +
60699 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60700 +
60701 + retval = new_mode;
60702 +
60703 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60704 + new_mode |= GR_INHERIT;
60705 +
60706 + if (!(mode & GR_NOLEARN))
60707 + gr_log_learn(dentry, mnt, new_mode);
60708 + }
60709 +
60710 + return retval;
60711 +}
60712 +
60713 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60714 + const struct dentry *parent,
60715 + const struct vfsmount *mnt)
60716 +{
60717 + struct name_entry *match;
60718 + struct acl_object_label *matchpo;
60719 + struct acl_subject_label *curracl;
60720 + char *path;
60721 +
60722 + if (unlikely(!(gr_status & GR_READY)))
60723 + return NULL;
60724 +
60725 + preempt_disable();
60726 + path = gr_to_filename_rbac(new_dentry, mnt);
60727 + match = lookup_name_entry_create(path);
60728 +
60729 + curracl = current->acl;
60730 +
60731 + if (match) {
60732 + read_lock(&gr_inode_lock);
60733 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60734 + read_unlock(&gr_inode_lock);
60735 +
60736 + if (matchpo) {
60737 + preempt_enable();
60738 + return matchpo;
60739 + }
60740 + }
60741 +
60742 + // lookup parent
60743 +
60744 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60745 +
60746 + preempt_enable();
60747 + return matchpo;
60748 +}
60749 +
60750 +__u32
60751 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60752 + const struct vfsmount * mnt, const __u32 mode)
60753 +{
60754 + struct acl_object_label *matchpo;
60755 + __u32 retval;
60756 +
60757 + if (unlikely(!(gr_status & GR_READY)))
60758 + return (mode & ~GR_AUDITS);
60759 +
60760 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60761 +
60762 + retval = matchpo->mode & mode;
60763 +
60764 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60765 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60766 + __u32 new_mode = mode;
60767 +
60768 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60769 +
60770 + gr_log_learn(new_dentry, mnt, new_mode);
60771 + return new_mode;
60772 + }
60773 +
60774 + return retval;
60775 +}
60776 +
60777 +__u32
60778 +gr_check_link(const struct dentry * new_dentry,
60779 + const struct dentry * parent_dentry,
60780 + const struct vfsmount * parent_mnt,
60781 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60782 +{
60783 + struct acl_object_label *obj;
60784 + __u32 oldmode, newmode;
60785 + __u32 needmode;
60786 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60787 + GR_DELETE | GR_INHERIT;
60788 +
60789 + if (unlikely(!(gr_status & GR_READY)))
60790 + return (GR_CREATE | GR_LINK);
60791 +
60792 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60793 + oldmode = obj->mode;
60794 +
60795 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60796 + newmode = obj->mode;
60797 +
60798 + needmode = newmode & checkmodes;
60799 +
60800 + // old name for hardlink must have at least the permissions of the new name
60801 + if ((oldmode & needmode) != needmode)
60802 + goto bad;
60803 +
60804 + // if old name had restrictions/auditing, make sure the new name does as well
60805 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60806 +
60807 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60808 + if (is_privileged_binary(old_dentry))
60809 + needmode |= GR_SETID;
60810 +
60811 + if ((newmode & needmode) != needmode)
60812 + goto bad;
60813 +
60814 + // enforce minimum permissions
60815 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60816 + return newmode;
60817 +bad:
60818 + needmode = oldmode;
60819 + if (is_privileged_binary(old_dentry))
60820 + needmode |= GR_SETID;
60821 +
60822 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60823 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60824 + return (GR_CREATE | GR_LINK);
60825 + } else if (newmode & GR_SUPPRESS)
60826 + return GR_SUPPRESS;
60827 + else
60828 + return 0;
60829 +}
60830 +
60831 +int
60832 +gr_check_hidden_task(const struct task_struct *task)
60833 +{
60834 + if (unlikely(!(gr_status & GR_READY)))
60835 + return 0;
60836 +
60837 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60838 + return 1;
60839 +
60840 + return 0;
60841 +}
60842 +
60843 +int
60844 +gr_check_protected_task(const struct task_struct *task)
60845 +{
60846 + if (unlikely(!(gr_status & GR_READY) || !task))
60847 + return 0;
60848 +
60849 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60850 + task->acl != current->acl)
60851 + return 1;
60852 +
60853 + return 0;
60854 +}
60855 +
60856 +int
60857 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60858 +{
60859 + struct task_struct *p;
60860 + int ret = 0;
60861 +
60862 + if (unlikely(!(gr_status & GR_READY) || !pid))
60863 + return ret;
60864 +
60865 + read_lock(&tasklist_lock);
60866 + do_each_pid_task(pid, type, p) {
60867 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60868 + p->acl != current->acl) {
60869 + ret = 1;
60870 + goto out;
60871 + }
60872 + } while_each_pid_task(pid, type, p);
60873 +out:
60874 + read_unlock(&tasklist_lock);
60875 +
60876 + return ret;
60877 +}
60878 +
60879 +void
60880 +gr_copy_label(struct task_struct *tsk)
60881 +{
60882 + tsk->signal->used_accept = 0;
60883 + tsk->acl_sp_role = 0;
60884 + tsk->acl_role_id = current->acl_role_id;
60885 + tsk->acl = current->acl;
60886 + tsk->role = current->role;
60887 + tsk->signal->curr_ip = current->signal->curr_ip;
60888 + tsk->signal->saved_ip = current->signal->saved_ip;
60889 + if (current->exec_file)
60890 + get_file(current->exec_file);
60891 + tsk->exec_file = current->exec_file;
60892 + tsk->is_writable = current->is_writable;
60893 + if (unlikely(current->signal->used_accept)) {
60894 + current->signal->curr_ip = 0;
60895 + current->signal->saved_ip = 0;
60896 + }
60897 +
60898 + return;
60899 +}
60900 +
60901 +static void
60902 +gr_set_proc_res(struct task_struct *task)
60903 +{
60904 + struct acl_subject_label *proc;
60905 + unsigned short i;
60906 +
60907 + proc = task->acl;
60908 +
60909 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60910 + return;
60911 +
60912 + for (i = 0; i < RLIM_NLIMITS; i++) {
60913 + if (!(proc->resmask & (1U << i)))
60914 + continue;
60915 +
60916 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60917 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60918 +
60919 + if (i == RLIMIT_CPU)
60920 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60921 + }
60922 +
60923 + return;
60924 +}
60925 +
60926 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
60927 +
60928 +int
60929 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60930 +{
60931 + unsigned int i;
60932 + __u16 num;
60933 + uid_t *uidlist;
60934 + uid_t curuid;
60935 + int realok = 0;
60936 + int effectiveok = 0;
60937 + int fsok = 0;
60938 + uid_t globalreal, globaleffective, globalfs;
60939 +
60940 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
60941 + struct user_struct *user;
60942 +
60943 + if (!uid_valid(real))
60944 + goto skipit;
60945 +
60946 + /* find user based on global namespace */
60947 +
60948 + globalreal = GR_GLOBAL_UID(real);
60949 +
60950 + user = find_user(make_kuid(&init_user_ns, globalreal));
60951 + if (user == NULL)
60952 + goto skipit;
60953 +
60954 + if (gr_process_kernel_setuid_ban(user)) {
60955 + /* for find_user */
60956 + free_uid(user);
60957 + return 1;
60958 + }
60959 +
60960 + /* for find_user */
60961 + free_uid(user);
60962 +
60963 +skipit:
60964 +#endif
60965 +
60966 + if (unlikely(!(gr_status & GR_READY)))
60967 + return 0;
60968 +
60969 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60970 + gr_log_learn_uid_change(real, effective, fs);
60971 +
60972 + num = current->acl->user_trans_num;
60973 + uidlist = current->acl->user_transitions;
60974 +
60975 + if (uidlist == NULL)
60976 + return 0;
60977 +
60978 + if (!uid_valid(real)) {
60979 + realok = 1;
60980 + globalreal = (uid_t)-1;
60981 + } else {
60982 + globalreal = GR_GLOBAL_UID(real);
60983 + }
60984 + if (!uid_valid(effective)) {
60985 + effectiveok = 1;
60986 + globaleffective = (uid_t)-1;
60987 + } else {
60988 + globaleffective = GR_GLOBAL_UID(effective);
60989 + }
60990 + if (!uid_valid(fs)) {
60991 + fsok = 1;
60992 + globalfs = (uid_t)-1;
60993 + } else {
60994 + globalfs = GR_GLOBAL_UID(fs);
60995 + }
60996 +
60997 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60998 + for (i = 0; i < num; i++) {
60999 + curuid = uidlist[i];
61000 + if (globalreal == curuid)
61001 + realok = 1;
61002 + if (globaleffective == curuid)
61003 + effectiveok = 1;
61004 + if (globalfs == curuid)
61005 + fsok = 1;
61006 + }
61007 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
61008 + for (i = 0; i < num; i++) {
61009 + curuid = uidlist[i];
61010 + if (globalreal == curuid)
61011 + break;
61012 + if (globaleffective == curuid)
61013 + break;
61014 + if (globalfs == curuid)
61015 + break;
61016 + }
61017 + /* not in deny list */
61018 + if (i == num) {
61019 + realok = 1;
61020 + effectiveok = 1;
61021 + fsok = 1;
61022 + }
61023 + }
61024 +
61025 + if (realok && effectiveok && fsok)
61026 + return 0;
61027 + else {
61028 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
61029 + return 1;
61030 + }
61031 +}
61032 +
61033 +int
61034 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
61035 +{
61036 + unsigned int i;
61037 + __u16 num;
61038 + gid_t *gidlist;
61039 + gid_t curgid;
61040 + int realok = 0;
61041 + int effectiveok = 0;
61042 + int fsok = 0;
61043 + gid_t globalreal, globaleffective, globalfs;
61044 +
61045 + if (unlikely(!(gr_status & GR_READY)))
61046 + return 0;
61047 +
61048 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61049 + gr_log_learn_gid_change(real, effective, fs);
61050 +
61051 + num = current->acl->group_trans_num;
61052 + gidlist = current->acl->group_transitions;
61053 +
61054 + if (gidlist == NULL)
61055 + return 0;
61056 +
61057 + if (!gid_valid(real)) {
61058 + realok = 1;
61059 + globalreal = (gid_t)-1;
61060 + } else {
61061 + globalreal = GR_GLOBAL_GID(real);
61062 + }
61063 + if (!gid_valid(effective)) {
61064 + effectiveok = 1;
61065 + globaleffective = (gid_t)-1;
61066 + } else {
61067 + globaleffective = GR_GLOBAL_GID(effective);
61068 + }
61069 + if (!gid_valid(fs)) {
61070 + fsok = 1;
61071 + globalfs = (gid_t)-1;
61072 + } else {
61073 + globalfs = GR_GLOBAL_GID(fs);
61074 + }
61075 +
61076 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
61077 + for (i = 0; i < num; i++) {
61078 + curgid = gidlist[i];
61079 + if (globalreal == curgid)
61080 + realok = 1;
61081 + if (globaleffective == curgid)
61082 + effectiveok = 1;
61083 + if (globalfs == curgid)
61084 + fsok = 1;
61085 + }
61086 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
61087 + for (i = 0; i < num; i++) {
61088 + curgid = gidlist[i];
61089 + if (globalreal == curgid)
61090 + break;
61091 + if (globaleffective == curgid)
61092 + break;
61093 + if (globalfs == curgid)
61094 + break;
61095 + }
61096 + /* not in deny list */
61097 + if (i == num) {
61098 + realok = 1;
61099 + effectiveok = 1;
61100 + fsok = 1;
61101 + }
61102 + }
61103 +
61104 + if (realok && effectiveok && fsok)
61105 + return 0;
61106 + else {
61107 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
61108 + return 1;
61109 + }
61110 +}
61111 +
61112 +extern int gr_acl_is_capable(const int cap);
61113 +
61114 +void
61115 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
61116 +{
61117 + struct acl_role_label *role = task->role;
61118 + struct acl_subject_label *subj = NULL;
61119 + struct acl_object_label *obj;
61120 + struct file *filp;
61121 + uid_t uid;
61122 + gid_t gid;
61123 +
61124 + if (unlikely(!(gr_status & GR_READY)))
61125 + return;
61126 +
61127 + uid = GR_GLOBAL_UID(kuid);
61128 + gid = GR_GLOBAL_GID(kgid);
61129 +
61130 + filp = task->exec_file;
61131 +
61132 + /* kernel process, we'll give them the kernel role */
61133 + if (unlikely(!filp)) {
61134 + task->role = kernel_role;
61135 + task->acl = kernel_role->root_label;
61136 + return;
61137 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
61138 + role = lookup_acl_role_label(task, uid, gid);
61139 +
61140 + /* don't change the role if we're not a privileged process */
61141 + if (role && task->role != role &&
61142 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
61143 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
61144 + return;
61145 +
61146 + /* perform subject lookup in possibly new role
61147 + we can use this result below in the case where role == task->role
61148 + */
61149 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
61150 +
61151 + /* if we changed uid/gid, but result in the same role
61152 + and are using inheritance, don't lose the inherited subject
61153 + if current subject is other than what normal lookup
61154 + would result in, we arrived via inheritance, don't
61155 + lose subject
61156 + */
61157 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
61158 + (subj == task->acl)))
61159 + task->acl = subj;
61160 +
61161 + task->role = role;
61162 +
61163 + task->is_writable = 0;
61164 +
61165 + /* ignore additional mmap checks for processes that are writable
61166 + by the default ACL */
61167 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61168 + if (unlikely(obj->mode & GR_WRITE))
61169 + task->is_writable = 1;
61170 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61171 + if (unlikely(obj->mode & GR_WRITE))
61172 + task->is_writable = 1;
61173 +
61174 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61175 + 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);
61176 +#endif
61177 +
61178 + gr_set_proc_res(task);
61179 +
61180 + return;
61181 +}
61182 +
61183 +int
61184 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
61185 + const int unsafe_flags)
61186 +{
61187 + struct task_struct *task = current;
61188 + struct acl_subject_label *newacl;
61189 + struct acl_object_label *obj;
61190 + __u32 retmode;
61191 +
61192 + if (unlikely(!(gr_status & GR_READY)))
61193 + return 0;
61194 +
61195 + newacl = chk_subj_label(dentry, mnt, task->role);
61196 +
61197 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
61198 + did an exec
61199 + */
61200 + rcu_read_lock();
61201 + read_lock(&tasklist_lock);
61202 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
61203 + (task->parent->acl->mode & GR_POVERRIDE))) {
61204 + read_unlock(&tasklist_lock);
61205 + rcu_read_unlock();
61206 + goto skip_check;
61207 + }
61208 + read_unlock(&tasklist_lock);
61209 + rcu_read_unlock();
61210 +
61211 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
61212 + !(task->role->roletype & GR_ROLE_GOD) &&
61213 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
61214 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
61215 + if (unsafe_flags & LSM_UNSAFE_SHARE)
61216 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
61217 + else
61218 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
61219 + return -EACCES;
61220 + }
61221 +
61222 +skip_check:
61223 +
61224 + obj = chk_obj_label(dentry, mnt, task->acl);
61225 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
61226 +
61227 + if (!(task->acl->mode & GR_INHERITLEARN) &&
61228 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
61229 + if (obj->nested)
61230 + task->acl = obj->nested;
61231 + else
61232 + task->acl = newacl;
61233 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
61234 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
61235 +
61236 + task->is_writable = 0;
61237 +
61238 + /* ignore additional mmap checks for processes that are writable
61239 + by the default ACL */
61240 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
61241 + if (unlikely(obj->mode & GR_WRITE))
61242 + task->is_writable = 1;
61243 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
61244 + if (unlikely(obj->mode & GR_WRITE))
61245 + task->is_writable = 1;
61246 +
61247 + gr_set_proc_res(task);
61248 +
61249 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61250 + 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);
61251 +#endif
61252 + return 0;
61253 +}
61254 +
61255 +/* always called with valid inodev ptr */
61256 +static void
61257 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
61258 +{
61259 + struct acl_object_label *matchpo;
61260 + struct acl_subject_label *matchps;
61261 + struct acl_subject_label *subj;
61262 + struct acl_role_label *role;
61263 + unsigned int x;
61264 +
61265 + FOR_EACH_ROLE_START(role)
61266 + FOR_EACH_SUBJECT_START(role, subj, x)
61267 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
61268 + matchpo->mode |= GR_DELETED;
61269 + FOR_EACH_SUBJECT_END(subj,x)
61270 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61271 + /* nested subjects aren't in the role's subj_hash table */
61272 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
61273 + matchpo->mode |= GR_DELETED;
61274 + FOR_EACH_NESTED_SUBJECT_END(subj)
61275 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
61276 + matchps->mode |= GR_DELETED;
61277 + FOR_EACH_ROLE_END(role)
61278 +
61279 + inodev->nentry->deleted = 1;
61280 +
61281 + return;
61282 +}
61283 +
61284 +void
61285 +gr_handle_delete(const ino_t ino, const dev_t dev)
61286 +{
61287 + struct inodev_entry *inodev;
61288 +
61289 + if (unlikely(!(gr_status & GR_READY)))
61290 + return;
61291 +
61292 + write_lock(&gr_inode_lock);
61293 + inodev = lookup_inodev_entry(ino, dev);
61294 + if (inodev != NULL)
61295 + do_handle_delete(inodev, ino, dev);
61296 + write_unlock(&gr_inode_lock);
61297 +
61298 + return;
61299 +}
61300 +
61301 +static void
61302 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
61303 + const ino_t newinode, const dev_t newdevice,
61304 + struct acl_subject_label *subj)
61305 +{
61306 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
61307 + struct acl_object_label *match;
61308 +
61309 + match = subj->obj_hash[index];
61310 +
61311 + while (match && (match->inode != oldinode ||
61312 + match->device != olddevice ||
61313 + !(match->mode & GR_DELETED)))
61314 + match = match->next;
61315 +
61316 + if (match && (match->inode == oldinode)
61317 + && (match->device == olddevice)
61318 + && (match->mode & GR_DELETED)) {
61319 + if (match->prev == NULL) {
61320 + subj->obj_hash[index] = match->next;
61321 + if (match->next != NULL)
61322 + match->next->prev = NULL;
61323 + } else {
61324 + match->prev->next = match->next;
61325 + if (match->next != NULL)
61326 + match->next->prev = match->prev;
61327 + }
61328 + match->prev = NULL;
61329 + match->next = NULL;
61330 + match->inode = newinode;
61331 + match->device = newdevice;
61332 + match->mode &= ~GR_DELETED;
61333 +
61334 + insert_acl_obj_label(match, subj);
61335 + }
61336 +
61337 + return;
61338 +}
61339 +
61340 +static void
61341 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
61342 + const ino_t newinode, const dev_t newdevice,
61343 + struct acl_role_label *role)
61344 +{
61345 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
61346 + struct acl_subject_label *match;
61347 +
61348 + match = role->subj_hash[index];
61349 +
61350 + while (match && (match->inode != oldinode ||
61351 + match->device != olddevice ||
61352 + !(match->mode & GR_DELETED)))
61353 + match = match->next;
61354 +
61355 + if (match && (match->inode == oldinode)
61356 + && (match->device == olddevice)
61357 + && (match->mode & GR_DELETED)) {
61358 + if (match->prev == NULL) {
61359 + role->subj_hash[index] = match->next;
61360 + if (match->next != NULL)
61361 + match->next->prev = NULL;
61362 + } else {
61363 + match->prev->next = match->next;
61364 + if (match->next != NULL)
61365 + match->next->prev = match->prev;
61366 + }
61367 + match->prev = NULL;
61368 + match->next = NULL;
61369 + match->inode = newinode;
61370 + match->device = newdevice;
61371 + match->mode &= ~GR_DELETED;
61372 +
61373 + insert_acl_subj_label(match, role);
61374 + }
61375 +
61376 + return;
61377 +}
61378 +
61379 +static void
61380 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
61381 + const ino_t newinode, const dev_t newdevice)
61382 +{
61383 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
61384 + struct inodev_entry *match;
61385 +
61386 + match = inodev_set.i_hash[index];
61387 +
61388 + while (match && (match->nentry->inode != oldinode ||
61389 + match->nentry->device != olddevice || !match->nentry->deleted))
61390 + match = match->next;
61391 +
61392 + if (match && (match->nentry->inode == oldinode)
61393 + && (match->nentry->device == olddevice) &&
61394 + match->nentry->deleted) {
61395 + if (match->prev == NULL) {
61396 + inodev_set.i_hash[index] = match->next;
61397 + if (match->next != NULL)
61398 + match->next->prev = NULL;
61399 + } else {
61400 + match->prev->next = match->next;
61401 + if (match->next != NULL)
61402 + match->next->prev = match->prev;
61403 + }
61404 + match->prev = NULL;
61405 + match->next = NULL;
61406 + match->nentry->inode = newinode;
61407 + match->nentry->device = newdevice;
61408 + match->nentry->deleted = 0;
61409 +
61410 + insert_inodev_entry(match);
61411 + }
61412 +
61413 + return;
61414 +}
61415 +
61416 +static void
61417 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61418 +{
61419 + struct acl_subject_label *subj;
61420 + struct acl_role_label *role;
61421 + unsigned int x;
61422 +
61423 + FOR_EACH_ROLE_START(role)
61424 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61425 +
61426 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61427 + if ((subj->inode == ino) && (subj->device == dev)) {
61428 + subj->inode = ino;
61429 + subj->device = dev;
61430 + }
61431 + /* nested subjects aren't in the role's subj_hash table */
61432 + update_acl_obj_label(matchn->inode, matchn->device,
61433 + ino, dev, subj);
61434 + FOR_EACH_NESTED_SUBJECT_END(subj)
61435 + FOR_EACH_SUBJECT_START(role, subj, x)
61436 + update_acl_obj_label(matchn->inode, matchn->device,
61437 + ino, dev, subj);
61438 + FOR_EACH_SUBJECT_END(subj,x)
61439 + FOR_EACH_ROLE_END(role)
61440 +
61441 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61442 +
61443 + return;
61444 +}
61445 +
61446 +static void
61447 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61448 + const struct vfsmount *mnt)
61449 +{
61450 + ino_t ino = dentry->d_inode->i_ino;
61451 + dev_t dev = __get_dev(dentry);
61452 +
61453 + __do_handle_create(matchn, ino, dev);
61454 +
61455 + return;
61456 +}
61457 +
61458 +void
61459 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61460 +{
61461 + struct name_entry *matchn;
61462 +
61463 + if (unlikely(!(gr_status & GR_READY)))
61464 + return;
61465 +
61466 + preempt_disable();
61467 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61468 +
61469 + if (unlikely((unsigned long)matchn)) {
61470 + write_lock(&gr_inode_lock);
61471 + do_handle_create(matchn, dentry, mnt);
61472 + write_unlock(&gr_inode_lock);
61473 + }
61474 + preempt_enable();
61475 +
61476 + return;
61477 +}
61478 +
61479 +void
61480 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61481 +{
61482 + struct name_entry *matchn;
61483 +
61484 + if (unlikely(!(gr_status & GR_READY)))
61485 + return;
61486 +
61487 + preempt_disable();
61488 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61489 +
61490 + if (unlikely((unsigned long)matchn)) {
61491 + write_lock(&gr_inode_lock);
61492 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61493 + write_unlock(&gr_inode_lock);
61494 + }
61495 + preempt_enable();
61496 +
61497 + return;
61498 +}
61499 +
61500 +void
61501 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61502 + struct dentry *old_dentry,
61503 + struct dentry *new_dentry,
61504 + struct vfsmount *mnt, const __u8 replace)
61505 +{
61506 + struct name_entry *matchn;
61507 + struct inodev_entry *inodev;
61508 + struct inode *inode = new_dentry->d_inode;
61509 + ino_t old_ino = old_dentry->d_inode->i_ino;
61510 + dev_t old_dev = __get_dev(old_dentry);
61511 +
61512 + /* vfs_rename swaps the name and parent link for old_dentry and
61513 + new_dentry
61514 + at this point, old_dentry has the new name, parent link, and inode
61515 + for the renamed file
61516 + if a file is being replaced by a rename, new_dentry has the inode
61517 + and name for the replaced file
61518 + */
61519 +
61520 + if (unlikely(!(gr_status & GR_READY)))
61521 + return;
61522 +
61523 + preempt_disable();
61524 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61525 +
61526 + /* we wouldn't have to check d_inode if it weren't for
61527 + NFS silly-renaming
61528 + */
61529 +
61530 + write_lock(&gr_inode_lock);
61531 + if (unlikely(replace && inode)) {
61532 + ino_t new_ino = inode->i_ino;
61533 + dev_t new_dev = __get_dev(new_dentry);
61534 +
61535 + inodev = lookup_inodev_entry(new_ino, new_dev);
61536 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61537 + do_handle_delete(inodev, new_ino, new_dev);
61538 + }
61539 +
61540 + inodev = lookup_inodev_entry(old_ino, old_dev);
61541 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61542 + do_handle_delete(inodev, old_ino, old_dev);
61543 +
61544 + if (unlikely((unsigned long)matchn))
61545 + do_handle_create(matchn, old_dentry, mnt);
61546 +
61547 + write_unlock(&gr_inode_lock);
61548 + preempt_enable();
61549 +
61550 + return;
61551 +}
61552 +
61553 +static int
61554 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61555 + unsigned char **sum)
61556 +{
61557 + struct acl_role_label *r;
61558 + struct role_allowed_ip *ipp;
61559 + struct role_transition *trans;
61560 + unsigned int i;
61561 + int found = 0;
61562 + u32 curr_ip = current->signal->curr_ip;
61563 +
61564 + current->signal->saved_ip = curr_ip;
61565 +
61566 + /* check transition table */
61567 +
61568 + for (trans = current->role->transitions; trans; trans = trans->next) {
61569 + if (!strcmp(rolename, trans->rolename)) {
61570 + found = 1;
61571 + break;
61572 + }
61573 + }
61574 +
61575 + if (!found)
61576 + return 0;
61577 +
61578 + /* handle special roles that do not require authentication
61579 + and check ip */
61580 +
61581 + FOR_EACH_ROLE_START(r)
61582 + if (!strcmp(rolename, r->rolename) &&
61583 + (r->roletype & GR_ROLE_SPECIAL)) {
61584 + found = 0;
61585 + if (r->allowed_ips != NULL) {
61586 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61587 + if ((ntohl(curr_ip) & ipp->netmask) ==
61588 + (ntohl(ipp->addr) & ipp->netmask))
61589 + found = 1;
61590 + }
61591 + } else
61592 + found = 2;
61593 + if (!found)
61594 + return 0;
61595 +
61596 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61597 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61598 + *salt = NULL;
61599 + *sum = NULL;
61600 + return 1;
61601 + }
61602 + }
61603 + FOR_EACH_ROLE_END(r)
61604 +
61605 + for (i = 0; i < num_sprole_pws; i++) {
61606 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61607 + *salt = acl_special_roles[i]->salt;
61608 + *sum = acl_special_roles[i]->sum;
61609 + return 1;
61610 + }
61611 + }
61612 +
61613 + return 0;
61614 +}
61615 +
61616 +static void
61617 +assign_special_role(char *rolename)
61618 +{
61619 + struct acl_object_label *obj;
61620 + struct acl_role_label *r;
61621 + struct acl_role_label *assigned = NULL;
61622 + struct task_struct *tsk;
61623 + struct file *filp;
61624 +
61625 + FOR_EACH_ROLE_START(r)
61626 + if (!strcmp(rolename, r->rolename) &&
61627 + (r->roletype & GR_ROLE_SPECIAL)) {
61628 + assigned = r;
61629 + break;
61630 + }
61631 + FOR_EACH_ROLE_END(r)
61632 +
61633 + if (!assigned)
61634 + return;
61635 +
61636 + read_lock(&tasklist_lock);
61637 + read_lock(&grsec_exec_file_lock);
61638 +
61639 + tsk = current->real_parent;
61640 + if (tsk == NULL)
61641 + goto out_unlock;
61642 +
61643 + filp = tsk->exec_file;
61644 + if (filp == NULL)
61645 + goto out_unlock;
61646 +
61647 + tsk->is_writable = 0;
61648 +
61649 + tsk->acl_sp_role = 1;
61650 + tsk->acl_role_id = ++acl_sp_role_value;
61651 + tsk->role = assigned;
61652 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61653 +
61654 + /* ignore additional mmap checks for processes that are writable
61655 + by the default ACL */
61656 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61657 + if (unlikely(obj->mode & GR_WRITE))
61658 + tsk->is_writable = 1;
61659 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61660 + if (unlikely(obj->mode & GR_WRITE))
61661 + tsk->is_writable = 1;
61662 +
61663 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61664 + 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));
61665 +#endif
61666 +
61667 +out_unlock:
61668 + read_unlock(&grsec_exec_file_lock);
61669 + read_unlock(&tasklist_lock);
61670 + return;
61671 +}
61672 +
61673 +int gr_check_secure_terminal(struct task_struct *task)
61674 +{
61675 + struct task_struct *p, *p2, *p3;
61676 + struct files_struct *files;
61677 + struct fdtable *fdt;
61678 + struct file *our_file = NULL, *file;
61679 + int i;
61680 +
61681 + if (task->signal->tty == NULL)
61682 + return 1;
61683 +
61684 + files = get_files_struct(task);
61685 + if (files != NULL) {
61686 + rcu_read_lock();
61687 + fdt = files_fdtable(files);
61688 + for (i=0; i < fdt->max_fds; i++) {
61689 + file = fcheck_files(files, i);
61690 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61691 + get_file(file);
61692 + our_file = file;
61693 + }
61694 + }
61695 + rcu_read_unlock();
61696 + put_files_struct(files);
61697 + }
61698 +
61699 + if (our_file == NULL)
61700 + return 1;
61701 +
61702 + read_lock(&tasklist_lock);
61703 + do_each_thread(p2, p) {
61704 + files = get_files_struct(p);
61705 + if (files == NULL ||
61706 + (p->signal && p->signal->tty == task->signal->tty)) {
61707 + if (files != NULL)
61708 + put_files_struct(files);
61709 + continue;
61710 + }
61711 + rcu_read_lock();
61712 + fdt = files_fdtable(files);
61713 + for (i=0; i < fdt->max_fds; i++) {
61714 + file = fcheck_files(files, i);
61715 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61716 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61717 + p3 = task;
61718 + while (task_pid_nr(p3) > 0) {
61719 + if (p3 == p)
61720 + break;
61721 + p3 = p3->real_parent;
61722 + }
61723 + if (p3 == p)
61724 + break;
61725 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61726 + gr_handle_alertkill(p);
61727 + rcu_read_unlock();
61728 + put_files_struct(files);
61729 + read_unlock(&tasklist_lock);
61730 + fput(our_file);
61731 + return 0;
61732 + }
61733 + }
61734 + rcu_read_unlock();
61735 + put_files_struct(files);
61736 + } while_each_thread(p2, p);
61737 + read_unlock(&tasklist_lock);
61738 +
61739 + fput(our_file);
61740 + return 1;
61741 +}
61742 +
61743 +static int gr_rbac_disable(void *unused)
61744 +{
61745 + pax_open_kernel();
61746 + gr_status &= ~GR_READY;
61747 + pax_close_kernel();
61748 +
61749 + return 0;
61750 +}
61751 +
61752 +ssize_t
61753 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
61754 +{
61755 + struct gr_arg_wrapper uwrap;
61756 + unsigned char *sprole_salt = NULL;
61757 + unsigned char *sprole_sum = NULL;
61758 + int error = 0;
61759 + int error2 = 0;
61760 + size_t req_count;
61761 +
61762 + mutex_lock(&gr_dev_mutex);
61763 +
61764 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61765 + error = -EPERM;
61766 + goto out;
61767 + }
61768 +
61769 +#ifdef CONFIG_COMPAT
61770 + pax_open_kernel();
61771 + if (is_compat_task()) {
61772 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
61773 + copy_gr_arg = &copy_gr_arg_compat;
61774 + copy_acl_object_label = &copy_acl_object_label_compat;
61775 + copy_acl_subject_label = &copy_acl_subject_label_compat;
61776 + copy_acl_role_label = &copy_acl_role_label_compat;
61777 + copy_acl_ip_label = &copy_acl_ip_label_compat;
61778 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
61779 + copy_role_transition = &copy_role_transition_compat;
61780 + copy_sprole_pw = &copy_sprole_pw_compat;
61781 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
61782 + copy_pointer_from_array = &copy_pointer_from_array_compat;
61783 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
61784 + } else {
61785 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
61786 + copy_gr_arg = &copy_gr_arg_normal;
61787 + copy_acl_object_label = &copy_acl_object_label_normal;
61788 + copy_acl_subject_label = &copy_acl_subject_label_normal;
61789 + copy_acl_role_label = &copy_acl_role_label_normal;
61790 + copy_acl_ip_label = &copy_acl_ip_label_normal;
61791 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
61792 + copy_role_transition = &copy_role_transition_normal;
61793 + copy_sprole_pw = &copy_sprole_pw_normal;
61794 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
61795 + copy_pointer_from_array = &copy_pointer_from_array_normal;
61796 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
61797 + }
61798 + pax_close_kernel();
61799 +#endif
61800 +
61801 + req_count = get_gr_arg_wrapper_size();
61802 +
61803 + if (count != req_count) {
61804 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
61805 + error = -EINVAL;
61806 + goto out;
61807 + }
61808 +
61809 +
61810 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61811 + gr_auth_expires = 0;
61812 + gr_auth_attempts = 0;
61813 + }
61814 +
61815 + error = copy_gr_arg_wrapper(buf, &uwrap);
61816 + if (error)
61817 + goto out;
61818 +
61819 + error = copy_gr_arg(uwrap.arg, gr_usermode);
61820 + if (error)
61821 + goto out;
61822 +
61823 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61824 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61825 + time_after(gr_auth_expires, get_seconds())) {
61826 + error = -EBUSY;
61827 + goto out;
61828 + }
61829 +
61830 + /* if non-root trying to do anything other than use a special role,
61831 + do not attempt authentication, do not count towards authentication
61832 + locking
61833 + */
61834 +
61835 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61836 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61837 + gr_is_global_nonroot(current_uid())) {
61838 + error = -EPERM;
61839 + goto out;
61840 + }
61841 +
61842 + /* ensure pw and special role name are null terminated */
61843 +
61844 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61845 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61846 +
61847 + /* Okay.
61848 + * We have our enough of the argument structure..(we have yet
61849 + * to copy_from_user the tables themselves) . Copy the tables
61850 + * only if we need them, i.e. for loading operations. */
61851 +
61852 + switch (gr_usermode->mode) {
61853 + case GR_STATUS:
61854 + if (gr_status & GR_READY) {
61855 + error = 1;
61856 + if (!gr_check_secure_terminal(current))
61857 + error = 3;
61858 + } else
61859 + error = 2;
61860 + goto out;
61861 + case GR_SHUTDOWN:
61862 + if ((gr_status & GR_READY)
61863 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61864 + stop_machine(gr_rbac_disable, NULL, NULL);
61865 + free_variables();
61866 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61867 + memset(gr_system_salt, 0, GR_SALT_LEN);
61868 + memset(gr_system_sum, 0, GR_SHA_LEN);
61869 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61870 + } else if (gr_status & GR_READY) {
61871 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61872 + error = -EPERM;
61873 + } else {
61874 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61875 + error = -EAGAIN;
61876 + }
61877 + break;
61878 + case GR_ENABLE:
61879 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61880 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61881 + else {
61882 + if (gr_status & GR_READY)
61883 + error = -EAGAIN;
61884 + else
61885 + error = error2;
61886 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61887 + }
61888 + break;
61889 + case GR_RELOAD:
61890 + if (!(gr_status & GR_READY)) {
61891 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61892 + error = -EAGAIN;
61893 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61894 + stop_machine(gr_rbac_disable, NULL, NULL);
61895 + free_variables();
61896 + error2 = gracl_init(gr_usermode);
61897 + if (!error2)
61898 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61899 + else {
61900 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61901 + error = error2;
61902 + }
61903 + } else {
61904 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61905 + error = -EPERM;
61906 + }
61907 + break;
61908 + case GR_SEGVMOD:
61909 + if (unlikely(!(gr_status & GR_READY))) {
61910 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61911 + error = -EAGAIN;
61912 + break;
61913 + }
61914 +
61915 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61916 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61917 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61918 + struct acl_subject_label *segvacl;
61919 + segvacl =
61920 + lookup_acl_subj_label(gr_usermode->segv_inode,
61921 + gr_usermode->segv_device,
61922 + current->role);
61923 + if (segvacl) {
61924 + segvacl->crashes = 0;
61925 + segvacl->expires = 0;
61926 + }
61927 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61928 + gr_remove_uid(gr_usermode->segv_uid);
61929 + }
61930 + } else {
61931 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61932 + error = -EPERM;
61933 + }
61934 + break;
61935 + case GR_SPROLE:
61936 + case GR_SPROLEPAM:
61937 + if (unlikely(!(gr_status & GR_READY))) {
61938 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61939 + error = -EAGAIN;
61940 + break;
61941 + }
61942 +
61943 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61944 + current->role->expires = 0;
61945 + current->role->auth_attempts = 0;
61946 + }
61947 +
61948 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61949 + time_after(current->role->expires, get_seconds())) {
61950 + error = -EBUSY;
61951 + goto out;
61952 + }
61953 +
61954 + if (lookup_special_role_auth
61955 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61956 + && ((!sprole_salt && !sprole_sum)
61957 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61958 + char *p = "";
61959 + assign_special_role(gr_usermode->sp_role);
61960 + read_lock(&tasklist_lock);
61961 + if (current->real_parent)
61962 + p = current->real_parent->role->rolename;
61963 + read_unlock(&tasklist_lock);
61964 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61965 + p, acl_sp_role_value);
61966 + } else {
61967 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61968 + error = -EPERM;
61969 + if(!(current->role->auth_attempts++))
61970 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61971 +
61972 + goto out;
61973 + }
61974 + break;
61975 + case GR_UNSPROLE:
61976 + if (unlikely(!(gr_status & GR_READY))) {
61977 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61978 + error = -EAGAIN;
61979 + break;
61980 + }
61981 +
61982 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61983 + char *p = "";
61984 + int i = 0;
61985 +
61986 + read_lock(&tasklist_lock);
61987 + if (current->real_parent) {
61988 + p = current->real_parent->role->rolename;
61989 + i = current->real_parent->acl_role_id;
61990 + }
61991 + read_unlock(&tasklist_lock);
61992 +
61993 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61994 + gr_set_acls(1);
61995 + } else {
61996 + error = -EPERM;
61997 + goto out;
61998 + }
61999 + break;
62000 + default:
62001 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
62002 + error = -EINVAL;
62003 + break;
62004 + }
62005 +
62006 + if (error != -EPERM)
62007 + goto out;
62008 +
62009 + if(!(gr_auth_attempts++))
62010 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
62011 +
62012 + out:
62013 + mutex_unlock(&gr_dev_mutex);
62014 +
62015 + if (!error)
62016 + error = req_count;
62017 +
62018 + return error;
62019 +}
62020 +
62021 +/* must be called with
62022 + rcu_read_lock();
62023 + read_lock(&tasklist_lock);
62024 + read_lock(&grsec_exec_file_lock);
62025 +*/
62026 +int gr_apply_subject_to_task(struct task_struct *task)
62027 +{
62028 + struct acl_object_label *obj;
62029 + char *tmpname;
62030 + struct acl_subject_label *tmpsubj;
62031 + struct file *filp;
62032 + struct name_entry *nmatch;
62033 +
62034 + filp = task->exec_file;
62035 + if (filp == NULL)
62036 + return 0;
62037 +
62038 + /* the following is to apply the correct subject
62039 + on binaries running when the RBAC system
62040 + is enabled, when the binaries have been
62041 + replaced or deleted since their execution
62042 + -----
62043 + when the RBAC system starts, the inode/dev
62044 + from exec_file will be one the RBAC system
62045 + is unaware of. It only knows the inode/dev
62046 + of the present file on disk, or the absence
62047 + of it.
62048 + */
62049 + preempt_disable();
62050 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
62051 +
62052 + nmatch = lookup_name_entry(tmpname);
62053 + preempt_enable();
62054 + tmpsubj = NULL;
62055 + if (nmatch) {
62056 + if (nmatch->deleted)
62057 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
62058 + else
62059 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
62060 + if (tmpsubj != NULL)
62061 + task->acl = tmpsubj;
62062 + }
62063 + if (tmpsubj == NULL)
62064 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
62065 + task->role);
62066 + if (task->acl) {
62067 + task->is_writable = 0;
62068 + /* ignore additional mmap checks for processes that are writable
62069 + by the default ACL */
62070 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62071 + if (unlikely(obj->mode & GR_WRITE))
62072 + task->is_writable = 1;
62073 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
62074 + if (unlikely(obj->mode & GR_WRITE))
62075 + task->is_writable = 1;
62076 +
62077 + gr_set_proc_res(task);
62078 +
62079 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
62080 + 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);
62081 +#endif
62082 + } else {
62083 + return 1;
62084 + }
62085 +
62086 + return 0;
62087 +}
62088 +
62089 +int
62090 +gr_set_acls(const int type)
62091 +{
62092 + struct task_struct *task, *task2;
62093 + struct acl_role_label *role = current->role;
62094 + __u16 acl_role_id = current->acl_role_id;
62095 + const struct cred *cred;
62096 + int ret;
62097 +
62098 + rcu_read_lock();
62099 + read_lock(&tasklist_lock);
62100 + read_lock(&grsec_exec_file_lock);
62101 + do_each_thread(task2, task) {
62102 + /* check to see if we're called from the exit handler,
62103 + if so, only replace ACLs that have inherited the admin
62104 + ACL */
62105 +
62106 + if (type && (task->role != role ||
62107 + task->acl_role_id != acl_role_id))
62108 + continue;
62109 +
62110 + task->acl_role_id = 0;
62111 + task->acl_sp_role = 0;
62112 +
62113 + if (task->exec_file) {
62114 + cred = __task_cred(task);
62115 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
62116 + ret = gr_apply_subject_to_task(task);
62117 + if (ret) {
62118 + read_unlock(&grsec_exec_file_lock);
62119 + read_unlock(&tasklist_lock);
62120 + rcu_read_unlock();
62121 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
62122 + return ret;
62123 + }
62124 + } else {
62125 + // it's a kernel process
62126 + task->role = kernel_role;
62127 + task->acl = kernel_role->root_label;
62128 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
62129 + task->acl->mode &= ~GR_PROCFIND;
62130 +#endif
62131 + }
62132 + } while_each_thread(task2, task);
62133 + read_unlock(&grsec_exec_file_lock);
62134 + read_unlock(&tasklist_lock);
62135 + rcu_read_unlock();
62136 +
62137 + return 0;
62138 +}
62139 +
62140 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
62141 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
62142 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
62143 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
62144 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
62145 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
62146 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
62147 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
62148 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
62149 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
62150 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
62151 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
62152 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
62153 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
62154 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
62155 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
62156 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
62157 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
62158 +};
62159 +
62160 +void
62161 +gr_learn_resource(const struct task_struct *task,
62162 + const int res, const unsigned long wanted, const int gt)
62163 +{
62164 + struct acl_subject_label *acl;
62165 + const struct cred *cred;
62166 +
62167 + if (unlikely((gr_status & GR_READY) &&
62168 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
62169 + goto skip_reslog;
62170 +
62171 + gr_log_resource(task, res, wanted, gt);
62172 +skip_reslog:
62173 +
62174 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
62175 + return;
62176 +
62177 + acl = task->acl;
62178 +
62179 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
62180 + !(acl->resmask & (1U << (unsigned short) res))))
62181 + return;
62182 +
62183 + if (wanted >= acl->res[res].rlim_cur) {
62184 + unsigned long res_add;
62185 +
62186 + res_add = wanted + res_learn_bumps[res];
62187 +
62188 + acl->res[res].rlim_cur = res_add;
62189 +
62190 + if (wanted > acl->res[res].rlim_max)
62191 + acl->res[res].rlim_max = res_add;
62192 +
62193 + /* only log the subject filename, since resource logging is supported for
62194 + single-subject learning only */
62195 + rcu_read_lock();
62196 + cred = __task_cred(task);
62197 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62198 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
62199 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
62200 + "", (unsigned long) res, &task->signal->saved_ip);
62201 + rcu_read_unlock();
62202 + }
62203 +
62204 + return;
62205 +}
62206 +EXPORT_SYMBOL(gr_learn_resource);
62207 +#endif
62208 +
62209 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
62210 +void
62211 +pax_set_initial_flags(struct linux_binprm *bprm)
62212 +{
62213 + struct task_struct *task = current;
62214 + struct acl_subject_label *proc;
62215 + unsigned long flags;
62216 +
62217 + if (unlikely(!(gr_status & GR_READY)))
62218 + return;
62219 +
62220 + flags = pax_get_flags(task);
62221 +
62222 + proc = task->acl;
62223 +
62224 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
62225 + flags &= ~MF_PAX_PAGEEXEC;
62226 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
62227 + flags &= ~MF_PAX_SEGMEXEC;
62228 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
62229 + flags &= ~MF_PAX_RANDMMAP;
62230 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
62231 + flags &= ~MF_PAX_EMUTRAMP;
62232 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
62233 + flags &= ~MF_PAX_MPROTECT;
62234 +
62235 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
62236 + flags |= MF_PAX_PAGEEXEC;
62237 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
62238 + flags |= MF_PAX_SEGMEXEC;
62239 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
62240 + flags |= MF_PAX_RANDMMAP;
62241 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
62242 + flags |= MF_PAX_EMUTRAMP;
62243 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
62244 + flags |= MF_PAX_MPROTECT;
62245 +
62246 + pax_set_flags(task, flags);
62247 +
62248 + return;
62249 +}
62250 +#endif
62251 +
62252 +int
62253 +gr_handle_proc_ptrace(struct task_struct *task)
62254 +{
62255 + struct file *filp;
62256 + struct task_struct *tmp = task;
62257 + struct task_struct *curtemp = current;
62258 + __u32 retmode;
62259 +
62260 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
62261 + if (unlikely(!(gr_status & GR_READY)))
62262 + return 0;
62263 +#endif
62264 +
62265 + read_lock(&tasklist_lock);
62266 + read_lock(&grsec_exec_file_lock);
62267 + filp = task->exec_file;
62268 +
62269 + while (task_pid_nr(tmp) > 0) {
62270 + if (tmp == curtemp)
62271 + break;
62272 + tmp = tmp->real_parent;
62273 + }
62274 +
62275 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
62276 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
62277 + read_unlock(&grsec_exec_file_lock);
62278 + read_unlock(&tasklist_lock);
62279 + return 1;
62280 + }
62281 +
62282 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
62283 + if (!(gr_status & GR_READY)) {
62284 + read_unlock(&grsec_exec_file_lock);
62285 + read_unlock(&tasklist_lock);
62286 + return 0;
62287 + }
62288 +#endif
62289 +
62290 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
62291 + read_unlock(&grsec_exec_file_lock);
62292 + read_unlock(&tasklist_lock);
62293 +
62294 + if (retmode & GR_NOPTRACE)
62295 + return 1;
62296 +
62297 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
62298 + && (current->acl != task->acl || (current->acl != current->role->root_label
62299 + && task_pid_nr(current) != task_pid_nr(task))))
62300 + return 1;
62301 +
62302 + return 0;
62303 +}
62304 +
62305 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
62306 +{
62307 + if (unlikely(!(gr_status & GR_READY)))
62308 + return;
62309 +
62310 + if (!(current->role->roletype & GR_ROLE_GOD))
62311 + return;
62312 +
62313 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
62314 + p->role->rolename, gr_task_roletype_to_char(p),
62315 + p->acl->filename);
62316 +}
62317 +
62318 +int
62319 +gr_handle_ptrace(struct task_struct *task, const long request)
62320 +{
62321 + struct task_struct *tmp = task;
62322 + struct task_struct *curtemp = current;
62323 + __u32 retmode;
62324 +
62325 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
62326 + if (unlikely(!(gr_status & GR_READY)))
62327 + return 0;
62328 +#endif
62329 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
62330 + read_lock(&tasklist_lock);
62331 + while (task_pid_nr(tmp) > 0) {
62332 + if (tmp == curtemp)
62333 + break;
62334 + tmp = tmp->real_parent;
62335 + }
62336 +
62337 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
62338 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
62339 + read_unlock(&tasklist_lock);
62340 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62341 + return 1;
62342 + }
62343 + read_unlock(&tasklist_lock);
62344 + }
62345 +
62346 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
62347 + if (!(gr_status & GR_READY))
62348 + return 0;
62349 +#endif
62350 +
62351 + read_lock(&grsec_exec_file_lock);
62352 + if (unlikely(!task->exec_file)) {
62353 + read_unlock(&grsec_exec_file_lock);
62354 + return 0;
62355 + }
62356 +
62357 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
62358 + read_unlock(&grsec_exec_file_lock);
62359 +
62360 + if (retmode & GR_NOPTRACE) {
62361 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62362 + return 1;
62363 + }
62364 +
62365 + if (retmode & GR_PTRACERD) {
62366 + switch (request) {
62367 + case PTRACE_SEIZE:
62368 + case PTRACE_POKETEXT:
62369 + case PTRACE_POKEDATA:
62370 + case PTRACE_POKEUSR:
62371 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
62372 + case PTRACE_SETREGS:
62373 + case PTRACE_SETFPREGS:
62374 +#endif
62375 +#ifdef CONFIG_X86
62376 + case PTRACE_SETFPXREGS:
62377 +#endif
62378 +#ifdef CONFIG_ALTIVEC
62379 + case PTRACE_SETVRREGS:
62380 +#endif
62381 + return 1;
62382 + default:
62383 + return 0;
62384 + }
62385 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
62386 + !(current->role->roletype & GR_ROLE_GOD) &&
62387 + (current->acl != task->acl)) {
62388 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62389 + return 1;
62390 + }
62391 +
62392 + return 0;
62393 +}
62394 +
62395 +static int is_writable_mmap(const struct file *filp)
62396 +{
62397 + struct task_struct *task = current;
62398 + struct acl_object_label *obj, *obj2;
62399 +
62400 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
62401 + !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))) {
62402 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62403 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
62404 + task->role->root_label);
62405 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
62406 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
62407 + return 1;
62408 + }
62409 + }
62410 + return 0;
62411 +}
62412 +
62413 +int
62414 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
62415 +{
62416 + __u32 mode;
62417 +
62418 + if (unlikely(!file || !(prot & PROT_EXEC)))
62419 + return 1;
62420 +
62421 + if (is_writable_mmap(file))
62422 + return 0;
62423 +
62424 + mode =
62425 + gr_search_file(file->f_path.dentry,
62426 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62427 + file->f_path.mnt);
62428 +
62429 + if (!gr_tpe_allow(file))
62430 + return 0;
62431 +
62432 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62433 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62434 + return 0;
62435 + } else if (unlikely(!(mode & GR_EXEC))) {
62436 + return 0;
62437 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62438 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62439 + return 1;
62440 + }
62441 +
62442 + return 1;
62443 +}
62444 +
62445 +int
62446 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62447 +{
62448 + __u32 mode;
62449 +
62450 + if (unlikely(!file || !(prot & PROT_EXEC)))
62451 + return 1;
62452 +
62453 + if (is_writable_mmap(file))
62454 + return 0;
62455 +
62456 + mode =
62457 + gr_search_file(file->f_path.dentry,
62458 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62459 + file->f_path.mnt);
62460 +
62461 + if (!gr_tpe_allow(file))
62462 + return 0;
62463 +
62464 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62465 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62466 + return 0;
62467 + } else if (unlikely(!(mode & GR_EXEC))) {
62468 + return 0;
62469 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62470 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62471 + return 1;
62472 + }
62473 +
62474 + return 1;
62475 +}
62476 +
62477 +void
62478 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62479 +{
62480 + unsigned long runtime;
62481 + unsigned long cputime;
62482 + unsigned int wday, cday;
62483 + __u8 whr, chr;
62484 + __u8 wmin, cmin;
62485 + __u8 wsec, csec;
62486 + struct timespec timeval;
62487 +
62488 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62489 + !(task->acl->mode & GR_PROCACCT)))
62490 + return;
62491 +
62492 + do_posix_clock_monotonic_gettime(&timeval);
62493 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62494 + wday = runtime / (3600 * 24);
62495 + runtime -= wday * (3600 * 24);
62496 + whr = runtime / 3600;
62497 + runtime -= whr * 3600;
62498 + wmin = runtime / 60;
62499 + runtime -= wmin * 60;
62500 + wsec = runtime;
62501 +
62502 + cputime = (task->utime + task->stime) / HZ;
62503 + cday = cputime / (3600 * 24);
62504 + cputime -= cday * (3600 * 24);
62505 + chr = cputime / 3600;
62506 + cputime -= chr * 3600;
62507 + cmin = cputime / 60;
62508 + cputime -= cmin * 60;
62509 + csec = cputime;
62510 +
62511 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62512 +
62513 + return;
62514 +}
62515 +
62516 +void gr_set_kernel_label(struct task_struct *task)
62517 +{
62518 + if (gr_status & GR_READY) {
62519 + task->role = kernel_role;
62520 + task->acl = kernel_role->root_label;
62521 + }
62522 + return;
62523 +}
62524 +
62525 +#ifdef CONFIG_TASKSTATS
62526 +int gr_is_taskstats_denied(int pid)
62527 +{
62528 + struct task_struct *task;
62529 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62530 + const struct cred *cred;
62531 +#endif
62532 + int ret = 0;
62533 +
62534 + /* restrict taskstats viewing to un-chrooted root users
62535 + who have the 'view' subject flag if the RBAC system is enabled
62536 + */
62537 +
62538 + rcu_read_lock();
62539 + read_lock(&tasklist_lock);
62540 + task = find_task_by_vpid(pid);
62541 + if (task) {
62542 +#ifdef CONFIG_GRKERNSEC_CHROOT
62543 + if (proc_is_chrooted(task))
62544 + ret = -EACCES;
62545 +#endif
62546 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62547 + cred = __task_cred(task);
62548 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62549 + if (gr_is_global_nonroot(cred->uid))
62550 + ret = -EACCES;
62551 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62552 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62553 + ret = -EACCES;
62554 +#endif
62555 +#endif
62556 + if (gr_status & GR_READY) {
62557 + if (!(task->acl->mode & GR_VIEW))
62558 + ret = -EACCES;
62559 + }
62560 + } else
62561 + ret = -ENOENT;
62562 +
62563 + read_unlock(&tasklist_lock);
62564 + rcu_read_unlock();
62565 +
62566 + return ret;
62567 +}
62568 +#endif
62569 +
62570 +/* AUXV entries are filled via a descendant of search_binary_handler
62571 + after we've already applied the subject for the target
62572 +*/
62573 +int gr_acl_enable_at_secure(void)
62574 +{
62575 + if (unlikely(!(gr_status & GR_READY)))
62576 + return 0;
62577 +
62578 + if (current->acl->mode & GR_ATSECURE)
62579 + return 1;
62580 +
62581 + return 0;
62582 +}
62583 +
62584 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62585 +{
62586 + struct task_struct *task = current;
62587 + struct dentry *dentry = file->f_path.dentry;
62588 + struct vfsmount *mnt = file->f_path.mnt;
62589 + struct acl_object_label *obj, *tmp;
62590 + struct acl_subject_label *subj;
62591 + unsigned int bufsize;
62592 + int is_not_root;
62593 + char *path;
62594 + dev_t dev = __get_dev(dentry);
62595 +
62596 + if (unlikely(!(gr_status & GR_READY)))
62597 + return 1;
62598 +
62599 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62600 + return 1;
62601 +
62602 + /* ignore Eric Biederman */
62603 + if (IS_PRIVATE(dentry->d_inode))
62604 + return 1;
62605 +
62606 + subj = task->acl;
62607 + read_lock(&gr_inode_lock);
62608 + do {
62609 + obj = lookup_acl_obj_label(ino, dev, subj);
62610 + if (obj != NULL) {
62611 + read_unlock(&gr_inode_lock);
62612 + return (obj->mode & GR_FIND) ? 1 : 0;
62613 + }
62614 + } while ((subj = subj->parent_subject));
62615 + read_unlock(&gr_inode_lock);
62616 +
62617 + /* this is purely an optimization since we're looking for an object
62618 + for the directory we're doing a readdir on
62619 + if it's possible for any globbed object to match the entry we're
62620 + filling into the directory, then the object we find here will be
62621 + an anchor point with attached globbed objects
62622 + */
62623 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62624 + if (obj->globbed == NULL)
62625 + return (obj->mode & GR_FIND) ? 1 : 0;
62626 +
62627 + is_not_root = ((obj->filename[0] == '/') &&
62628 + (obj->filename[1] == '\0')) ? 0 : 1;
62629 + bufsize = PAGE_SIZE - namelen - is_not_root;
62630 +
62631 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62632 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62633 + return 1;
62634 +
62635 + preempt_disable();
62636 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62637 + bufsize);
62638 +
62639 + bufsize = strlen(path);
62640 +
62641 + /* if base is "/", don't append an additional slash */
62642 + if (is_not_root)
62643 + *(path + bufsize) = '/';
62644 + memcpy(path + bufsize + is_not_root, name, namelen);
62645 + *(path + bufsize + namelen + is_not_root) = '\0';
62646 +
62647 + tmp = obj->globbed;
62648 + while (tmp) {
62649 + if (!glob_match(tmp->filename, path)) {
62650 + preempt_enable();
62651 + return (tmp->mode & GR_FIND) ? 1 : 0;
62652 + }
62653 + tmp = tmp->next;
62654 + }
62655 + preempt_enable();
62656 + return (obj->mode & GR_FIND) ? 1 : 0;
62657 +}
62658 +
62659 +void gr_put_exec_file(struct task_struct *task)
62660 +{
62661 + struct file *filp;
62662 +
62663 + write_lock(&grsec_exec_file_lock);
62664 + filp = task->exec_file;
62665 + task->exec_file = NULL;
62666 + write_unlock(&grsec_exec_file_lock);
62667 +
62668 + if (filp)
62669 + fput(filp);
62670 +
62671 + return;
62672 +}
62673 +
62674 +
62675 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62676 +EXPORT_SYMBOL(gr_acl_is_enabled);
62677 +#endif
62678 +EXPORT_SYMBOL(gr_set_kernel_label);
62679 +#ifdef CONFIG_SECURITY
62680 +EXPORT_SYMBOL(gr_check_user_change);
62681 +EXPORT_SYMBOL(gr_check_group_change);
62682 +#endif
62683 +
62684 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62685 new file mode 100644
62686 index 0000000..34fefda
62687 --- /dev/null
62688 +++ b/grsecurity/gracl_alloc.c
62689 @@ -0,0 +1,105 @@
62690 +#include <linux/kernel.h>
62691 +#include <linux/mm.h>
62692 +#include <linux/slab.h>
62693 +#include <linux/vmalloc.h>
62694 +#include <linux/gracl.h>
62695 +#include <linux/grsecurity.h>
62696 +
62697 +static unsigned long alloc_stack_next = 1;
62698 +static unsigned long alloc_stack_size = 1;
62699 +static void **alloc_stack;
62700 +
62701 +static __inline__ int
62702 +alloc_pop(void)
62703 +{
62704 + if (alloc_stack_next == 1)
62705 + return 0;
62706 +
62707 + kfree(alloc_stack[alloc_stack_next - 2]);
62708 +
62709 + alloc_stack_next--;
62710 +
62711 + return 1;
62712 +}
62713 +
62714 +static __inline__ int
62715 +alloc_push(void *buf)
62716 +{
62717 + if (alloc_stack_next >= alloc_stack_size)
62718 + return 1;
62719 +
62720 + alloc_stack[alloc_stack_next - 1] = buf;
62721 +
62722 + alloc_stack_next++;
62723 +
62724 + return 0;
62725 +}
62726 +
62727 +void *
62728 +acl_alloc(unsigned long len)
62729 +{
62730 + void *ret = NULL;
62731 +
62732 + if (!len || len > PAGE_SIZE)
62733 + goto out;
62734 +
62735 + ret = kmalloc(len, GFP_KERNEL);
62736 +
62737 + if (ret) {
62738 + if (alloc_push(ret)) {
62739 + kfree(ret);
62740 + ret = NULL;
62741 + }
62742 + }
62743 +
62744 +out:
62745 + return ret;
62746 +}
62747 +
62748 +void *
62749 +acl_alloc_num(unsigned long num, unsigned long len)
62750 +{
62751 + if (!len || (num > (PAGE_SIZE / len)))
62752 + return NULL;
62753 +
62754 + return acl_alloc(num * len);
62755 +}
62756 +
62757 +void
62758 +acl_free_all(void)
62759 +{
62760 + if (gr_acl_is_enabled() || !alloc_stack)
62761 + return;
62762 +
62763 + while (alloc_pop()) ;
62764 +
62765 + if (alloc_stack) {
62766 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62767 + kfree(alloc_stack);
62768 + else
62769 + vfree(alloc_stack);
62770 + }
62771 +
62772 + alloc_stack = NULL;
62773 + alloc_stack_size = 1;
62774 + alloc_stack_next = 1;
62775 +
62776 + return;
62777 +}
62778 +
62779 +int
62780 +acl_alloc_stack_init(unsigned long size)
62781 +{
62782 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62783 + alloc_stack =
62784 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62785 + else
62786 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62787 +
62788 + alloc_stack_size = size;
62789 +
62790 + if (!alloc_stack)
62791 + return 0;
62792 + else
62793 + return 1;
62794 +}
62795 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62796 new file mode 100644
62797 index 0000000..bdd51ea
62798 --- /dev/null
62799 +++ b/grsecurity/gracl_cap.c
62800 @@ -0,0 +1,110 @@
62801 +#include <linux/kernel.h>
62802 +#include <linux/module.h>
62803 +#include <linux/sched.h>
62804 +#include <linux/gracl.h>
62805 +#include <linux/grsecurity.h>
62806 +#include <linux/grinternal.h>
62807 +
62808 +extern const char *captab_log[];
62809 +extern int captab_log_entries;
62810 +
62811 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62812 +{
62813 + struct acl_subject_label *curracl;
62814 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62815 + kernel_cap_t cap_audit = __cap_empty_set;
62816 +
62817 + if (!gr_acl_is_enabled())
62818 + return 1;
62819 +
62820 + curracl = task->acl;
62821 +
62822 + cap_drop = curracl->cap_lower;
62823 + cap_mask = curracl->cap_mask;
62824 + cap_audit = curracl->cap_invert_audit;
62825 +
62826 + while ((curracl = curracl->parent_subject)) {
62827 + /* if the cap isn't specified in the current computed mask but is specified in the
62828 + current level subject, and is lowered in the current level subject, then add
62829 + it to the set of dropped capabilities
62830 + otherwise, add the current level subject's mask to the current computed mask
62831 + */
62832 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62833 + cap_raise(cap_mask, cap);
62834 + if (cap_raised(curracl->cap_lower, cap))
62835 + cap_raise(cap_drop, cap);
62836 + if (cap_raised(curracl->cap_invert_audit, cap))
62837 + cap_raise(cap_audit, cap);
62838 + }
62839 + }
62840 +
62841 + if (!cap_raised(cap_drop, cap)) {
62842 + if (cap_raised(cap_audit, cap))
62843 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62844 + return 1;
62845 + }
62846 +
62847 + curracl = task->acl;
62848 +
62849 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62850 + && cap_raised(cred->cap_effective, cap)) {
62851 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62852 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62853 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62854 + gr_to_filename(task->exec_file->f_path.dentry,
62855 + task->exec_file->f_path.mnt) : curracl->filename,
62856 + curracl->filename, 0UL,
62857 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62858 + return 1;
62859 + }
62860 +
62861 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62862 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62863 +
62864 + return 0;
62865 +}
62866 +
62867 +int
62868 +gr_acl_is_capable(const int cap)
62869 +{
62870 + return gr_task_acl_is_capable(current, current_cred(), cap);
62871 +}
62872 +
62873 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62874 +{
62875 + struct acl_subject_label *curracl;
62876 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62877 +
62878 + if (!gr_acl_is_enabled())
62879 + return 1;
62880 +
62881 + curracl = task->acl;
62882 +
62883 + cap_drop = curracl->cap_lower;
62884 + cap_mask = curracl->cap_mask;
62885 +
62886 + while ((curracl = curracl->parent_subject)) {
62887 + /* if the cap isn't specified in the current computed mask but is specified in the
62888 + current level subject, and is lowered in the current level subject, then add
62889 + it to the set of dropped capabilities
62890 + otherwise, add the current level subject's mask to the current computed mask
62891 + */
62892 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62893 + cap_raise(cap_mask, cap);
62894 + if (cap_raised(curracl->cap_lower, cap))
62895 + cap_raise(cap_drop, cap);
62896 + }
62897 + }
62898 +
62899 + if (!cap_raised(cap_drop, cap))
62900 + return 1;
62901 +
62902 + return 0;
62903 +}
62904 +
62905 +int
62906 +gr_acl_is_capable_nolog(const int cap)
62907 +{
62908 + return gr_task_acl_is_capable_nolog(current, cap);
62909 +}
62910 +
62911 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
62912 new file mode 100644
62913 index 0000000..a43dd06
62914 --- /dev/null
62915 +++ b/grsecurity/gracl_compat.c
62916 @@ -0,0 +1,269 @@
62917 +#include <linux/kernel.h>
62918 +#include <linux/gracl.h>
62919 +#include <linux/compat.h>
62920 +#include <linux/gracl_compat.h>
62921 +
62922 +#include <asm/uaccess.h>
62923 +
62924 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
62925 +{
62926 + struct gr_arg_wrapper_compat uwrapcompat;
62927 +
62928 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
62929 + return -EFAULT;
62930 +
62931 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
62932 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
62933 + return -EINVAL;
62934 +
62935 + uwrap->arg = compat_ptr(uwrapcompat.arg);
62936 + uwrap->version = uwrapcompat.version;
62937 + uwrap->size = sizeof(struct gr_arg);
62938 +
62939 + return 0;
62940 +}
62941 +
62942 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
62943 +{
62944 + struct gr_arg_compat argcompat;
62945 +
62946 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
62947 + return -EFAULT;
62948 +
62949 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
62950 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
62951 + arg->role_db.num_roles = argcompat.role_db.num_roles;
62952 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
62953 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
62954 + arg->role_db.num_objects = argcompat.role_db.num_objects;
62955 +
62956 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
62957 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
62958 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
62959 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
62960 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
62961 + arg->segv_device = argcompat.segv_device;
62962 + arg->segv_inode = argcompat.segv_inode;
62963 + arg->segv_uid = argcompat.segv_uid;
62964 + arg->num_sprole_pws = argcompat.num_sprole_pws;
62965 + arg->mode = argcompat.mode;
62966 +
62967 + return 0;
62968 +}
62969 +
62970 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
62971 +{
62972 + struct acl_object_label_compat objcompat;
62973 +
62974 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
62975 + return -EFAULT;
62976 +
62977 + obj->filename = compat_ptr(objcompat.filename);
62978 + obj->inode = objcompat.inode;
62979 + obj->device = objcompat.device;
62980 + obj->mode = objcompat.mode;
62981 +
62982 + obj->nested = compat_ptr(objcompat.nested);
62983 + obj->globbed = compat_ptr(objcompat.globbed);
62984 +
62985 + obj->prev = compat_ptr(objcompat.prev);
62986 + obj->next = compat_ptr(objcompat.next);
62987 +
62988 + return 0;
62989 +}
62990 +
62991 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62992 +{
62993 + unsigned int i;
62994 + struct acl_subject_label_compat subjcompat;
62995 +
62996 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
62997 + return -EFAULT;
62998 +
62999 + subj->filename = compat_ptr(subjcompat.filename);
63000 + subj->inode = subjcompat.inode;
63001 + subj->device = subjcompat.device;
63002 + subj->mode = subjcompat.mode;
63003 + subj->cap_mask = subjcompat.cap_mask;
63004 + subj->cap_lower = subjcompat.cap_lower;
63005 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
63006 +
63007 + for (i = 0; i < GR_NLIMITS; i++) {
63008 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
63009 + subj->res[i].rlim_cur = RLIM_INFINITY;
63010 + else
63011 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
63012 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
63013 + subj->res[i].rlim_max = RLIM_INFINITY;
63014 + else
63015 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
63016 + }
63017 + subj->resmask = subjcompat.resmask;
63018 +
63019 + subj->user_trans_type = subjcompat.user_trans_type;
63020 + subj->group_trans_type = subjcompat.group_trans_type;
63021 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
63022 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
63023 + subj->user_trans_num = subjcompat.user_trans_num;
63024 + subj->group_trans_num = subjcompat.group_trans_num;
63025 +
63026 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
63027 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
63028 + subj->ip_type = subjcompat.ip_type;
63029 + subj->ips = compat_ptr(subjcompat.ips);
63030 + subj->ip_num = subjcompat.ip_num;
63031 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
63032 +
63033 + subj->crashes = subjcompat.crashes;
63034 + subj->expires = subjcompat.expires;
63035 +
63036 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
63037 + subj->hash = compat_ptr(subjcompat.hash);
63038 + subj->prev = compat_ptr(subjcompat.prev);
63039 + subj->next = compat_ptr(subjcompat.next);
63040 +
63041 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
63042 + subj->obj_hash_size = subjcompat.obj_hash_size;
63043 + subj->pax_flags = subjcompat.pax_flags;
63044 +
63045 + return 0;
63046 +}
63047 +
63048 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
63049 +{
63050 + struct acl_role_label_compat rolecompat;
63051 +
63052 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
63053 + return -EFAULT;
63054 +
63055 + role->rolename = compat_ptr(rolecompat.rolename);
63056 + role->uidgid = rolecompat.uidgid;
63057 + role->roletype = rolecompat.roletype;
63058 +
63059 + role->auth_attempts = rolecompat.auth_attempts;
63060 + role->expires = rolecompat.expires;
63061 +
63062 + role->root_label = compat_ptr(rolecompat.root_label);
63063 + role->hash = compat_ptr(rolecompat.hash);
63064 +
63065 + role->prev = compat_ptr(rolecompat.prev);
63066 + role->next = compat_ptr(rolecompat.next);
63067 +
63068 + role->transitions = compat_ptr(rolecompat.transitions);
63069 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
63070 + role->domain_children = compat_ptr(rolecompat.domain_children);
63071 + role->domain_child_num = rolecompat.domain_child_num;
63072 +
63073 + role->umask = rolecompat.umask;
63074 +
63075 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
63076 + role->subj_hash_size = rolecompat.subj_hash_size;
63077 +
63078 + return 0;
63079 +}
63080 +
63081 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
63082 +{
63083 + struct role_allowed_ip_compat roleip_compat;
63084 +
63085 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
63086 + return -EFAULT;
63087 +
63088 + roleip->addr = roleip_compat.addr;
63089 + roleip->netmask = roleip_compat.netmask;
63090 +
63091 + roleip->prev = compat_ptr(roleip_compat.prev);
63092 + roleip->next = compat_ptr(roleip_compat.next);
63093 +
63094 + return 0;
63095 +}
63096 +
63097 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
63098 +{
63099 + struct role_transition_compat trans_compat;
63100 +
63101 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
63102 + return -EFAULT;
63103 +
63104 + trans->rolename = compat_ptr(trans_compat.rolename);
63105 +
63106 + trans->prev = compat_ptr(trans_compat.prev);
63107 + trans->next = compat_ptr(trans_compat.next);
63108 +
63109 + return 0;
63110 +
63111 +}
63112 +
63113 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
63114 +{
63115 + struct gr_hash_struct_compat hash_compat;
63116 +
63117 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
63118 + return -EFAULT;
63119 +
63120 + hash->table = compat_ptr(hash_compat.table);
63121 + hash->nametable = compat_ptr(hash_compat.nametable);
63122 + hash->first = compat_ptr(hash_compat.first);
63123 +
63124 + hash->table_size = hash_compat.table_size;
63125 + hash->used_size = hash_compat.used_size;
63126 +
63127 + hash->type = hash_compat.type;
63128 +
63129 + return 0;
63130 +}
63131 +
63132 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
63133 +{
63134 + compat_uptr_t ptrcompat;
63135 +
63136 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
63137 + return -EFAULT;
63138 +
63139 + *(void **)ptr = compat_ptr(ptrcompat);
63140 +
63141 + return 0;
63142 +}
63143 +
63144 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
63145 +{
63146 + struct acl_ip_label_compat ip_compat;
63147 +
63148 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
63149 + return -EFAULT;
63150 +
63151 + ip->iface = compat_ptr(ip_compat.iface);
63152 + ip->addr = ip_compat.addr;
63153 + ip->netmask = ip_compat.netmask;
63154 + ip->low = ip_compat.low;
63155 + ip->high = ip_compat.high;
63156 + ip->mode = ip_compat.mode;
63157 + ip->type = ip_compat.type;
63158 +
63159 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
63160 +
63161 + ip->prev = compat_ptr(ip_compat.prev);
63162 + ip->next = compat_ptr(ip_compat.next);
63163 +
63164 + return 0;
63165 +}
63166 +
63167 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
63168 +{
63169 + struct sprole_pw_compat pw_compat;
63170 +
63171 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
63172 + return -EFAULT;
63173 +
63174 + pw->rolename = compat_ptr(pw_compat.rolename);
63175 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
63176 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
63177 +
63178 + return 0;
63179 +}
63180 +
63181 +size_t get_gr_arg_wrapper_size_compat(void)
63182 +{
63183 + return sizeof(struct gr_arg_wrapper_compat);
63184 +}
63185 +
63186 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
63187 new file mode 100644
63188 index 0000000..a340c17
63189 --- /dev/null
63190 +++ b/grsecurity/gracl_fs.c
63191 @@ -0,0 +1,431 @@
63192 +#include <linux/kernel.h>
63193 +#include <linux/sched.h>
63194 +#include <linux/types.h>
63195 +#include <linux/fs.h>
63196 +#include <linux/file.h>
63197 +#include <linux/stat.h>
63198 +#include <linux/grsecurity.h>
63199 +#include <linux/grinternal.h>
63200 +#include <linux/gracl.h>
63201 +
63202 +umode_t
63203 +gr_acl_umask(void)
63204 +{
63205 + if (unlikely(!gr_acl_is_enabled()))
63206 + return 0;
63207 +
63208 + return current->role->umask;
63209 +}
63210 +
63211 +__u32
63212 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63213 + const struct vfsmount * mnt)
63214 +{
63215 + __u32 mode;
63216 +
63217 + if (unlikely(!dentry->d_inode))
63218 + return GR_FIND;
63219 +
63220 + mode =
63221 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
63222 +
63223 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
63224 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
63225 + return mode;
63226 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
63227 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
63228 + return 0;
63229 + } else if (unlikely(!(mode & GR_FIND)))
63230 + return 0;
63231 +
63232 + return GR_FIND;
63233 +}
63234 +
63235 +__u32
63236 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63237 + int acc_mode)
63238 +{
63239 + __u32 reqmode = GR_FIND;
63240 + __u32 mode;
63241 +
63242 + if (unlikely(!dentry->d_inode))
63243 + return reqmode;
63244 +
63245 + if (acc_mode & MAY_APPEND)
63246 + reqmode |= GR_APPEND;
63247 + else if (acc_mode & MAY_WRITE)
63248 + reqmode |= GR_WRITE;
63249 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
63250 + reqmode |= GR_READ;
63251 +
63252 + mode =
63253 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
63254 + mnt);
63255 +
63256 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63257 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
63258 + reqmode & GR_READ ? " reading" : "",
63259 + reqmode & GR_WRITE ? " writing" : reqmode &
63260 + GR_APPEND ? " appending" : "");
63261 + return reqmode;
63262 + } else
63263 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63264 + {
63265 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
63266 + reqmode & GR_READ ? " reading" : "",
63267 + reqmode & GR_WRITE ? " writing" : reqmode &
63268 + GR_APPEND ? " appending" : "");
63269 + return 0;
63270 + } else if (unlikely((mode & reqmode) != reqmode))
63271 + return 0;
63272 +
63273 + return reqmode;
63274 +}
63275 +
63276 +__u32
63277 +gr_acl_handle_creat(const struct dentry * dentry,
63278 + const struct dentry * p_dentry,
63279 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
63280 + const int imode)
63281 +{
63282 + __u32 reqmode = GR_WRITE | GR_CREATE;
63283 + __u32 mode;
63284 +
63285 + if (acc_mode & MAY_APPEND)
63286 + reqmode |= GR_APPEND;
63287 + // if a directory was required or the directory already exists, then
63288 + // don't count this open as a read
63289 + if ((acc_mode & MAY_READ) &&
63290 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
63291 + reqmode |= GR_READ;
63292 + if ((open_flags & O_CREAT) &&
63293 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
63294 + reqmode |= GR_SETID;
63295 +
63296 + mode =
63297 + gr_check_create(dentry, p_dentry, p_mnt,
63298 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
63299 +
63300 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63301 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
63302 + reqmode & GR_READ ? " reading" : "",
63303 + reqmode & GR_WRITE ? " writing" : reqmode &
63304 + GR_APPEND ? " appending" : "");
63305 + return reqmode;
63306 + } else
63307 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63308 + {
63309 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
63310 + reqmode & GR_READ ? " reading" : "",
63311 + reqmode & GR_WRITE ? " writing" : reqmode &
63312 + GR_APPEND ? " appending" : "");
63313 + return 0;
63314 + } else if (unlikely((mode & reqmode) != reqmode))
63315 + return 0;
63316 +
63317 + return reqmode;
63318 +}
63319 +
63320 +__u32
63321 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
63322 + const int fmode)
63323 +{
63324 + __u32 mode, reqmode = GR_FIND;
63325 +
63326 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
63327 + reqmode |= GR_EXEC;
63328 + if (fmode & S_IWOTH)
63329 + reqmode |= GR_WRITE;
63330 + if (fmode & S_IROTH)
63331 + reqmode |= GR_READ;
63332 +
63333 + mode =
63334 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
63335 + mnt);
63336 +
63337 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63338 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
63339 + reqmode & GR_READ ? " reading" : "",
63340 + reqmode & GR_WRITE ? " writing" : "",
63341 + reqmode & GR_EXEC ? " executing" : "");
63342 + return reqmode;
63343 + } else
63344 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63345 + {
63346 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
63347 + reqmode & GR_READ ? " reading" : "",
63348 + reqmode & GR_WRITE ? " writing" : "",
63349 + reqmode & GR_EXEC ? " executing" : "");
63350 + return 0;
63351 + } else if (unlikely((mode & reqmode) != reqmode))
63352 + return 0;
63353 +
63354 + return reqmode;
63355 +}
63356 +
63357 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
63358 +{
63359 + __u32 mode;
63360 +
63361 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
63362 +
63363 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
63364 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
63365 + return mode;
63366 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
63367 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
63368 + return 0;
63369 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
63370 + return 0;
63371 +
63372 + return (reqmode);
63373 +}
63374 +
63375 +__u32
63376 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63377 +{
63378 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
63379 +}
63380 +
63381 +__u32
63382 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
63383 +{
63384 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
63385 +}
63386 +
63387 +__u32
63388 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
63389 +{
63390 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
63391 +}
63392 +
63393 +__u32
63394 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
63395 +{
63396 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
63397 +}
63398 +
63399 +__u32
63400 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
63401 + umode_t *modeptr)
63402 +{
63403 + umode_t mode;
63404 +
63405 + *modeptr &= ~gr_acl_umask();
63406 + mode = *modeptr;
63407 +
63408 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
63409 + return 1;
63410 +
63411 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
63412 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
63413 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
63414 + GR_CHMOD_ACL_MSG);
63415 + } else {
63416 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
63417 + }
63418 +}
63419 +
63420 +__u32
63421 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
63422 +{
63423 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
63424 +}
63425 +
63426 +__u32
63427 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
63428 +{
63429 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
63430 +}
63431 +
63432 +__u32
63433 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
63434 +{
63435 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
63436 +}
63437 +
63438 +__u32
63439 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
63440 +{
63441 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
63442 + GR_UNIXCONNECT_ACL_MSG);
63443 +}
63444 +
63445 +/* hardlinks require at minimum create and link permission,
63446 + any additional privilege required is based on the
63447 + privilege of the file being linked to
63448 +*/
63449 +__u32
63450 +gr_acl_handle_link(const struct dentry * new_dentry,
63451 + const struct dentry * parent_dentry,
63452 + const struct vfsmount * parent_mnt,
63453 + const struct dentry * old_dentry,
63454 + const struct vfsmount * old_mnt, const struct filename *to)
63455 +{
63456 + __u32 mode;
63457 + __u32 needmode = GR_CREATE | GR_LINK;
63458 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
63459 +
63460 + mode =
63461 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
63462 + old_mnt);
63463 +
63464 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
63465 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
63466 + return mode;
63467 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
63468 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
63469 + return 0;
63470 + } else if (unlikely((mode & needmode) != needmode))
63471 + return 0;
63472 +
63473 + return 1;
63474 +}
63475 +
63476 +__u32
63477 +gr_acl_handle_symlink(const struct dentry * new_dentry,
63478 + const struct dentry * parent_dentry,
63479 + const struct vfsmount * parent_mnt, const struct filename *from)
63480 +{
63481 + __u32 needmode = GR_WRITE | GR_CREATE;
63482 + __u32 mode;
63483 +
63484 + mode =
63485 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
63486 + GR_CREATE | GR_AUDIT_CREATE |
63487 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
63488 +
63489 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
63490 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
63491 + return mode;
63492 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
63493 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
63494 + return 0;
63495 + } else if (unlikely((mode & needmode) != needmode))
63496 + return 0;
63497 +
63498 + return (GR_WRITE | GR_CREATE);
63499 +}
63500 +
63501 +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)
63502 +{
63503 + __u32 mode;
63504 +
63505 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
63506 +
63507 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
63508 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
63509 + return mode;
63510 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
63511 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
63512 + return 0;
63513 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
63514 + return 0;
63515 +
63516 + return (reqmode);
63517 +}
63518 +
63519 +__u32
63520 +gr_acl_handle_mknod(const struct dentry * new_dentry,
63521 + const struct dentry * parent_dentry,
63522 + const struct vfsmount * parent_mnt,
63523 + const int mode)
63524 +{
63525 + __u32 reqmode = GR_WRITE | GR_CREATE;
63526 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
63527 + reqmode |= GR_SETID;
63528 +
63529 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
63530 + reqmode, GR_MKNOD_ACL_MSG);
63531 +}
63532 +
63533 +__u32
63534 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
63535 + const struct dentry *parent_dentry,
63536 + const struct vfsmount *parent_mnt)
63537 +{
63538 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
63539 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
63540 +}
63541 +
63542 +#define RENAME_CHECK_SUCCESS(old, new) \
63543 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
63544 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
63545 +
63546 +int
63547 +gr_acl_handle_rename(struct dentry *new_dentry,
63548 + struct dentry *parent_dentry,
63549 + const struct vfsmount *parent_mnt,
63550 + struct dentry *old_dentry,
63551 + struct inode *old_parent_inode,
63552 + struct vfsmount *old_mnt, const struct filename *newname)
63553 +{
63554 + __u32 comp1, comp2;
63555 + int error = 0;
63556 +
63557 + if (unlikely(!gr_acl_is_enabled()))
63558 + return 0;
63559 +
63560 + if (!new_dentry->d_inode) {
63561 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
63562 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
63563 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
63564 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
63565 + GR_DELETE | GR_AUDIT_DELETE |
63566 + GR_AUDIT_READ | GR_AUDIT_WRITE |
63567 + GR_SUPPRESS, old_mnt);
63568 + } else {
63569 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
63570 + GR_CREATE | GR_DELETE |
63571 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
63572 + GR_AUDIT_READ | GR_AUDIT_WRITE |
63573 + GR_SUPPRESS, parent_mnt);
63574 + comp2 =
63575 + gr_search_file(old_dentry,
63576 + GR_READ | GR_WRITE | GR_AUDIT_READ |
63577 + GR_DELETE | GR_AUDIT_DELETE |
63578 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
63579 + }
63580 +
63581 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
63582 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
63583 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63584 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
63585 + && !(comp2 & GR_SUPPRESS)) {
63586 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63587 + error = -EACCES;
63588 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
63589 + error = -EACCES;
63590 +
63591 + return error;
63592 +}
63593 +
63594 +void
63595 +gr_acl_handle_exit(void)
63596 +{
63597 + u16 id;
63598 + char *rolename;
63599 +
63600 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
63601 + !(current->role->roletype & GR_ROLE_PERSIST))) {
63602 + id = current->acl_role_id;
63603 + rolename = current->role->rolename;
63604 + gr_set_acls(1);
63605 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
63606 + }
63607 +
63608 + gr_put_exec_file(current);
63609 + return;
63610 +}
63611 +
63612 +int
63613 +gr_acl_handle_procpidmem(const struct task_struct *task)
63614 +{
63615 + if (unlikely(!gr_acl_is_enabled()))
63616 + return 0;
63617 +
63618 + if (task != current && task->acl->mode & GR_PROTPROCFD)
63619 + return -EACCES;
63620 +
63621 + return 0;
63622 +}
63623 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
63624 new file mode 100644
63625 index 0000000..8132048
63626 --- /dev/null
63627 +++ b/grsecurity/gracl_ip.c
63628 @@ -0,0 +1,387 @@
63629 +#include <linux/kernel.h>
63630 +#include <asm/uaccess.h>
63631 +#include <asm/errno.h>
63632 +#include <net/sock.h>
63633 +#include <linux/file.h>
63634 +#include <linux/fs.h>
63635 +#include <linux/net.h>
63636 +#include <linux/in.h>
63637 +#include <linux/skbuff.h>
63638 +#include <linux/ip.h>
63639 +#include <linux/udp.h>
63640 +#include <linux/types.h>
63641 +#include <linux/sched.h>
63642 +#include <linux/netdevice.h>
63643 +#include <linux/inetdevice.h>
63644 +#include <linux/gracl.h>
63645 +#include <linux/grsecurity.h>
63646 +#include <linux/grinternal.h>
63647 +
63648 +#define GR_BIND 0x01
63649 +#define GR_CONNECT 0x02
63650 +#define GR_INVERT 0x04
63651 +#define GR_BINDOVERRIDE 0x08
63652 +#define GR_CONNECTOVERRIDE 0x10
63653 +#define GR_SOCK_FAMILY 0x20
63654 +
63655 +static const char * gr_protocols[IPPROTO_MAX] = {
63656 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
63657 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
63658 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
63659 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
63660 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
63661 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
63662 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
63663 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
63664 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
63665 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
63666 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
63667 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
63668 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
63669 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
63670 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
63671 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
63672 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
63673 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
63674 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
63675 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
63676 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
63677 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
63678 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
63679 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
63680 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
63681 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
63682 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
63683 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
63684 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
63685 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
63686 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
63687 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
63688 + };
63689 +
63690 +static const char * gr_socktypes[SOCK_MAX] = {
63691 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
63692 + "unknown:7", "unknown:8", "unknown:9", "packet"
63693 + };
63694 +
63695 +static const char * gr_sockfamilies[AF_MAX+1] = {
63696 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
63697 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
63698 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
63699 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
63700 + };
63701 +
63702 +const char *
63703 +gr_proto_to_name(unsigned char proto)
63704 +{
63705 + return gr_protocols[proto];
63706 +}
63707 +
63708 +const char *
63709 +gr_socktype_to_name(unsigned char type)
63710 +{
63711 + return gr_socktypes[type];
63712 +}
63713 +
63714 +const char *
63715 +gr_sockfamily_to_name(unsigned char family)
63716 +{
63717 + return gr_sockfamilies[family];
63718 +}
63719 +
63720 +int
63721 +gr_search_socket(const int domain, const int type, const int protocol)
63722 +{
63723 + struct acl_subject_label *curr;
63724 + const struct cred *cred = current_cred();
63725 +
63726 + if (unlikely(!gr_acl_is_enabled()))
63727 + goto exit;
63728 +
63729 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63730 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63731 + goto exit; // let the kernel handle it
63732 +
63733 + curr = current->acl;
63734 +
63735 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63736 + /* the family is allowed, if this is PF_INET allow it only if
63737 + the extra sock type/protocol checks pass */
63738 + if (domain == PF_INET)
63739 + goto inet_check;
63740 + goto exit;
63741 + } else {
63742 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63743 + __u32 fakeip = 0;
63744 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63745 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63746 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63747 + gr_to_filename(current->exec_file->f_path.dentry,
63748 + current->exec_file->f_path.mnt) :
63749 + curr->filename, curr->filename,
63750 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63751 + &current->signal->saved_ip);
63752 + goto exit;
63753 + }
63754 + goto exit_fail;
63755 + }
63756 +
63757 +inet_check:
63758 + /* the rest of this checking is for IPv4 only */
63759 + if (!curr->ips)
63760 + goto exit;
63761 +
63762 + if ((curr->ip_type & (1U << type)) &&
63763 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63764 + goto exit;
63765 +
63766 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63767 + /* we don't place acls on raw sockets , and sometimes
63768 + dgram/ip sockets are opened for ioctl and not
63769 + bind/connect, so we'll fake a bind learn log */
63770 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63771 + __u32 fakeip = 0;
63772 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63773 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63774 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63775 + gr_to_filename(current->exec_file->f_path.dentry,
63776 + current->exec_file->f_path.mnt) :
63777 + curr->filename, curr->filename,
63778 + &fakeip, 0, type,
63779 + protocol, GR_CONNECT, &current->signal->saved_ip);
63780 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63781 + __u32 fakeip = 0;
63782 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63783 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63784 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63785 + gr_to_filename(current->exec_file->f_path.dentry,
63786 + current->exec_file->f_path.mnt) :
63787 + curr->filename, curr->filename,
63788 + &fakeip, 0, type,
63789 + protocol, GR_BIND, &current->signal->saved_ip);
63790 + }
63791 + /* we'll log when they use connect or bind */
63792 + goto exit;
63793 + }
63794 +
63795 +exit_fail:
63796 + if (domain == PF_INET)
63797 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63798 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63799 + else
63800 +#ifndef CONFIG_IPV6
63801 + if (domain != PF_INET6)
63802 +#endif
63803 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63804 + gr_socktype_to_name(type), protocol);
63805 +
63806 + return 0;
63807 +exit:
63808 + return 1;
63809 +}
63810 +
63811 +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)
63812 +{
63813 + if ((ip->mode & mode) &&
63814 + (ip_port >= ip->low) &&
63815 + (ip_port <= ip->high) &&
63816 + ((ntohl(ip_addr) & our_netmask) ==
63817 + (ntohl(our_addr) & our_netmask))
63818 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63819 + && (ip->type & (1U << type))) {
63820 + if (ip->mode & GR_INVERT)
63821 + return 2; // specifically denied
63822 + else
63823 + return 1; // allowed
63824 + }
63825 +
63826 + return 0; // not specifically allowed, may continue parsing
63827 +}
63828 +
63829 +static int
63830 +gr_search_connectbind(const int full_mode, struct sock *sk,
63831 + struct sockaddr_in *addr, const int type)
63832 +{
63833 + char iface[IFNAMSIZ] = {0};
63834 + struct acl_subject_label *curr;
63835 + struct acl_ip_label *ip;
63836 + struct inet_sock *isk;
63837 + struct net_device *dev;
63838 + struct in_device *idev;
63839 + unsigned long i;
63840 + int ret;
63841 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63842 + __u32 ip_addr = 0;
63843 + __u32 our_addr;
63844 + __u32 our_netmask;
63845 + char *p;
63846 + __u16 ip_port = 0;
63847 + const struct cred *cred = current_cred();
63848 +
63849 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63850 + return 0;
63851 +
63852 + curr = current->acl;
63853 + isk = inet_sk(sk);
63854 +
63855 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63856 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63857 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63858 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63859 + struct sockaddr_in saddr;
63860 + int err;
63861 +
63862 + saddr.sin_family = AF_INET;
63863 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63864 + saddr.sin_port = isk->inet_sport;
63865 +
63866 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63867 + if (err)
63868 + return err;
63869 +
63870 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63871 + if (err)
63872 + return err;
63873 + }
63874 +
63875 + if (!curr->ips)
63876 + return 0;
63877 +
63878 + ip_addr = addr->sin_addr.s_addr;
63879 + ip_port = ntohs(addr->sin_port);
63880 +
63881 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63882 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63883 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63884 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63885 + gr_to_filename(current->exec_file->f_path.dentry,
63886 + current->exec_file->f_path.mnt) :
63887 + curr->filename, curr->filename,
63888 + &ip_addr, ip_port, type,
63889 + sk->sk_protocol, mode, &current->signal->saved_ip);
63890 + return 0;
63891 + }
63892 +
63893 + for (i = 0; i < curr->ip_num; i++) {
63894 + ip = *(curr->ips + i);
63895 + if (ip->iface != NULL) {
63896 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63897 + p = strchr(iface, ':');
63898 + if (p != NULL)
63899 + *p = '\0';
63900 + dev = dev_get_by_name(sock_net(sk), iface);
63901 + if (dev == NULL)
63902 + continue;
63903 + idev = in_dev_get(dev);
63904 + if (idev == NULL) {
63905 + dev_put(dev);
63906 + continue;
63907 + }
63908 + rcu_read_lock();
63909 + for_ifa(idev) {
63910 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63911 + our_addr = ifa->ifa_address;
63912 + our_netmask = 0xffffffff;
63913 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63914 + if (ret == 1) {
63915 + rcu_read_unlock();
63916 + in_dev_put(idev);
63917 + dev_put(dev);
63918 + return 0;
63919 + } else if (ret == 2) {
63920 + rcu_read_unlock();
63921 + in_dev_put(idev);
63922 + dev_put(dev);
63923 + goto denied;
63924 + }
63925 + }
63926 + } endfor_ifa(idev);
63927 + rcu_read_unlock();
63928 + in_dev_put(idev);
63929 + dev_put(dev);
63930 + } else {
63931 + our_addr = ip->addr;
63932 + our_netmask = ip->netmask;
63933 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63934 + if (ret == 1)
63935 + return 0;
63936 + else if (ret == 2)
63937 + goto denied;
63938 + }
63939 + }
63940 +
63941 +denied:
63942 + if (mode == GR_BIND)
63943 + 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));
63944 + else if (mode == GR_CONNECT)
63945 + 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));
63946 +
63947 + return -EACCES;
63948 +}
63949 +
63950 +int
63951 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63952 +{
63953 + /* always allow disconnection of dgram sockets with connect */
63954 + if (addr->sin_family == AF_UNSPEC)
63955 + return 0;
63956 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63957 +}
63958 +
63959 +int
63960 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63961 +{
63962 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63963 +}
63964 +
63965 +int gr_search_listen(struct socket *sock)
63966 +{
63967 + struct sock *sk = sock->sk;
63968 + struct sockaddr_in addr;
63969 +
63970 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63971 + addr.sin_port = inet_sk(sk)->inet_sport;
63972 +
63973 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63974 +}
63975 +
63976 +int gr_search_accept(struct socket *sock)
63977 +{
63978 + struct sock *sk = sock->sk;
63979 + struct sockaddr_in addr;
63980 +
63981 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63982 + addr.sin_port = inet_sk(sk)->inet_sport;
63983 +
63984 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63985 +}
63986 +
63987 +int
63988 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63989 +{
63990 + if (addr)
63991 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63992 + else {
63993 + struct sockaddr_in sin;
63994 + const struct inet_sock *inet = inet_sk(sk);
63995 +
63996 + sin.sin_addr.s_addr = inet->inet_daddr;
63997 + sin.sin_port = inet->inet_dport;
63998 +
63999 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
64000 + }
64001 +}
64002 +
64003 +int
64004 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
64005 +{
64006 + struct sockaddr_in sin;
64007 +
64008 + if (unlikely(skb->len < sizeof (struct udphdr)))
64009 + return 0; // skip this packet
64010 +
64011 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
64012 + sin.sin_port = udp_hdr(skb)->source;
64013 +
64014 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
64015 +}
64016 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
64017 new file mode 100644
64018 index 0000000..25f54ef
64019 --- /dev/null
64020 +++ b/grsecurity/gracl_learn.c
64021 @@ -0,0 +1,207 @@
64022 +#include <linux/kernel.h>
64023 +#include <linux/mm.h>
64024 +#include <linux/sched.h>
64025 +#include <linux/poll.h>
64026 +#include <linux/string.h>
64027 +#include <linux/file.h>
64028 +#include <linux/types.h>
64029 +#include <linux/vmalloc.h>
64030 +#include <linux/grinternal.h>
64031 +
64032 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
64033 + size_t count, loff_t *ppos);
64034 +extern int gr_acl_is_enabled(void);
64035 +
64036 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
64037 +static int gr_learn_attached;
64038 +
64039 +/* use a 512k buffer */
64040 +#define LEARN_BUFFER_SIZE (512 * 1024)
64041 +
64042 +static DEFINE_SPINLOCK(gr_learn_lock);
64043 +static DEFINE_MUTEX(gr_learn_user_mutex);
64044 +
64045 +/* we need to maintain two buffers, so that the kernel context of grlearn
64046 + uses a semaphore around the userspace copying, and the other kernel contexts
64047 + use a spinlock when copying into the buffer, since they cannot sleep
64048 +*/
64049 +static char *learn_buffer;
64050 +static char *learn_buffer_user;
64051 +static int learn_buffer_len;
64052 +static int learn_buffer_user_len;
64053 +
64054 +static ssize_t
64055 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
64056 +{
64057 + DECLARE_WAITQUEUE(wait, current);
64058 + ssize_t retval = 0;
64059 +
64060 + add_wait_queue(&learn_wait, &wait);
64061 + set_current_state(TASK_INTERRUPTIBLE);
64062 + do {
64063 + mutex_lock(&gr_learn_user_mutex);
64064 + spin_lock(&gr_learn_lock);
64065 + if (learn_buffer_len)
64066 + break;
64067 + spin_unlock(&gr_learn_lock);
64068 + mutex_unlock(&gr_learn_user_mutex);
64069 + if (file->f_flags & O_NONBLOCK) {
64070 + retval = -EAGAIN;
64071 + goto out;
64072 + }
64073 + if (signal_pending(current)) {
64074 + retval = -ERESTARTSYS;
64075 + goto out;
64076 + }
64077 +
64078 + schedule();
64079 + } while (1);
64080 +
64081 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
64082 + learn_buffer_user_len = learn_buffer_len;
64083 + retval = learn_buffer_len;
64084 + learn_buffer_len = 0;
64085 +
64086 + spin_unlock(&gr_learn_lock);
64087 +
64088 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
64089 + retval = -EFAULT;
64090 +
64091 + mutex_unlock(&gr_learn_user_mutex);
64092 +out:
64093 + set_current_state(TASK_RUNNING);
64094 + remove_wait_queue(&learn_wait, &wait);
64095 + return retval;
64096 +}
64097 +
64098 +static unsigned int
64099 +poll_learn(struct file * file, poll_table * wait)
64100 +{
64101 + poll_wait(file, &learn_wait, wait);
64102 +
64103 + if (learn_buffer_len)
64104 + return (POLLIN | POLLRDNORM);
64105 +
64106 + return 0;
64107 +}
64108 +
64109 +void
64110 +gr_clear_learn_entries(void)
64111 +{
64112 + char *tmp;
64113 +
64114 + mutex_lock(&gr_learn_user_mutex);
64115 + spin_lock(&gr_learn_lock);
64116 + tmp = learn_buffer;
64117 + learn_buffer = NULL;
64118 + spin_unlock(&gr_learn_lock);
64119 + if (tmp)
64120 + vfree(tmp);
64121 + if (learn_buffer_user != NULL) {
64122 + vfree(learn_buffer_user);
64123 + learn_buffer_user = NULL;
64124 + }
64125 + learn_buffer_len = 0;
64126 + mutex_unlock(&gr_learn_user_mutex);
64127 +
64128 + return;
64129 +}
64130 +
64131 +void
64132 +gr_add_learn_entry(const char *fmt, ...)
64133 +{
64134 + va_list args;
64135 + unsigned int len;
64136 +
64137 + if (!gr_learn_attached)
64138 + return;
64139 +
64140 + spin_lock(&gr_learn_lock);
64141 +
64142 + /* leave a gap at the end so we know when it's "full" but don't have to
64143 + compute the exact length of the string we're trying to append
64144 + */
64145 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
64146 + spin_unlock(&gr_learn_lock);
64147 + wake_up_interruptible(&learn_wait);
64148 + return;
64149 + }
64150 + if (learn_buffer == NULL) {
64151 + spin_unlock(&gr_learn_lock);
64152 + return;
64153 + }
64154 +
64155 + va_start(args, fmt);
64156 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
64157 + va_end(args);
64158 +
64159 + learn_buffer_len += len + 1;
64160 +
64161 + spin_unlock(&gr_learn_lock);
64162 + wake_up_interruptible(&learn_wait);
64163 +
64164 + return;
64165 +}
64166 +
64167 +static int
64168 +open_learn(struct inode *inode, struct file *file)
64169 +{
64170 + if (file->f_mode & FMODE_READ && gr_learn_attached)
64171 + return -EBUSY;
64172 + if (file->f_mode & FMODE_READ) {
64173 + int retval = 0;
64174 + mutex_lock(&gr_learn_user_mutex);
64175 + if (learn_buffer == NULL)
64176 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
64177 + if (learn_buffer_user == NULL)
64178 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
64179 + if (learn_buffer == NULL) {
64180 + retval = -ENOMEM;
64181 + goto out_error;
64182 + }
64183 + if (learn_buffer_user == NULL) {
64184 + retval = -ENOMEM;
64185 + goto out_error;
64186 + }
64187 + learn_buffer_len = 0;
64188 + learn_buffer_user_len = 0;
64189 + gr_learn_attached = 1;
64190 +out_error:
64191 + mutex_unlock(&gr_learn_user_mutex);
64192 + return retval;
64193 + }
64194 + return 0;
64195 +}
64196 +
64197 +static int
64198 +close_learn(struct inode *inode, struct file *file)
64199 +{
64200 + if (file->f_mode & FMODE_READ) {
64201 + char *tmp = NULL;
64202 + mutex_lock(&gr_learn_user_mutex);
64203 + spin_lock(&gr_learn_lock);
64204 + tmp = learn_buffer;
64205 + learn_buffer = NULL;
64206 + spin_unlock(&gr_learn_lock);
64207 + if (tmp)
64208 + vfree(tmp);
64209 + if (learn_buffer_user != NULL) {
64210 + vfree(learn_buffer_user);
64211 + learn_buffer_user = NULL;
64212 + }
64213 + learn_buffer_len = 0;
64214 + learn_buffer_user_len = 0;
64215 + gr_learn_attached = 0;
64216 + mutex_unlock(&gr_learn_user_mutex);
64217 + }
64218 +
64219 + return 0;
64220 +}
64221 +
64222 +const struct file_operations grsec_fops = {
64223 + .read = read_learn,
64224 + .write = write_grsec_handler,
64225 + .open = open_learn,
64226 + .release = close_learn,
64227 + .poll = poll_learn,
64228 +};
64229 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
64230 new file mode 100644
64231 index 0000000..39645c9
64232 --- /dev/null
64233 +++ b/grsecurity/gracl_res.c
64234 @@ -0,0 +1,68 @@
64235 +#include <linux/kernel.h>
64236 +#include <linux/sched.h>
64237 +#include <linux/gracl.h>
64238 +#include <linux/grinternal.h>
64239 +
64240 +static const char *restab_log[] = {
64241 + [RLIMIT_CPU] = "RLIMIT_CPU",
64242 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
64243 + [RLIMIT_DATA] = "RLIMIT_DATA",
64244 + [RLIMIT_STACK] = "RLIMIT_STACK",
64245 + [RLIMIT_CORE] = "RLIMIT_CORE",
64246 + [RLIMIT_RSS] = "RLIMIT_RSS",
64247 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
64248 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
64249 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
64250 + [RLIMIT_AS] = "RLIMIT_AS",
64251 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
64252 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
64253 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
64254 + [RLIMIT_NICE] = "RLIMIT_NICE",
64255 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
64256 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
64257 + [GR_CRASH_RES] = "RLIMIT_CRASH"
64258 +};
64259 +
64260 +void
64261 +gr_log_resource(const struct task_struct *task,
64262 + const int res, const unsigned long wanted, const int gt)
64263 +{
64264 + const struct cred *cred;
64265 + unsigned long rlim;
64266 +
64267 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
64268 + return;
64269 +
64270 + // not yet supported resource
64271 + if (unlikely(!restab_log[res]))
64272 + return;
64273 +
64274 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
64275 + rlim = task_rlimit_max(task, res);
64276 + else
64277 + rlim = task_rlimit(task, res);
64278 +
64279 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
64280 + return;
64281 +
64282 + rcu_read_lock();
64283 + cred = __task_cred(task);
64284 +
64285 + if (res == RLIMIT_NPROC &&
64286 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
64287 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
64288 + goto out_rcu_unlock;
64289 + else if (res == RLIMIT_MEMLOCK &&
64290 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
64291 + goto out_rcu_unlock;
64292 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
64293 + goto out_rcu_unlock;
64294 + rcu_read_unlock();
64295 +
64296 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
64297 +
64298 + return;
64299 +out_rcu_unlock:
64300 + rcu_read_unlock();
64301 + return;
64302 +}
64303 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
64304 new file mode 100644
64305 index 0000000..3c38bfe
64306 --- /dev/null
64307 +++ b/grsecurity/gracl_segv.c
64308 @@ -0,0 +1,305 @@
64309 +#include <linux/kernel.h>
64310 +#include <linux/mm.h>
64311 +#include <asm/uaccess.h>
64312 +#include <asm/errno.h>
64313 +#include <asm/mman.h>
64314 +#include <net/sock.h>
64315 +#include <linux/file.h>
64316 +#include <linux/fs.h>
64317 +#include <linux/net.h>
64318 +#include <linux/in.h>
64319 +#include <linux/slab.h>
64320 +#include <linux/types.h>
64321 +#include <linux/sched.h>
64322 +#include <linux/timer.h>
64323 +#include <linux/gracl.h>
64324 +#include <linux/grsecurity.h>
64325 +#include <linux/grinternal.h>
64326 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
64327 +#include <linux/magic.h>
64328 +#include <linux/pagemap.h>
64329 +#include "../fs/btrfs/async-thread.h"
64330 +#include "../fs/btrfs/ctree.h"
64331 +#include "../fs/btrfs/btrfs_inode.h"
64332 +#endif
64333 +
64334 +static struct crash_uid *uid_set;
64335 +static unsigned short uid_used;
64336 +static DEFINE_SPINLOCK(gr_uid_lock);
64337 +extern rwlock_t gr_inode_lock;
64338 +extern struct acl_subject_label *
64339 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
64340 + struct acl_role_label *role);
64341 +
64342 +static inline dev_t __get_dev(const struct dentry *dentry)
64343 +{
64344 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
64345 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
64346 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
64347 + else
64348 +#endif
64349 + return dentry->d_sb->s_dev;
64350 +}
64351 +
64352 +int
64353 +gr_init_uidset(void)
64354 +{
64355 + uid_set =
64356 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
64357 + uid_used = 0;
64358 +
64359 + return uid_set ? 1 : 0;
64360 +}
64361 +
64362 +void
64363 +gr_free_uidset(void)
64364 +{
64365 + if (uid_set)
64366 + kfree(uid_set);
64367 +
64368 + return;
64369 +}
64370 +
64371 +int
64372 +gr_find_uid(const uid_t uid)
64373 +{
64374 + struct crash_uid *tmp = uid_set;
64375 + uid_t buid;
64376 + int low = 0, high = uid_used - 1, mid;
64377 +
64378 + while (high >= low) {
64379 + mid = (low + high) >> 1;
64380 + buid = tmp[mid].uid;
64381 + if (buid == uid)
64382 + return mid;
64383 + if (buid > uid)
64384 + high = mid - 1;
64385 + if (buid < uid)
64386 + low = mid + 1;
64387 + }
64388 +
64389 + return -1;
64390 +}
64391 +
64392 +static __inline__ void
64393 +gr_insertsort(void)
64394 +{
64395 + unsigned short i, j;
64396 + struct crash_uid index;
64397 +
64398 + for (i = 1; i < uid_used; i++) {
64399 + index = uid_set[i];
64400 + j = i;
64401 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
64402 + uid_set[j] = uid_set[j - 1];
64403 + j--;
64404 + }
64405 + uid_set[j] = index;
64406 + }
64407 +
64408 + return;
64409 +}
64410 +
64411 +static __inline__ void
64412 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
64413 +{
64414 + int loc;
64415 + uid_t uid = GR_GLOBAL_UID(kuid);
64416 +
64417 + if (uid_used == GR_UIDTABLE_MAX)
64418 + return;
64419 +
64420 + loc = gr_find_uid(uid);
64421 +
64422 + if (loc >= 0) {
64423 + uid_set[loc].expires = expires;
64424 + return;
64425 + }
64426 +
64427 + uid_set[uid_used].uid = uid;
64428 + uid_set[uid_used].expires = expires;
64429 + uid_used++;
64430 +
64431 + gr_insertsort();
64432 +
64433 + return;
64434 +}
64435 +
64436 +void
64437 +gr_remove_uid(const unsigned short loc)
64438 +{
64439 + unsigned short i;
64440 +
64441 + for (i = loc + 1; i < uid_used; i++)
64442 + uid_set[i - 1] = uid_set[i];
64443 +
64444 + uid_used--;
64445 +
64446 + return;
64447 +}
64448 +
64449 +int
64450 +gr_check_crash_uid(const kuid_t kuid)
64451 +{
64452 + int loc;
64453 + int ret = 0;
64454 + uid_t uid;
64455 +
64456 + if (unlikely(!gr_acl_is_enabled()))
64457 + return 0;
64458 +
64459 + uid = GR_GLOBAL_UID(kuid);
64460 +
64461 + spin_lock(&gr_uid_lock);
64462 + loc = gr_find_uid(uid);
64463 +
64464 + if (loc < 0)
64465 + goto out_unlock;
64466 +
64467 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
64468 + gr_remove_uid(loc);
64469 + else
64470 + ret = 1;
64471 +
64472 +out_unlock:
64473 + spin_unlock(&gr_uid_lock);
64474 + return ret;
64475 +}
64476 +
64477 +static __inline__ int
64478 +proc_is_setxid(const struct cred *cred)
64479 +{
64480 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
64481 + !uid_eq(cred->uid, cred->fsuid))
64482 + return 1;
64483 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
64484 + !gid_eq(cred->gid, cred->fsgid))
64485 + return 1;
64486 +
64487 + return 0;
64488 +}
64489 +
64490 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
64491 +
64492 +void
64493 +gr_handle_crash(struct task_struct *task, const int sig)
64494 +{
64495 + struct acl_subject_label *curr;
64496 + struct task_struct *tsk, *tsk2;
64497 + const struct cred *cred;
64498 + const struct cred *cred2;
64499 +
64500 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
64501 + return;
64502 +
64503 + if (unlikely(!gr_acl_is_enabled()))
64504 + return;
64505 +
64506 + curr = task->acl;
64507 +
64508 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
64509 + return;
64510 +
64511 + if (time_before_eq(curr->expires, get_seconds())) {
64512 + curr->expires = 0;
64513 + curr->crashes = 0;
64514 + }
64515 +
64516 + curr->crashes++;
64517 +
64518 + if (!curr->expires)
64519 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
64520 +
64521 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
64522 + time_after(curr->expires, get_seconds())) {
64523 + rcu_read_lock();
64524 + cred = __task_cred(task);
64525 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
64526 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
64527 + spin_lock(&gr_uid_lock);
64528 + gr_insert_uid(cred->uid, curr->expires);
64529 + spin_unlock(&gr_uid_lock);
64530 + curr->expires = 0;
64531 + curr->crashes = 0;
64532 + read_lock(&tasklist_lock);
64533 + do_each_thread(tsk2, tsk) {
64534 + cred2 = __task_cred(tsk);
64535 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
64536 + gr_fake_force_sig(SIGKILL, tsk);
64537 + } while_each_thread(tsk2, tsk);
64538 + read_unlock(&tasklist_lock);
64539 + } else {
64540 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
64541 + read_lock(&tasklist_lock);
64542 + read_lock(&grsec_exec_file_lock);
64543 + do_each_thread(tsk2, tsk) {
64544 + if (likely(tsk != task)) {
64545 + // if this thread has the same subject as the one that triggered
64546 + // RES_CRASH and it's the same binary, kill it
64547 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
64548 + gr_fake_force_sig(SIGKILL, tsk);
64549 + }
64550 + } while_each_thread(tsk2, tsk);
64551 + read_unlock(&grsec_exec_file_lock);
64552 + read_unlock(&tasklist_lock);
64553 + }
64554 + rcu_read_unlock();
64555 + }
64556 +
64557 + return;
64558 +}
64559 +
64560 +int
64561 +gr_check_crash_exec(const struct file *filp)
64562 +{
64563 + struct acl_subject_label *curr;
64564 +
64565 + if (unlikely(!gr_acl_is_enabled()))
64566 + return 0;
64567 +
64568 + read_lock(&gr_inode_lock);
64569 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
64570 + __get_dev(filp->f_path.dentry),
64571 + current->role);
64572 + read_unlock(&gr_inode_lock);
64573 +
64574 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
64575 + (!curr->crashes && !curr->expires))
64576 + return 0;
64577 +
64578 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
64579 + time_after(curr->expires, get_seconds()))
64580 + return 1;
64581 + else if (time_before_eq(curr->expires, get_seconds())) {
64582 + curr->crashes = 0;
64583 + curr->expires = 0;
64584 + }
64585 +
64586 + return 0;
64587 +}
64588 +
64589 +void
64590 +gr_handle_alertkill(struct task_struct *task)
64591 +{
64592 + struct acl_subject_label *curracl;
64593 + __u32 curr_ip;
64594 + struct task_struct *p, *p2;
64595 +
64596 + if (unlikely(!gr_acl_is_enabled()))
64597 + return;
64598 +
64599 + curracl = task->acl;
64600 + curr_ip = task->signal->curr_ip;
64601 +
64602 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
64603 + read_lock(&tasklist_lock);
64604 + do_each_thread(p2, p) {
64605 + if (p->signal->curr_ip == curr_ip)
64606 + gr_fake_force_sig(SIGKILL, p);
64607 + } while_each_thread(p2, p);
64608 + read_unlock(&tasklist_lock);
64609 + } else if (curracl->mode & GR_KILLPROC)
64610 + gr_fake_force_sig(SIGKILL, task);
64611 +
64612 + return;
64613 +}
64614 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
64615 new file mode 100644
64616 index 0000000..98011b0
64617 --- /dev/null
64618 +++ b/grsecurity/gracl_shm.c
64619 @@ -0,0 +1,40 @@
64620 +#include <linux/kernel.h>
64621 +#include <linux/mm.h>
64622 +#include <linux/sched.h>
64623 +#include <linux/file.h>
64624 +#include <linux/ipc.h>
64625 +#include <linux/gracl.h>
64626 +#include <linux/grsecurity.h>
64627 +#include <linux/grinternal.h>
64628 +
64629 +int
64630 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64631 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64632 +{
64633 + struct task_struct *task;
64634 +
64635 + if (!gr_acl_is_enabled())
64636 + return 1;
64637 +
64638 + rcu_read_lock();
64639 + read_lock(&tasklist_lock);
64640 +
64641 + task = find_task_by_vpid(shm_cprid);
64642 +
64643 + if (unlikely(!task))
64644 + task = find_task_by_vpid(shm_lapid);
64645 +
64646 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
64647 + (task_pid_nr(task) == shm_lapid)) &&
64648 + (task->acl->mode & GR_PROTSHM) &&
64649 + (task->acl != current->acl))) {
64650 + read_unlock(&tasklist_lock);
64651 + rcu_read_unlock();
64652 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
64653 + return 0;
64654 + }
64655 + read_unlock(&tasklist_lock);
64656 + rcu_read_unlock();
64657 +
64658 + return 1;
64659 +}
64660 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
64661 new file mode 100644
64662 index 0000000..bc0be01
64663 --- /dev/null
64664 +++ b/grsecurity/grsec_chdir.c
64665 @@ -0,0 +1,19 @@
64666 +#include <linux/kernel.h>
64667 +#include <linux/sched.h>
64668 +#include <linux/fs.h>
64669 +#include <linux/file.h>
64670 +#include <linux/grsecurity.h>
64671 +#include <linux/grinternal.h>
64672 +
64673 +void
64674 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
64675 +{
64676 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64677 + if ((grsec_enable_chdir && grsec_enable_group &&
64678 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
64679 + !grsec_enable_group)) {
64680 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
64681 + }
64682 +#endif
64683 + return;
64684 +}
64685 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
64686 new file mode 100644
64687 index 0000000..bd6e105
64688 --- /dev/null
64689 +++ b/grsecurity/grsec_chroot.c
64690 @@ -0,0 +1,370 @@
64691 +#include <linux/kernel.h>
64692 +#include <linux/module.h>
64693 +#include <linux/sched.h>
64694 +#include <linux/file.h>
64695 +#include <linux/fs.h>
64696 +#include <linux/mount.h>
64697 +#include <linux/types.h>
64698 +#include "../fs/mount.h"
64699 +#include <linux/grsecurity.h>
64700 +#include <linux/grinternal.h>
64701 +
64702 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64703 +static int gr_init_ran;
64704 +#endif
64705 +
64706 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
64707 +{
64708 +#ifdef CONFIG_GRKERNSEC
64709 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64710 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
64711 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64712 + && gr_init_ran
64713 +#endif
64714 + )
64715 + task->gr_is_chrooted = 1;
64716 + else {
64717 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64718 + if (task_pid_nr(task) == 1 && !gr_init_ran)
64719 + gr_init_ran = 1;
64720 +#endif
64721 + task->gr_is_chrooted = 0;
64722 + }
64723 +
64724 + task->gr_chroot_dentry = path->dentry;
64725 +#endif
64726 + return;
64727 +}
64728 +
64729 +void gr_clear_chroot_entries(struct task_struct *task)
64730 +{
64731 +#ifdef CONFIG_GRKERNSEC
64732 + task->gr_is_chrooted = 0;
64733 + task->gr_chroot_dentry = NULL;
64734 +#endif
64735 + return;
64736 +}
64737 +
64738 +int
64739 +gr_handle_chroot_unix(const pid_t pid)
64740 +{
64741 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64742 + struct task_struct *p;
64743 +
64744 + if (unlikely(!grsec_enable_chroot_unix))
64745 + return 1;
64746 +
64747 + if (likely(!proc_is_chrooted(current)))
64748 + return 1;
64749 +
64750 + rcu_read_lock();
64751 + read_lock(&tasklist_lock);
64752 + p = find_task_by_vpid_unrestricted(pid);
64753 + if (unlikely(p && !have_same_root(current, p))) {
64754 + read_unlock(&tasklist_lock);
64755 + rcu_read_unlock();
64756 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64757 + return 0;
64758 + }
64759 + read_unlock(&tasklist_lock);
64760 + rcu_read_unlock();
64761 +#endif
64762 + return 1;
64763 +}
64764 +
64765 +int
64766 +gr_handle_chroot_nice(void)
64767 +{
64768 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64769 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64770 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64771 + return -EPERM;
64772 + }
64773 +#endif
64774 + return 0;
64775 +}
64776 +
64777 +int
64778 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64779 +{
64780 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64781 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64782 + && proc_is_chrooted(current)) {
64783 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64784 + return -EACCES;
64785 + }
64786 +#endif
64787 + return 0;
64788 +}
64789 +
64790 +int
64791 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64792 +{
64793 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64794 + struct task_struct *p;
64795 + int ret = 0;
64796 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64797 + return ret;
64798 +
64799 + read_lock(&tasklist_lock);
64800 + do_each_pid_task(pid, type, p) {
64801 + if (!have_same_root(current, p)) {
64802 + ret = 1;
64803 + goto out;
64804 + }
64805 + } while_each_pid_task(pid, type, p);
64806 +out:
64807 + read_unlock(&tasklist_lock);
64808 + return ret;
64809 +#endif
64810 + return 0;
64811 +}
64812 +
64813 +int
64814 +gr_pid_is_chrooted(struct task_struct *p)
64815 +{
64816 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64817 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64818 + return 0;
64819 +
64820 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64821 + !have_same_root(current, p)) {
64822 + return 1;
64823 + }
64824 +#endif
64825 + return 0;
64826 +}
64827 +
64828 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64829 +
64830 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64831 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64832 +{
64833 + struct path path, currentroot;
64834 + int ret = 0;
64835 +
64836 + path.dentry = (struct dentry *)u_dentry;
64837 + path.mnt = (struct vfsmount *)u_mnt;
64838 + get_fs_root(current->fs, &currentroot);
64839 + if (path_is_under(&path, &currentroot))
64840 + ret = 1;
64841 + path_put(&currentroot);
64842 +
64843 + return ret;
64844 +}
64845 +#endif
64846 +
64847 +int
64848 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64849 +{
64850 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64851 + if (!grsec_enable_chroot_fchdir)
64852 + return 1;
64853 +
64854 + if (!proc_is_chrooted(current))
64855 + return 1;
64856 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64857 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64858 + return 0;
64859 + }
64860 +#endif
64861 + return 1;
64862 +}
64863 +
64864 +int
64865 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64866 + const time_t shm_createtime)
64867 +{
64868 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64869 + struct task_struct *p;
64870 + time_t starttime;
64871 +
64872 + if (unlikely(!grsec_enable_chroot_shmat))
64873 + return 1;
64874 +
64875 + if (likely(!proc_is_chrooted(current)))
64876 + return 1;
64877 +
64878 + rcu_read_lock();
64879 + read_lock(&tasklist_lock);
64880 +
64881 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64882 + starttime = p->start_time.tv_sec;
64883 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64884 + if (have_same_root(current, p)) {
64885 + goto allow;
64886 + } else {
64887 + read_unlock(&tasklist_lock);
64888 + rcu_read_unlock();
64889 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64890 + return 0;
64891 + }
64892 + }
64893 + /* creator exited, pid reuse, fall through to next check */
64894 + }
64895 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64896 + if (unlikely(!have_same_root(current, p))) {
64897 + read_unlock(&tasklist_lock);
64898 + rcu_read_unlock();
64899 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64900 + return 0;
64901 + }
64902 + }
64903 +
64904 +allow:
64905 + read_unlock(&tasklist_lock);
64906 + rcu_read_unlock();
64907 +#endif
64908 + return 1;
64909 +}
64910 +
64911 +void
64912 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64913 +{
64914 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64915 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64916 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64917 +#endif
64918 + return;
64919 +}
64920 +
64921 +int
64922 +gr_handle_chroot_mknod(const struct dentry *dentry,
64923 + const struct vfsmount *mnt, const int mode)
64924 +{
64925 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64926 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64927 + proc_is_chrooted(current)) {
64928 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64929 + return -EPERM;
64930 + }
64931 +#endif
64932 + return 0;
64933 +}
64934 +
64935 +int
64936 +gr_handle_chroot_mount(const struct dentry *dentry,
64937 + const struct vfsmount *mnt, const char *dev_name)
64938 +{
64939 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64940 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64941 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64942 + return -EPERM;
64943 + }
64944 +#endif
64945 + return 0;
64946 +}
64947 +
64948 +int
64949 +gr_handle_chroot_pivot(void)
64950 +{
64951 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64952 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64953 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64954 + return -EPERM;
64955 + }
64956 +#endif
64957 + return 0;
64958 +}
64959 +
64960 +int
64961 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64962 +{
64963 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64964 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64965 + !gr_is_outside_chroot(dentry, mnt)) {
64966 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64967 + return -EPERM;
64968 + }
64969 +#endif
64970 + return 0;
64971 +}
64972 +
64973 +extern const char *captab_log[];
64974 +extern int captab_log_entries;
64975 +
64976 +int
64977 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64978 +{
64979 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64980 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64981 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64982 + if (cap_raised(chroot_caps, cap)) {
64983 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64984 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64985 + }
64986 + return 0;
64987 + }
64988 + }
64989 +#endif
64990 + return 1;
64991 +}
64992 +
64993 +int
64994 +gr_chroot_is_capable(const int cap)
64995 +{
64996 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64997 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64998 +#endif
64999 + return 1;
65000 +}
65001 +
65002 +int
65003 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
65004 +{
65005 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65006 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
65007 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
65008 + if (cap_raised(chroot_caps, cap)) {
65009 + return 0;
65010 + }
65011 + }
65012 +#endif
65013 + return 1;
65014 +}
65015 +
65016 +int
65017 +gr_chroot_is_capable_nolog(const int cap)
65018 +{
65019 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65020 + return gr_task_chroot_is_capable_nolog(current, cap);
65021 +#endif
65022 + return 1;
65023 +}
65024 +
65025 +int
65026 +gr_handle_chroot_sysctl(const int op)
65027 +{
65028 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65029 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
65030 + proc_is_chrooted(current))
65031 + return -EACCES;
65032 +#endif
65033 + return 0;
65034 +}
65035 +
65036 +void
65037 +gr_handle_chroot_chdir(const struct path *path)
65038 +{
65039 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65040 + if (grsec_enable_chroot_chdir)
65041 + set_fs_pwd(current->fs, path);
65042 +#endif
65043 + return;
65044 +}
65045 +
65046 +int
65047 +gr_handle_chroot_chmod(const struct dentry *dentry,
65048 + const struct vfsmount *mnt, const int mode)
65049 +{
65050 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65051 + /* allow chmod +s on directories, but not files */
65052 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
65053 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
65054 + proc_is_chrooted(current)) {
65055 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
65056 + return -EPERM;
65057 + }
65058 +#endif
65059 + return 0;
65060 +}
65061 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
65062 new file mode 100644
65063 index 0000000..ce65ceb
65064 --- /dev/null
65065 +++ b/grsecurity/grsec_disabled.c
65066 @@ -0,0 +1,434 @@
65067 +#include <linux/kernel.h>
65068 +#include <linux/module.h>
65069 +#include <linux/sched.h>
65070 +#include <linux/file.h>
65071 +#include <linux/fs.h>
65072 +#include <linux/kdev_t.h>
65073 +#include <linux/net.h>
65074 +#include <linux/in.h>
65075 +#include <linux/ip.h>
65076 +#include <linux/skbuff.h>
65077 +#include <linux/sysctl.h>
65078 +
65079 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
65080 +void
65081 +pax_set_initial_flags(struct linux_binprm *bprm)
65082 +{
65083 + return;
65084 +}
65085 +#endif
65086 +
65087 +#ifdef CONFIG_SYSCTL
65088 +__u32
65089 +gr_handle_sysctl(const struct ctl_table * table, const int op)
65090 +{
65091 + return 0;
65092 +}
65093 +#endif
65094 +
65095 +#ifdef CONFIG_TASKSTATS
65096 +int gr_is_taskstats_denied(int pid)
65097 +{
65098 + return 0;
65099 +}
65100 +#endif
65101 +
65102 +int
65103 +gr_acl_is_enabled(void)
65104 +{
65105 + return 0;
65106 +}
65107 +
65108 +void
65109 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65110 +{
65111 + return;
65112 +}
65113 +
65114 +int
65115 +gr_handle_rawio(const struct inode *inode)
65116 +{
65117 + return 0;
65118 +}
65119 +
65120 +void
65121 +gr_acl_handle_psacct(struct task_struct *task, const long code)
65122 +{
65123 + return;
65124 +}
65125 +
65126 +int
65127 +gr_handle_ptrace(struct task_struct *task, const long request)
65128 +{
65129 + return 0;
65130 +}
65131 +
65132 +int
65133 +gr_handle_proc_ptrace(struct task_struct *task)
65134 +{
65135 + return 0;
65136 +}
65137 +
65138 +int
65139 +gr_set_acls(const int type)
65140 +{
65141 + return 0;
65142 +}
65143 +
65144 +int
65145 +gr_check_hidden_task(const struct task_struct *tsk)
65146 +{
65147 + return 0;
65148 +}
65149 +
65150 +int
65151 +gr_check_protected_task(const struct task_struct *task)
65152 +{
65153 + return 0;
65154 +}
65155 +
65156 +int
65157 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
65158 +{
65159 + return 0;
65160 +}
65161 +
65162 +void
65163 +gr_copy_label(struct task_struct *tsk)
65164 +{
65165 + return;
65166 +}
65167 +
65168 +void
65169 +gr_set_pax_flags(struct task_struct *task)
65170 +{
65171 + return;
65172 +}
65173 +
65174 +int
65175 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
65176 + const int unsafe_share)
65177 +{
65178 + return 0;
65179 +}
65180 +
65181 +void
65182 +gr_handle_delete(const ino_t ino, const dev_t dev)
65183 +{
65184 + return;
65185 +}
65186 +
65187 +void
65188 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65189 +{
65190 + return;
65191 +}
65192 +
65193 +void
65194 +gr_handle_crash(struct task_struct *task, const int sig)
65195 +{
65196 + return;
65197 +}
65198 +
65199 +int
65200 +gr_check_crash_exec(const struct file *filp)
65201 +{
65202 + return 0;
65203 +}
65204 +
65205 +int
65206 +gr_check_crash_uid(const kuid_t uid)
65207 +{
65208 + return 0;
65209 +}
65210 +
65211 +void
65212 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65213 + struct dentry *old_dentry,
65214 + struct dentry *new_dentry,
65215 + struct vfsmount *mnt, const __u8 replace)
65216 +{
65217 + return;
65218 +}
65219 +
65220 +int
65221 +gr_search_socket(const int family, const int type, const int protocol)
65222 +{
65223 + return 1;
65224 +}
65225 +
65226 +int
65227 +gr_search_connectbind(const int mode, const struct socket *sock,
65228 + const struct sockaddr_in *addr)
65229 +{
65230 + return 0;
65231 +}
65232 +
65233 +void
65234 +gr_handle_alertkill(struct task_struct *task)
65235 +{
65236 + return;
65237 +}
65238 +
65239 +__u32
65240 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
65241 +{
65242 + return 1;
65243 +}
65244 +
65245 +__u32
65246 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65247 + const struct vfsmount * mnt)
65248 +{
65249 + return 1;
65250 +}
65251 +
65252 +__u32
65253 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65254 + int acc_mode)
65255 +{
65256 + return 1;
65257 +}
65258 +
65259 +__u32
65260 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
65261 +{
65262 + return 1;
65263 +}
65264 +
65265 +__u32
65266 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
65267 +{
65268 + return 1;
65269 +}
65270 +
65271 +int
65272 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
65273 + unsigned int *vm_flags)
65274 +{
65275 + return 1;
65276 +}
65277 +
65278 +__u32
65279 +gr_acl_handle_truncate(const struct dentry * dentry,
65280 + const struct vfsmount * mnt)
65281 +{
65282 + return 1;
65283 +}
65284 +
65285 +__u32
65286 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
65287 +{
65288 + return 1;
65289 +}
65290 +
65291 +__u32
65292 +gr_acl_handle_access(const struct dentry * dentry,
65293 + const struct vfsmount * mnt, const int fmode)
65294 +{
65295 + return 1;
65296 +}
65297 +
65298 +__u32
65299 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
65300 + umode_t *mode)
65301 +{
65302 + return 1;
65303 +}
65304 +
65305 +__u32
65306 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
65307 +{
65308 + return 1;
65309 +}
65310 +
65311 +__u32
65312 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
65313 +{
65314 + return 1;
65315 +}
65316 +
65317 +void
65318 +grsecurity_init(void)
65319 +{
65320 + return;
65321 +}
65322 +
65323 +umode_t gr_acl_umask(void)
65324 +{
65325 + return 0;
65326 +}
65327 +
65328 +__u32
65329 +gr_acl_handle_mknod(const struct dentry * new_dentry,
65330 + const struct dentry * parent_dentry,
65331 + const struct vfsmount * parent_mnt,
65332 + const int mode)
65333 +{
65334 + return 1;
65335 +}
65336 +
65337 +__u32
65338 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
65339 + const struct dentry * parent_dentry,
65340 + const struct vfsmount * parent_mnt)
65341 +{
65342 + return 1;
65343 +}
65344 +
65345 +__u32
65346 +gr_acl_handle_symlink(const struct dentry * new_dentry,
65347 + const struct dentry * parent_dentry,
65348 + const struct vfsmount * parent_mnt, const struct filename *from)
65349 +{
65350 + return 1;
65351 +}
65352 +
65353 +__u32
65354 +gr_acl_handle_link(const struct dentry * new_dentry,
65355 + const struct dentry * parent_dentry,
65356 + const struct vfsmount * parent_mnt,
65357 + const struct dentry * old_dentry,
65358 + const struct vfsmount * old_mnt, const struct filename *to)
65359 +{
65360 + return 1;
65361 +}
65362 +
65363 +int
65364 +gr_acl_handle_rename(const struct dentry *new_dentry,
65365 + const struct dentry *parent_dentry,
65366 + const struct vfsmount *parent_mnt,
65367 + const struct dentry *old_dentry,
65368 + const struct inode *old_parent_inode,
65369 + const struct vfsmount *old_mnt, const struct filename *newname)
65370 +{
65371 + return 0;
65372 +}
65373 +
65374 +int
65375 +gr_acl_handle_filldir(const struct file *file, const char *name,
65376 + const int namelen, const ino_t ino)
65377 +{
65378 + return 1;
65379 +}
65380 +
65381 +int
65382 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
65383 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
65384 +{
65385 + return 1;
65386 +}
65387 +
65388 +int
65389 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
65390 +{
65391 + return 0;
65392 +}
65393 +
65394 +int
65395 +gr_search_accept(const struct socket *sock)
65396 +{
65397 + return 0;
65398 +}
65399 +
65400 +int
65401 +gr_search_listen(const struct socket *sock)
65402 +{
65403 + return 0;
65404 +}
65405 +
65406 +int
65407 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
65408 +{
65409 + return 0;
65410 +}
65411 +
65412 +__u32
65413 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
65414 +{
65415 + return 1;
65416 +}
65417 +
65418 +__u32
65419 +gr_acl_handle_creat(const struct dentry * dentry,
65420 + const struct dentry * p_dentry,
65421 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
65422 + const int imode)
65423 +{
65424 + return 1;
65425 +}
65426 +
65427 +void
65428 +gr_acl_handle_exit(void)
65429 +{
65430 + return;
65431 +}
65432 +
65433 +int
65434 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65435 +{
65436 + return 1;
65437 +}
65438 +
65439 +void
65440 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
65441 +{
65442 + return;
65443 +}
65444 +
65445 +int
65446 +gr_acl_handle_procpidmem(const struct task_struct *task)
65447 +{
65448 + return 0;
65449 +}
65450 +
65451 +int
65452 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
65453 +{
65454 + return 0;
65455 +}
65456 +
65457 +int
65458 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
65459 +{
65460 + return 0;
65461 +}
65462 +
65463 +void
65464 +gr_set_kernel_label(struct task_struct *task)
65465 +{
65466 + return;
65467 +}
65468 +
65469 +int
65470 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
65471 +{
65472 + return 0;
65473 +}
65474 +
65475 +int
65476 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
65477 +{
65478 + return 0;
65479 +}
65480 +
65481 +int gr_acl_enable_at_secure(void)
65482 +{
65483 + return 0;
65484 +}
65485 +
65486 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
65487 +{
65488 + return dentry->d_sb->s_dev;
65489 +}
65490 +
65491 +void gr_put_exec_file(struct task_struct *task)
65492 +{
65493 + return;
65494 +}
65495 +
65496 +EXPORT_SYMBOL(gr_set_kernel_label);
65497 +#ifdef CONFIG_SECURITY
65498 +EXPORT_SYMBOL(gr_check_user_change);
65499 +EXPORT_SYMBOL(gr_check_group_change);
65500 +#endif
65501 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
65502 new file mode 100644
65503 index 0000000..387032b
65504 --- /dev/null
65505 +++ b/grsecurity/grsec_exec.c
65506 @@ -0,0 +1,187 @@
65507 +#include <linux/kernel.h>
65508 +#include <linux/sched.h>
65509 +#include <linux/file.h>
65510 +#include <linux/binfmts.h>
65511 +#include <linux/fs.h>
65512 +#include <linux/types.h>
65513 +#include <linux/grdefs.h>
65514 +#include <linux/grsecurity.h>
65515 +#include <linux/grinternal.h>
65516 +#include <linux/capability.h>
65517 +#include <linux/module.h>
65518 +#include <linux/compat.h>
65519 +
65520 +#include <asm/uaccess.h>
65521 +
65522 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65523 +static char gr_exec_arg_buf[132];
65524 +static DEFINE_MUTEX(gr_exec_arg_mutex);
65525 +#endif
65526 +
65527 +struct user_arg_ptr {
65528 +#ifdef CONFIG_COMPAT
65529 + bool is_compat;
65530 +#endif
65531 + union {
65532 + const char __user *const __user *native;
65533 +#ifdef CONFIG_COMPAT
65534 + const compat_uptr_t __user *compat;
65535 +#endif
65536 + } ptr;
65537 +};
65538 +
65539 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
65540 +
65541 +void
65542 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
65543 +{
65544 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65545 + char *grarg = gr_exec_arg_buf;
65546 + unsigned int i, x, execlen = 0;
65547 + char c;
65548 +
65549 + if (!((grsec_enable_execlog && grsec_enable_group &&
65550 + in_group_p(grsec_audit_gid))
65551 + || (grsec_enable_execlog && !grsec_enable_group)))
65552 + return;
65553 +
65554 + mutex_lock(&gr_exec_arg_mutex);
65555 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
65556 +
65557 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
65558 + const char __user *p;
65559 + unsigned int len;
65560 +
65561 + p = get_user_arg_ptr(argv, i);
65562 + if (IS_ERR(p))
65563 + goto log;
65564 +
65565 + len = strnlen_user(p, 128 - execlen);
65566 + if (len > 128 - execlen)
65567 + len = 128 - execlen;
65568 + else if (len > 0)
65569 + len--;
65570 + if (copy_from_user(grarg + execlen, p, len))
65571 + goto log;
65572 +
65573 + /* rewrite unprintable characters */
65574 + for (x = 0; x < len; x++) {
65575 + c = *(grarg + execlen + x);
65576 + if (c < 32 || c > 126)
65577 + *(grarg + execlen + x) = ' ';
65578 + }
65579 +
65580 + execlen += len;
65581 + *(grarg + execlen) = ' ';
65582 + *(grarg + execlen + 1) = '\0';
65583 + execlen++;
65584 + }
65585 +
65586 + log:
65587 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
65588 + bprm->file->f_path.mnt, grarg);
65589 + mutex_unlock(&gr_exec_arg_mutex);
65590 +#endif
65591 + return;
65592 +}
65593 +
65594 +#ifdef CONFIG_GRKERNSEC
65595 +extern int gr_acl_is_capable(const int cap);
65596 +extern int gr_acl_is_capable_nolog(const int cap);
65597 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65598 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
65599 +extern int gr_chroot_is_capable(const int cap);
65600 +extern int gr_chroot_is_capable_nolog(const int cap);
65601 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65602 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
65603 +#endif
65604 +
65605 +const char *captab_log[] = {
65606 + "CAP_CHOWN",
65607 + "CAP_DAC_OVERRIDE",
65608 + "CAP_DAC_READ_SEARCH",
65609 + "CAP_FOWNER",
65610 + "CAP_FSETID",
65611 + "CAP_KILL",
65612 + "CAP_SETGID",
65613 + "CAP_SETUID",
65614 + "CAP_SETPCAP",
65615 + "CAP_LINUX_IMMUTABLE",
65616 + "CAP_NET_BIND_SERVICE",
65617 + "CAP_NET_BROADCAST",
65618 + "CAP_NET_ADMIN",
65619 + "CAP_NET_RAW",
65620 + "CAP_IPC_LOCK",
65621 + "CAP_IPC_OWNER",
65622 + "CAP_SYS_MODULE",
65623 + "CAP_SYS_RAWIO",
65624 + "CAP_SYS_CHROOT",
65625 + "CAP_SYS_PTRACE",
65626 + "CAP_SYS_PACCT",
65627 + "CAP_SYS_ADMIN",
65628 + "CAP_SYS_BOOT",
65629 + "CAP_SYS_NICE",
65630 + "CAP_SYS_RESOURCE",
65631 + "CAP_SYS_TIME",
65632 + "CAP_SYS_TTY_CONFIG",
65633 + "CAP_MKNOD",
65634 + "CAP_LEASE",
65635 + "CAP_AUDIT_WRITE",
65636 + "CAP_AUDIT_CONTROL",
65637 + "CAP_SETFCAP",
65638 + "CAP_MAC_OVERRIDE",
65639 + "CAP_MAC_ADMIN",
65640 + "CAP_SYSLOG",
65641 + "CAP_WAKE_ALARM"
65642 +};
65643 +
65644 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
65645 +
65646 +int gr_is_capable(const int cap)
65647 +{
65648 +#ifdef CONFIG_GRKERNSEC
65649 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
65650 + return 1;
65651 + return 0;
65652 +#else
65653 + return 1;
65654 +#endif
65655 +}
65656 +
65657 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65658 +{
65659 +#ifdef CONFIG_GRKERNSEC
65660 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
65661 + return 1;
65662 + return 0;
65663 +#else
65664 + return 1;
65665 +#endif
65666 +}
65667 +
65668 +int gr_is_capable_nolog(const int cap)
65669 +{
65670 +#ifdef CONFIG_GRKERNSEC
65671 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
65672 + return 1;
65673 + return 0;
65674 +#else
65675 + return 1;
65676 +#endif
65677 +}
65678 +
65679 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
65680 +{
65681 +#ifdef CONFIG_GRKERNSEC
65682 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
65683 + return 1;
65684 + return 0;
65685 +#else
65686 + return 1;
65687 +#endif
65688 +}
65689 +
65690 +EXPORT_SYMBOL(gr_is_capable);
65691 +EXPORT_SYMBOL(gr_is_capable_nolog);
65692 +EXPORT_SYMBOL(gr_task_is_capable);
65693 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
65694 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
65695 new file mode 100644
65696 index 0000000..06cc6ea
65697 --- /dev/null
65698 +++ b/grsecurity/grsec_fifo.c
65699 @@ -0,0 +1,24 @@
65700 +#include <linux/kernel.h>
65701 +#include <linux/sched.h>
65702 +#include <linux/fs.h>
65703 +#include <linux/file.h>
65704 +#include <linux/grinternal.h>
65705 +
65706 +int
65707 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65708 + const struct dentry *dir, const int flag, const int acc_mode)
65709 +{
65710 +#ifdef CONFIG_GRKERNSEC_FIFO
65711 + const struct cred *cred = current_cred();
65712 +
65713 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65714 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65715 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65716 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65717 + if (!inode_permission(dentry->d_inode, acc_mode))
65718 + 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));
65719 + return -EACCES;
65720 + }
65721 +#endif
65722 + return 0;
65723 +}
65724 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65725 new file mode 100644
65726 index 0000000..8ca18bf
65727 --- /dev/null
65728 +++ b/grsecurity/grsec_fork.c
65729 @@ -0,0 +1,23 @@
65730 +#include <linux/kernel.h>
65731 +#include <linux/sched.h>
65732 +#include <linux/grsecurity.h>
65733 +#include <linux/grinternal.h>
65734 +#include <linux/errno.h>
65735 +
65736 +void
65737 +gr_log_forkfail(const int retval)
65738 +{
65739 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65740 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65741 + switch (retval) {
65742 + case -EAGAIN:
65743 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65744 + break;
65745 + case -ENOMEM:
65746 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65747 + break;
65748 + }
65749 + }
65750 +#endif
65751 + return;
65752 +}
65753 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65754 new file mode 100644
65755 index 0000000..ab2d875
65756 --- /dev/null
65757 +++ b/grsecurity/grsec_init.c
65758 @@ -0,0 +1,279 @@
65759 +#include <linux/kernel.h>
65760 +#include <linux/sched.h>
65761 +#include <linux/mm.h>
65762 +#include <linux/gracl.h>
65763 +#include <linux/slab.h>
65764 +#include <linux/vmalloc.h>
65765 +#include <linux/percpu.h>
65766 +#include <linux/module.h>
65767 +
65768 +int grsec_enable_ptrace_readexec;
65769 +int grsec_enable_setxid;
65770 +int grsec_enable_symlinkown;
65771 +kgid_t grsec_symlinkown_gid;
65772 +int grsec_enable_brute;
65773 +int grsec_enable_link;
65774 +int grsec_enable_dmesg;
65775 +int grsec_enable_harden_ptrace;
65776 +int grsec_enable_fifo;
65777 +int grsec_enable_execlog;
65778 +int grsec_enable_signal;
65779 +int grsec_enable_forkfail;
65780 +int grsec_enable_audit_ptrace;
65781 +int grsec_enable_time;
65782 +int grsec_enable_group;
65783 +kgid_t grsec_audit_gid;
65784 +int grsec_enable_chdir;
65785 +int grsec_enable_mount;
65786 +int grsec_enable_rofs;
65787 +int grsec_enable_chroot_findtask;
65788 +int grsec_enable_chroot_mount;
65789 +int grsec_enable_chroot_shmat;
65790 +int grsec_enable_chroot_fchdir;
65791 +int grsec_enable_chroot_double;
65792 +int grsec_enable_chroot_pivot;
65793 +int grsec_enable_chroot_chdir;
65794 +int grsec_enable_chroot_chmod;
65795 +int grsec_enable_chroot_mknod;
65796 +int grsec_enable_chroot_nice;
65797 +int grsec_enable_chroot_execlog;
65798 +int grsec_enable_chroot_caps;
65799 +int grsec_enable_chroot_sysctl;
65800 +int grsec_enable_chroot_unix;
65801 +int grsec_enable_tpe;
65802 +kgid_t grsec_tpe_gid;
65803 +int grsec_enable_blackhole;
65804 +#ifdef CONFIG_IPV6_MODULE
65805 +EXPORT_SYMBOL(grsec_enable_blackhole);
65806 +#endif
65807 +int grsec_lastack_retries;
65808 +int grsec_enable_tpe_all;
65809 +int grsec_enable_tpe_invert;
65810 +int grsec_enable_socket_all;
65811 +kgid_t grsec_socket_all_gid;
65812 +int grsec_enable_socket_client;
65813 +kgid_t grsec_socket_client_gid;
65814 +int grsec_enable_socket_server;
65815 +kgid_t grsec_socket_server_gid;
65816 +int grsec_resource_logging;
65817 +int grsec_disable_privio;
65818 +int grsec_enable_log_rwxmaps;
65819 +int grsec_lock;
65820 +
65821 +DEFINE_SPINLOCK(grsec_alert_lock);
65822 +unsigned long grsec_alert_wtime = 0;
65823 +unsigned long grsec_alert_fyet = 0;
65824 +
65825 +DEFINE_SPINLOCK(grsec_audit_lock);
65826 +
65827 +DEFINE_RWLOCK(grsec_exec_file_lock);
65828 +
65829 +char *gr_shared_page[4];
65830 +
65831 +char *gr_alert_log_fmt;
65832 +char *gr_audit_log_fmt;
65833 +char *gr_alert_log_buf;
65834 +char *gr_audit_log_buf;
65835 +
65836 +extern struct gr_arg *gr_usermode;
65837 +extern unsigned char *gr_system_salt;
65838 +extern unsigned char *gr_system_sum;
65839 +
65840 +void __init
65841 +grsecurity_init(void)
65842 +{
65843 + int j;
65844 + /* create the per-cpu shared pages */
65845 +
65846 +#ifdef CONFIG_X86
65847 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65848 +#endif
65849 +
65850 + for (j = 0; j < 4; j++) {
65851 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65852 + if (gr_shared_page[j] == NULL) {
65853 + panic("Unable to allocate grsecurity shared page");
65854 + return;
65855 + }
65856 + }
65857 +
65858 + /* allocate log buffers */
65859 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65860 + if (!gr_alert_log_fmt) {
65861 + panic("Unable to allocate grsecurity alert log format buffer");
65862 + return;
65863 + }
65864 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65865 + if (!gr_audit_log_fmt) {
65866 + panic("Unable to allocate grsecurity audit log format buffer");
65867 + return;
65868 + }
65869 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65870 + if (!gr_alert_log_buf) {
65871 + panic("Unable to allocate grsecurity alert log buffer");
65872 + return;
65873 + }
65874 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65875 + if (!gr_audit_log_buf) {
65876 + panic("Unable to allocate grsecurity audit log buffer");
65877 + return;
65878 + }
65879 +
65880 + /* allocate memory for authentication structure */
65881 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65882 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65883 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65884 +
65885 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65886 + panic("Unable to allocate grsecurity authentication structure");
65887 + return;
65888 + }
65889 +
65890 +
65891 +#ifdef CONFIG_GRKERNSEC_IO
65892 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65893 + grsec_disable_privio = 1;
65894 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65895 + grsec_disable_privio = 1;
65896 +#else
65897 + grsec_disable_privio = 0;
65898 +#endif
65899 +#endif
65900 +
65901 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65902 + /* for backward compatibility, tpe_invert always defaults to on if
65903 + enabled in the kernel
65904 + */
65905 + grsec_enable_tpe_invert = 1;
65906 +#endif
65907 +
65908 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65909 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65910 + grsec_lock = 1;
65911 +#endif
65912 +
65913 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65914 + grsec_enable_log_rwxmaps = 1;
65915 +#endif
65916 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65917 + grsec_enable_group = 1;
65918 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65919 +#endif
65920 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65921 + grsec_enable_ptrace_readexec = 1;
65922 +#endif
65923 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65924 + grsec_enable_chdir = 1;
65925 +#endif
65926 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65927 + grsec_enable_harden_ptrace = 1;
65928 +#endif
65929 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65930 + grsec_enable_mount = 1;
65931 +#endif
65932 +#ifdef CONFIG_GRKERNSEC_LINK
65933 + grsec_enable_link = 1;
65934 +#endif
65935 +#ifdef CONFIG_GRKERNSEC_BRUTE
65936 + grsec_enable_brute = 1;
65937 +#endif
65938 +#ifdef CONFIG_GRKERNSEC_DMESG
65939 + grsec_enable_dmesg = 1;
65940 +#endif
65941 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65942 + grsec_enable_blackhole = 1;
65943 + grsec_lastack_retries = 4;
65944 +#endif
65945 +#ifdef CONFIG_GRKERNSEC_FIFO
65946 + grsec_enable_fifo = 1;
65947 +#endif
65948 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65949 + grsec_enable_execlog = 1;
65950 +#endif
65951 +#ifdef CONFIG_GRKERNSEC_SETXID
65952 + grsec_enable_setxid = 1;
65953 +#endif
65954 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65955 + grsec_enable_signal = 1;
65956 +#endif
65957 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65958 + grsec_enable_forkfail = 1;
65959 +#endif
65960 +#ifdef CONFIG_GRKERNSEC_TIME
65961 + grsec_enable_time = 1;
65962 +#endif
65963 +#ifdef CONFIG_GRKERNSEC_RESLOG
65964 + grsec_resource_logging = 1;
65965 +#endif
65966 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65967 + grsec_enable_chroot_findtask = 1;
65968 +#endif
65969 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65970 + grsec_enable_chroot_unix = 1;
65971 +#endif
65972 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65973 + grsec_enable_chroot_mount = 1;
65974 +#endif
65975 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65976 + grsec_enable_chroot_fchdir = 1;
65977 +#endif
65978 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65979 + grsec_enable_chroot_shmat = 1;
65980 +#endif
65981 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65982 + grsec_enable_audit_ptrace = 1;
65983 +#endif
65984 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65985 + grsec_enable_chroot_double = 1;
65986 +#endif
65987 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65988 + grsec_enable_chroot_pivot = 1;
65989 +#endif
65990 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65991 + grsec_enable_chroot_chdir = 1;
65992 +#endif
65993 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65994 + grsec_enable_chroot_chmod = 1;
65995 +#endif
65996 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65997 + grsec_enable_chroot_mknod = 1;
65998 +#endif
65999 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66000 + grsec_enable_chroot_nice = 1;
66001 +#endif
66002 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66003 + grsec_enable_chroot_execlog = 1;
66004 +#endif
66005 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66006 + grsec_enable_chroot_caps = 1;
66007 +#endif
66008 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66009 + grsec_enable_chroot_sysctl = 1;
66010 +#endif
66011 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66012 + grsec_enable_symlinkown = 1;
66013 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
66014 +#endif
66015 +#ifdef CONFIG_GRKERNSEC_TPE
66016 + grsec_enable_tpe = 1;
66017 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
66018 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66019 + grsec_enable_tpe_all = 1;
66020 +#endif
66021 +#endif
66022 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66023 + grsec_enable_socket_all = 1;
66024 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
66025 +#endif
66026 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66027 + grsec_enable_socket_client = 1;
66028 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
66029 +#endif
66030 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66031 + grsec_enable_socket_server = 1;
66032 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
66033 +#endif
66034 +#endif
66035 +
66036 + return;
66037 +}
66038 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
66039 new file mode 100644
66040 index 0000000..5e05e20
66041 --- /dev/null
66042 +++ b/grsecurity/grsec_link.c
66043 @@ -0,0 +1,58 @@
66044 +#include <linux/kernel.h>
66045 +#include <linux/sched.h>
66046 +#include <linux/fs.h>
66047 +#include <linux/file.h>
66048 +#include <linux/grinternal.h>
66049 +
66050 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
66051 +{
66052 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66053 + const struct inode *link_inode = link->dentry->d_inode;
66054 +
66055 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
66056 + /* ignore root-owned links, e.g. /proc/self */
66057 + gr_is_global_nonroot(link_inode->i_uid) && target &&
66058 + !uid_eq(link_inode->i_uid, target->i_uid)) {
66059 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
66060 + return 1;
66061 + }
66062 +#endif
66063 + return 0;
66064 +}
66065 +
66066 +int
66067 +gr_handle_follow_link(const struct inode *parent,
66068 + const struct inode *inode,
66069 + const struct dentry *dentry, const struct vfsmount *mnt)
66070 +{
66071 +#ifdef CONFIG_GRKERNSEC_LINK
66072 + const struct cred *cred = current_cred();
66073 +
66074 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
66075 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
66076 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
66077 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
66078 + return -EACCES;
66079 + }
66080 +#endif
66081 + return 0;
66082 +}
66083 +
66084 +int
66085 +gr_handle_hardlink(const struct dentry *dentry,
66086 + const struct vfsmount *mnt,
66087 + struct inode *inode, const int mode, const struct filename *to)
66088 +{
66089 +#ifdef CONFIG_GRKERNSEC_LINK
66090 + const struct cred *cred = current_cred();
66091 +
66092 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
66093 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
66094 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
66095 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
66096 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
66097 + return -EPERM;
66098 + }
66099 +#endif
66100 + return 0;
66101 +}
66102 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
66103 new file mode 100644
66104 index 0000000..dbe0a6b
66105 --- /dev/null
66106 +++ b/grsecurity/grsec_log.c
66107 @@ -0,0 +1,341 @@
66108 +#include <linux/kernel.h>
66109 +#include <linux/sched.h>
66110 +#include <linux/file.h>
66111 +#include <linux/tty.h>
66112 +#include <linux/fs.h>
66113 +#include <linux/mm.h>
66114 +#include <linux/grinternal.h>
66115 +
66116 +#ifdef CONFIG_TREE_PREEMPT_RCU
66117 +#define DISABLE_PREEMPT() preempt_disable()
66118 +#define ENABLE_PREEMPT() preempt_enable()
66119 +#else
66120 +#define DISABLE_PREEMPT()
66121 +#define ENABLE_PREEMPT()
66122 +#endif
66123 +
66124 +#define BEGIN_LOCKS(x) \
66125 + DISABLE_PREEMPT(); \
66126 + rcu_read_lock(); \
66127 + read_lock(&tasklist_lock); \
66128 + read_lock(&grsec_exec_file_lock); \
66129 + if (x != GR_DO_AUDIT) \
66130 + spin_lock(&grsec_alert_lock); \
66131 + else \
66132 + spin_lock(&grsec_audit_lock)
66133 +
66134 +#define END_LOCKS(x) \
66135 + if (x != GR_DO_AUDIT) \
66136 + spin_unlock(&grsec_alert_lock); \
66137 + else \
66138 + spin_unlock(&grsec_audit_lock); \
66139 + read_unlock(&grsec_exec_file_lock); \
66140 + read_unlock(&tasklist_lock); \
66141 + rcu_read_unlock(); \
66142 + ENABLE_PREEMPT(); \
66143 + if (x == GR_DONT_AUDIT) \
66144 + gr_handle_alertkill(current)
66145 +
66146 +enum {
66147 + FLOODING,
66148 + NO_FLOODING
66149 +};
66150 +
66151 +extern char *gr_alert_log_fmt;
66152 +extern char *gr_audit_log_fmt;
66153 +extern char *gr_alert_log_buf;
66154 +extern char *gr_audit_log_buf;
66155 +
66156 +static int gr_log_start(int audit)
66157 +{
66158 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
66159 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
66160 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66161 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
66162 + unsigned long curr_secs = get_seconds();
66163 +
66164 + if (audit == GR_DO_AUDIT)
66165 + goto set_fmt;
66166 +
66167 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
66168 + grsec_alert_wtime = curr_secs;
66169 + grsec_alert_fyet = 0;
66170 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
66171 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
66172 + grsec_alert_fyet++;
66173 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
66174 + grsec_alert_wtime = curr_secs;
66175 + grsec_alert_fyet++;
66176 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
66177 + return FLOODING;
66178 + }
66179 + else return FLOODING;
66180 +
66181 +set_fmt:
66182 +#endif
66183 + memset(buf, 0, PAGE_SIZE);
66184 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
66185 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
66186 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
66187 + } else if (current->signal->curr_ip) {
66188 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
66189 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
66190 + } else if (gr_acl_is_enabled()) {
66191 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
66192 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
66193 + } else {
66194 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
66195 + strcpy(buf, fmt);
66196 + }
66197 +
66198 + return NO_FLOODING;
66199 +}
66200 +
66201 +static void gr_log_middle(int audit, const char *msg, va_list ap)
66202 + __attribute__ ((format (printf, 2, 0)));
66203 +
66204 +static void gr_log_middle(int audit, const char *msg, va_list ap)
66205 +{
66206 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66207 + unsigned int len = strlen(buf);
66208 +
66209 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
66210 +
66211 + return;
66212 +}
66213 +
66214 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
66215 + __attribute__ ((format (printf, 2, 3)));
66216 +
66217 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
66218 +{
66219 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66220 + unsigned int len = strlen(buf);
66221 + va_list ap;
66222 +
66223 + va_start(ap, msg);
66224 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
66225 + va_end(ap);
66226 +
66227 + return;
66228 +}
66229 +
66230 +static void gr_log_end(int audit, int append_default)
66231 +{
66232 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66233 + if (append_default) {
66234 + struct task_struct *task = current;
66235 + struct task_struct *parent = task->real_parent;
66236 + const struct cred *cred = __task_cred(task);
66237 + const struct cred *pcred = __task_cred(parent);
66238 + unsigned int len = strlen(buf);
66239 +
66240 + 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));
66241 + }
66242 +
66243 + printk("%s\n", buf);
66244 +
66245 + return;
66246 +}
66247 +
66248 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
66249 +{
66250 + int logtype;
66251 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
66252 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
66253 + void *voidptr = NULL;
66254 + int num1 = 0, num2 = 0;
66255 + unsigned long ulong1 = 0, ulong2 = 0;
66256 + struct dentry *dentry = NULL;
66257 + struct vfsmount *mnt = NULL;
66258 + struct file *file = NULL;
66259 + struct task_struct *task = NULL;
66260 + struct vm_area_struct *vma = NULL;
66261 + const struct cred *cred, *pcred;
66262 + va_list ap;
66263 +
66264 + BEGIN_LOCKS(audit);
66265 + logtype = gr_log_start(audit);
66266 + if (logtype == FLOODING) {
66267 + END_LOCKS(audit);
66268 + return;
66269 + }
66270 + va_start(ap, argtypes);
66271 + switch (argtypes) {
66272 + case GR_TTYSNIFF:
66273 + task = va_arg(ap, struct task_struct *);
66274 + 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));
66275 + break;
66276 + case GR_SYSCTL_HIDDEN:
66277 + str1 = va_arg(ap, char *);
66278 + gr_log_middle_varargs(audit, msg, result, str1);
66279 + break;
66280 + case GR_RBAC:
66281 + dentry = va_arg(ap, struct dentry *);
66282 + mnt = va_arg(ap, struct vfsmount *);
66283 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
66284 + break;
66285 + case GR_RBAC_STR:
66286 + dentry = va_arg(ap, struct dentry *);
66287 + mnt = va_arg(ap, struct vfsmount *);
66288 + str1 = va_arg(ap, char *);
66289 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
66290 + break;
66291 + case GR_STR_RBAC:
66292 + str1 = va_arg(ap, char *);
66293 + dentry = va_arg(ap, struct dentry *);
66294 + mnt = va_arg(ap, struct vfsmount *);
66295 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
66296 + break;
66297 + case GR_RBAC_MODE2:
66298 + dentry = va_arg(ap, struct dentry *);
66299 + mnt = va_arg(ap, struct vfsmount *);
66300 + str1 = va_arg(ap, char *);
66301 + str2 = va_arg(ap, char *);
66302 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
66303 + break;
66304 + case GR_RBAC_MODE3:
66305 + dentry = va_arg(ap, struct dentry *);
66306 + mnt = va_arg(ap, struct vfsmount *);
66307 + str1 = va_arg(ap, char *);
66308 + str2 = va_arg(ap, char *);
66309 + str3 = va_arg(ap, char *);
66310 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
66311 + break;
66312 + case GR_FILENAME:
66313 + dentry = va_arg(ap, struct dentry *);
66314 + mnt = va_arg(ap, struct vfsmount *);
66315 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
66316 + break;
66317 + case GR_STR_FILENAME:
66318 + str1 = va_arg(ap, char *);
66319 + dentry = va_arg(ap, struct dentry *);
66320 + mnt = va_arg(ap, struct vfsmount *);
66321 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
66322 + break;
66323 + case GR_FILENAME_STR:
66324 + dentry = va_arg(ap, struct dentry *);
66325 + mnt = va_arg(ap, struct vfsmount *);
66326 + str1 = va_arg(ap, char *);
66327 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
66328 + break;
66329 + case GR_FILENAME_TWO_INT:
66330 + dentry = va_arg(ap, struct dentry *);
66331 + mnt = va_arg(ap, struct vfsmount *);
66332 + num1 = va_arg(ap, int);
66333 + num2 = va_arg(ap, int);
66334 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
66335 + break;
66336 + case GR_FILENAME_TWO_INT_STR:
66337 + dentry = va_arg(ap, struct dentry *);
66338 + mnt = va_arg(ap, struct vfsmount *);
66339 + num1 = va_arg(ap, int);
66340 + num2 = va_arg(ap, int);
66341 + str1 = va_arg(ap, char *);
66342 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
66343 + break;
66344 + case GR_TEXTREL:
66345 + file = va_arg(ap, struct file *);
66346 + ulong1 = va_arg(ap, unsigned long);
66347 + ulong2 = va_arg(ap, unsigned long);
66348 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
66349 + break;
66350 + case GR_PTRACE:
66351 + task = va_arg(ap, struct task_struct *);
66352 + 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));
66353 + break;
66354 + case GR_RESOURCE:
66355 + task = va_arg(ap, struct task_struct *);
66356 + cred = __task_cred(task);
66357 + pcred = __task_cred(task->real_parent);
66358 + ulong1 = va_arg(ap, unsigned long);
66359 + str1 = va_arg(ap, char *);
66360 + ulong2 = va_arg(ap, unsigned long);
66361 + 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));
66362 + break;
66363 + case GR_CAP:
66364 + task = va_arg(ap, struct task_struct *);
66365 + cred = __task_cred(task);
66366 + pcred = __task_cred(task->real_parent);
66367 + str1 = va_arg(ap, char *);
66368 + 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));
66369 + break;
66370 + case GR_SIG:
66371 + str1 = va_arg(ap, char *);
66372 + voidptr = va_arg(ap, void *);
66373 + gr_log_middle_varargs(audit, msg, str1, voidptr);
66374 + break;
66375 + case GR_SIG2:
66376 + task = va_arg(ap, struct task_struct *);
66377 + cred = __task_cred(task);
66378 + pcred = __task_cred(task->real_parent);
66379 + num1 = va_arg(ap, int);
66380 + 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));
66381 + break;
66382 + case GR_CRASH1:
66383 + task = va_arg(ap, struct task_struct *);
66384 + cred = __task_cred(task);
66385 + pcred = __task_cred(task->real_parent);
66386 + ulong1 = va_arg(ap, unsigned long);
66387 + 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);
66388 + break;
66389 + case GR_CRASH2:
66390 + task = va_arg(ap, struct task_struct *);
66391 + cred = __task_cred(task);
66392 + pcred = __task_cred(task->real_parent);
66393 + ulong1 = va_arg(ap, unsigned long);
66394 + 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);
66395 + break;
66396 + case GR_RWXMAP:
66397 + file = va_arg(ap, struct file *);
66398 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
66399 + break;
66400 + case GR_RWXMAPVMA:
66401 + vma = va_arg(ap, struct vm_area_struct *);
66402 + if (vma->vm_file)
66403 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
66404 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
66405 + str1 = "<stack>";
66406 + else if (vma->vm_start <= current->mm->brk &&
66407 + vma->vm_end >= current->mm->start_brk)
66408 + str1 = "<heap>";
66409 + else
66410 + str1 = "<anonymous mapping>";
66411 + gr_log_middle_varargs(audit, msg, str1);
66412 + break;
66413 + case GR_PSACCT:
66414 + {
66415 + unsigned int wday, cday;
66416 + __u8 whr, chr;
66417 + __u8 wmin, cmin;
66418 + __u8 wsec, csec;
66419 + char cur_tty[64] = { 0 };
66420 + char parent_tty[64] = { 0 };
66421 +
66422 + task = va_arg(ap, struct task_struct *);
66423 + wday = va_arg(ap, unsigned int);
66424 + cday = va_arg(ap, unsigned int);
66425 + whr = va_arg(ap, int);
66426 + chr = va_arg(ap, int);
66427 + wmin = va_arg(ap, int);
66428 + cmin = va_arg(ap, int);
66429 + wsec = va_arg(ap, int);
66430 + csec = va_arg(ap, int);
66431 + ulong1 = va_arg(ap, unsigned long);
66432 + cred = __task_cred(task);
66433 + pcred = __task_cred(task->real_parent);
66434 +
66435 + 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));
66436 + }
66437 + break;
66438 + default:
66439 + gr_log_middle(audit, msg, ap);
66440 + }
66441 + va_end(ap);
66442 + // these don't need DEFAULTSECARGS printed on the end
66443 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
66444 + gr_log_end(audit, 0);
66445 + else
66446 + gr_log_end(audit, 1);
66447 + END_LOCKS(audit);
66448 +}
66449 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
66450 new file mode 100644
66451 index 0000000..f536303
66452 --- /dev/null
66453 +++ b/grsecurity/grsec_mem.c
66454 @@ -0,0 +1,40 @@
66455 +#include <linux/kernel.h>
66456 +#include <linux/sched.h>
66457 +#include <linux/mm.h>
66458 +#include <linux/mman.h>
66459 +#include <linux/grinternal.h>
66460 +
66461 +void
66462 +gr_handle_ioperm(void)
66463 +{
66464 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
66465 + return;
66466 +}
66467 +
66468 +void
66469 +gr_handle_iopl(void)
66470 +{
66471 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
66472 + return;
66473 +}
66474 +
66475 +void
66476 +gr_handle_mem_readwrite(u64 from, u64 to)
66477 +{
66478 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
66479 + return;
66480 +}
66481 +
66482 +void
66483 +gr_handle_vm86(void)
66484 +{
66485 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
66486 + return;
66487 +}
66488 +
66489 +void
66490 +gr_log_badprocpid(const char *entry)
66491 +{
66492 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
66493 + return;
66494 +}
66495 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
66496 new file mode 100644
66497 index 0000000..2131422
66498 --- /dev/null
66499 +++ b/grsecurity/grsec_mount.c
66500 @@ -0,0 +1,62 @@
66501 +#include <linux/kernel.h>
66502 +#include <linux/sched.h>
66503 +#include <linux/mount.h>
66504 +#include <linux/grsecurity.h>
66505 +#include <linux/grinternal.h>
66506 +
66507 +void
66508 +gr_log_remount(const char *devname, const int retval)
66509 +{
66510 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66511 + if (grsec_enable_mount && (retval >= 0))
66512 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
66513 +#endif
66514 + return;
66515 +}
66516 +
66517 +void
66518 +gr_log_unmount(const char *devname, const int retval)
66519 +{
66520 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66521 + if (grsec_enable_mount && (retval >= 0))
66522 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
66523 +#endif
66524 + return;
66525 +}
66526 +
66527 +void
66528 +gr_log_mount(const char *from, const char *to, const int retval)
66529 +{
66530 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66531 + if (grsec_enable_mount && (retval >= 0))
66532 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
66533 +#endif
66534 + return;
66535 +}
66536 +
66537 +int
66538 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
66539 +{
66540 +#ifdef CONFIG_GRKERNSEC_ROFS
66541 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
66542 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
66543 + return -EPERM;
66544 + } else
66545 + return 0;
66546 +#endif
66547 + return 0;
66548 +}
66549 +
66550 +int
66551 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
66552 +{
66553 +#ifdef CONFIG_GRKERNSEC_ROFS
66554 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
66555 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
66556 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
66557 + return -EPERM;
66558 + } else
66559 + return 0;
66560 +#endif
66561 + return 0;
66562 +}
66563 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
66564 new file mode 100644
66565 index 0000000..6ee9d50
66566 --- /dev/null
66567 +++ b/grsecurity/grsec_pax.c
66568 @@ -0,0 +1,45 @@
66569 +#include <linux/kernel.h>
66570 +#include <linux/sched.h>
66571 +#include <linux/mm.h>
66572 +#include <linux/file.h>
66573 +#include <linux/grinternal.h>
66574 +#include <linux/grsecurity.h>
66575 +
66576 +void
66577 +gr_log_textrel(struct vm_area_struct * vma)
66578 +{
66579 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66580 + if (grsec_enable_log_rwxmaps)
66581 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
66582 +#endif
66583 + return;
66584 +}
66585 +
66586 +void gr_log_ptgnustack(struct file *file)
66587 +{
66588 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66589 + if (grsec_enable_log_rwxmaps)
66590 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
66591 +#endif
66592 + return;
66593 +}
66594 +
66595 +void
66596 +gr_log_rwxmmap(struct file *file)
66597 +{
66598 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66599 + if (grsec_enable_log_rwxmaps)
66600 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
66601 +#endif
66602 + return;
66603 +}
66604 +
66605 +void
66606 +gr_log_rwxmprotect(struct vm_area_struct *vma)
66607 +{
66608 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66609 + if (grsec_enable_log_rwxmaps)
66610 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
66611 +#endif
66612 + return;
66613 +}
66614 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
66615 new file mode 100644
66616 index 0000000..f7f29aa
66617 --- /dev/null
66618 +++ b/grsecurity/grsec_ptrace.c
66619 @@ -0,0 +1,30 @@
66620 +#include <linux/kernel.h>
66621 +#include <linux/sched.h>
66622 +#include <linux/grinternal.h>
66623 +#include <linux/security.h>
66624 +
66625 +void
66626 +gr_audit_ptrace(struct task_struct *task)
66627 +{
66628 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66629 + if (grsec_enable_audit_ptrace)
66630 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
66631 +#endif
66632 + return;
66633 +}
66634 +
66635 +int
66636 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
66637 +{
66638 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66639 + const struct dentry *dentry = file->f_path.dentry;
66640 + const struct vfsmount *mnt = file->f_path.mnt;
66641 +
66642 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
66643 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
66644 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
66645 + return -EACCES;
66646 + }
66647 +#endif
66648 + return 0;
66649 +}
66650 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
66651 new file mode 100644
66652 index 0000000..4e29cc7
66653 --- /dev/null
66654 +++ b/grsecurity/grsec_sig.c
66655 @@ -0,0 +1,246 @@
66656 +#include <linux/kernel.h>
66657 +#include <linux/sched.h>
66658 +#include <linux/fs.h>
66659 +#include <linux/delay.h>
66660 +#include <linux/grsecurity.h>
66661 +#include <linux/grinternal.h>
66662 +#include <linux/hardirq.h>
66663 +
66664 +char *signames[] = {
66665 + [SIGSEGV] = "Segmentation fault",
66666 + [SIGILL] = "Illegal instruction",
66667 + [SIGABRT] = "Abort",
66668 + [SIGBUS] = "Invalid alignment/Bus error"
66669 +};
66670 +
66671 +void
66672 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
66673 +{
66674 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66675 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
66676 + (sig == SIGABRT) || (sig == SIGBUS))) {
66677 + if (task_pid_nr(t) == task_pid_nr(current)) {
66678 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
66679 + } else {
66680 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
66681 + }
66682 + }
66683 +#endif
66684 + return;
66685 +}
66686 +
66687 +int
66688 +gr_handle_signal(const struct task_struct *p, const int sig)
66689 +{
66690 +#ifdef CONFIG_GRKERNSEC
66691 + /* ignore the 0 signal for protected task checks */
66692 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
66693 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
66694 + return -EPERM;
66695 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
66696 + return -EPERM;
66697 + }
66698 +#endif
66699 + return 0;
66700 +}
66701 +
66702 +#ifdef CONFIG_GRKERNSEC
66703 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
66704 +
66705 +int gr_fake_force_sig(int sig, struct task_struct *t)
66706 +{
66707 + unsigned long int flags;
66708 + int ret, blocked, ignored;
66709 + struct k_sigaction *action;
66710 +
66711 + spin_lock_irqsave(&t->sighand->siglock, flags);
66712 + action = &t->sighand->action[sig-1];
66713 + ignored = action->sa.sa_handler == SIG_IGN;
66714 + blocked = sigismember(&t->blocked, sig);
66715 + if (blocked || ignored) {
66716 + action->sa.sa_handler = SIG_DFL;
66717 + if (blocked) {
66718 + sigdelset(&t->blocked, sig);
66719 + recalc_sigpending_and_wake(t);
66720 + }
66721 + }
66722 + if (action->sa.sa_handler == SIG_DFL)
66723 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
66724 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
66725 +
66726 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
66727 +
66728 + return ret;
66729 +}
66730 +#endif
66731 +
66732 +#ifdef CONFIG_GRKERNSEC_BRUTE
66733 +#define GR_USER_BAN_TIME (15 * 60)
66734 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66735 +
66736 +static int __get_dumpable(unsigned long mm_flags)
66737 +{
66738 + int ret;
66739 +
66740 + ret = mm_flags & MMF_DUMPABLE_MASK;
66741 + return (ret >= 2) ? 2 : ret;
66742 +}
66743 +#endif
66744 +
66745 +void gr_handle_brute_attach(unsigned long mm_flags)
66746 +{
66747 +#ifdef CONFIG_GRKERNSEC_BRUTE
66748 + struct task_struct *p = current;
66749 + kuid_t uid = GLOBAL_ROOT_UID;
66750 + int daemon = 0;
66751 +
66752 + if (!grsec_enable_brute)
66753 + return;
66754 +
66755 + rcu_read_lock();
66756 + read_lock(&tasklist_lock);
66757 + read_lock(&grsec_exec_file_lock);
66758 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
66759 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66760 + p->real_parent->brute = 1;
66761 + daemon = 1;
66762 + } else {
66763 + const struct cred *cred = __task_cred(p), *cred2;
66764 + struct task_struct *tsk, *tsk2;
66765 +
66766 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66767 + struct user_struct *user;
66768 +
66769 + uid = cred->uid;
66770 +
66771 + /* this is put upon execution past expiration */
66772 + user = find_user(uid);
66773 + if (user == NULL)
66774 + goto unlock;
66775 + user->suid_banned = 1;
66776 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
66777 + if (user->suid_ban_expires == ~0UL)
66778 + user->suid_ban_expires--;
66779 +
66780 + /* only kill other threads of the same binary, from the same user */
66781 + do_each_thread(tsk2, tsk) {
66782 + cred2 = __task_cred(tsk);
66783 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
66784 + gr_fake_force_sig(SIGKILL, tsk);
66785 + } while_each_thread(tsk2, tsk);
66786 + }
66787 + }
66788 +unlock:
66789 + read_unlock(&grsec_exec_file_lock);
66790 + read_unlock(&tasklist_lock);
66791 + rcu_read_unlock();
66792 +
66793 + if (gr_is_global_nonroot(uid))
66794 + gr_log_fs_int2(GR_DONT_AUDIT, GR_BRUTE_SUID_MSG, p->exec_file->f_path.dentry, p->exec_file->f_path.mnt, GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
66795 + else if (daemon)
66796 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66797 +
66798 +#endif
66799 + return;
66800 +}
66801 +
66802 +void gr_handle_brute_check(void)
66803 +{
66804 +#ifdef CONFIG_GRKERNSEC_BRUTE
66805 + struct task_struct *p = current;
66806 +
66807 + if (unlikely(p->brute)) {
66808 + if (!grsec_enable_brute)
66809 + p->brute = 0;
66810 + else if (time_before(get_seconds(), p->brute_expires))
66811 + msleep(30 * 1000);
66812 + }
66813 +#endif
66814 + return;
66815 +}
66816 +
66817 +void gr_handle_kernel_exploit(void)
66818 +{
66819 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66820 + const struct cred *cred;
66821 + struct task_struct *tsk, *tsk2;
66822 + struct user_struct *user;
66823 + kuid_t uid;
66824 +
66825 + if (in_irq() || in_serving_softirq() || in_nmi())
66826 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66827 +
66828 + uid = current_uid();
66829 +
66830 + if (gr_is_global_root(uid))
66831 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66832 + else {
66833 + /* kill all the processes of this user, hold a reference
66834 + to their creds struct, and prevent them from creating
66835 + another process until system reset
66836 + */
66837 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66838 + GR_GLOBAL_UID(uid));
66839 + /* we intentionally leak this ref */
66840 + user = get_uid(current->cred->user);
66841 + if (user)
66842 + user->kernel_banned = 1;
66843 +
66844 + /* kill all processes of this user */
66845 + read_lock(&tasklist_lock);
66846 + do_each_thread(tsk2, tsk) {
66847 + cred = __task_cred(tsk);
66848 + if (uid_eq(cred->uid, uid))
66849 + gr_fake_force_sig(SIGKILL, tsk);
66850 + } while_each_thread(tsk2, tsk);
66851 + read_unlock(&tasklist_lock);
66852 + }
66853 +#endif
66854 +}
66855 +
66856 +#ifdef CONFIG_GRKERNSEC_BRUTE
66857 +static bool suid_ban_expired(struct user_struct *user)
66858 +{
66859 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
66860 + user->suid_banned = 0;
66861 + user->suid_ban_expires = 0;
66862 + free_uid(user);
66863 + return true;
66864 + }
66865 +
66866 + return false;
66867 +}
66868 +#endif
66869 +
66870 +int gr_process_kernel_exec_ban(void)
66871 +{
66872 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66873 + if (unlikely(current->cred->user->kernel_banned))
66874 + return -EPERM;
66875 +#endif
66876 + return 0;
66877 +}
66878 +
66879 +int gr_process_kernel_setuid_ban(struct user_struct *user)
66880 +{
66881 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66882 + if (unlikely(user->kernel_banned))
66883 + gr_fake_force_sig(SIGKILL, current);
66884 +#endif
66885 + return 0;
66886 +}
66887 +
66888 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
66889 +{
66890 +#ifdef CONFIG_GRKERNSEC_BRUTE
66891 + struct user_struct *user = current->cred->user;
66892 + if (unlikely(user->suid_banned)) {
66893 + if (suid_ban_expired(user))
66894 + return 0;
66895 + /* disallow execution of suid binaries only */
66896 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
66897 + return -EPERM;
66898 + }
66899 +#endif
66900 + return 0;
66901 +}
66902 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66903 new file mode 100644
66904 index 0000000..4030d57
66905 --- /dev/null
66906 +++ b/grsecurity/grsec_sock.c
66907 @@ -0,0 +1,244 @@
66908 +#include <linux/kernel.h>
66909 +#include <linux/module.h>
66910 +#include <linux/sched.h>
66911 +#include <linux/file.h>
66912 +#include <linux/net.h>
66913 +#include <linux/in.h>
66914 +#include <linux/ip.h>
66915 +#include <net/sock.h>
66916 +#include <net/inet_sock.h>
66917 +#include <linux/grsecurity.h>
66918 +#include <linux/grinternal.h>
66919 +#include <linux/gracl.h>
66920 +
66921 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66922 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66923 +
66924 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66925 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66926 +
66927 +#ifdef CONFIG_UNIX_MODULE
66928 +EXPORT_SYMBOL(gr_acl_handle_unix);
66929 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66930 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66931 +EXPORT_SYMBOL(gr_handle_create);
66932 +#endif
66933 +
66934 +#ifdef CONFIG_GRKERNSEC
66935 +#define gr_conn_table_size 32749
66936 +struct conn_table_entry {
66937 + struct conn_table_entry *next;
66938 + struct signal_struct *sig;
66939 +};
66940 +
66941 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66942 +DEFINE_SPINLOCK(gr_conn_table_lock);
66943 +
66944 +extern const char * gr_socktype_to_name(unsigned char type);
66945 +extern const char * gr_proto_to_name(unsigned char proto);
66946 +extern const char * gr_sockfamily_to_name(unsigned char family);
66947 +
66948 +static __inline__ int
66949 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66950 +{
66951 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66952 +}
66953 +
66954 +static __inline__ int
66955 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66956 + __u16 sport, __u16 dport)
66957 +{
66958 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66959 + sig->gr_sport == sport && sig->gr_dport == dport))
66960 + return 1;
66961 + else
66962 + return 0;
66963 +}
66964 +
66965 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66966 +{
66967 + struct conn_table_entry **match;
66968 + unsigned int index;
66969 +
66970 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66971 + sig->gr_sport, sig->gr_dport,
66972 + gr_conn_table_size);
66973 +
66974 + newent->sig = sig;
66975 +
66976 + match = &gr_conn_table[index];
66977 + newent->next = *match;
66978 + *match = newent;
66979 +
66980 + return;
66981 +}
66982 +
66983 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66984 +{
66985 + struct conn_table_entry *match, *last = NULL;
66986 + unsigned int index;
66987 +
66988 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66989 + sig->gr_sport, sig->gr_dport,
66990 + gr_conn_table_size);
66991 +
66992 + match = gr_conn_table[index];
66993 + while (match && !conn_match(match->sig,
66994 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66995 + sig->gr_dport)) {
66996 + last = match;
66997 + match = match->next;
66998 + }
66999 +
67000 + if (match) {
67001 + if (last)
67002 + last->next = match->next;
67003 + else
67004 + gr_conn_table[index] = NULL;
67005 + kfree(match);
67006 + }
67007 +
67008 + return;
67009 +}
67010 +
67011 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
67012 + __u16 sport, __u16 dport)
67013 +{
67014 + struct conn_table_entry *match;
67015 + unsigned int index;
67016 +
67017 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
67018 +
67019 + match = gr_conn_table[index];
67020 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
67021 + match = match->next;
67022 +
67023 + if (match)
67024 + return match->sig;
67025 + else
67026 + return NULL;
67027 +}
67028 +
67029 +#endif
67030 +
67031 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
67032 +{
67033 +#ifdef CONFIG_GRKERNSEC
67034 + struct signal_struct *sig = task->signal;
67035 + struct conn_table_entry *newent;
67036 +
67037 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
67038 + if (newent == NULL)
67039 + return;
67040 + /* no bh lock needed since we are called with bh disabled */
67041 + spin_lock(&gr_conn_table_lock);
67042 + gr_del_task_from_ip_table_nolock(sig);
67043 + sig->gr_saddr = inet->inet_rcv_saddr;
67044 + sig->gr_daddr = inet->inet_daddr;
67045 + sig->gr_sport = inet->inet_sport;
67046 + sig->gr_dport = inet->inet_dport;
67047 + gr_add_to_task_ip_table_nolock(sig, newent);
67048 + spin_unlock(&gr_conn_table_lock);
67049 +#endif
67050 + return;
67051 +}
67052 +
67053 +void gr_del_task_from_ip_table(struct task_struct *task)
67054 +{
67055 +#ifdef CONFIG_GRKERNSEC
67056 + spin_lock_bh(&gr_conn_table_lock);
67057 + gr_del_task_from_ip_table_nolock(task->signal);
67058 + spin_unlock_bh(&gr_conn_table_lock);
67059 +#endif
67060 + return;
67061 +}
67062 +
67063 +void
67064 +gr_attach_curr_ip(const struct sock *sk)
67065 +{
67066 +#ifdef CONFIG_GRKERNSEC
67067 + struct signal_struct *p, *set;
67068 + const struct inet_sock *inet = inet_sk(sk);
67069 +
67070 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
67071 + return;
67072 +
67073 + set = current->signal;
67074 +
67075 + spin_lock_bh(&gr_conn_table_lock);
67076 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
67077 + inet->inet_dport, inet->inet_sport);
67078 + if (unlikely(p != NULL)) {
67079 + set->curr_ip = p->curr_ip;
67080 + set->used_accept = 1;
67081 + gr_del_task_from_ip_table_nolock(p);
67082 + spin_unlock_bh(&gr_conn_table_lock);
67083 + return;
67084 + }
67085 + spin_unlock_bh(&gr_conn_table_lock);
67086 +
67087 + set->curr_ip = inet->inet_daddr;
67088 + set->used_accept = 1;
67089 +#endif
67090 + return;
67091 +}
67092 +
67093 +int
67094 +gr_handle_sock_all(const int family, const int type, const int protocol)
67095 +{
67096 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
67097 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
67098 + (family != AF_UNIX)) {
67099 + if (family == AF_INET)
67100 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
67101 + else
67102 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
67103 + return -EACCES;
67104 + }
67105 +#endif
67106 + return 0;
67107 +}
67108 +
67109 +int
67110 +gr_handle_sock_server(const struct sockaddr *sck)
67111 +{
67112 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
67113 + if (grsec_enable_socket_server &&
67114 + in_group_p(grsec_socket_server_gid) &&
67115 + sck && (sck->sa_family != AF_UNIX) &&
67116 + (sck->sa_family != AF_LOCAL)) {
67117 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
67118 + return -EACCES;
67119 + }
67120 +#endif
67121 + return 0;
67122 +}
67123 +
67124 +int
67125 +gr_handle_sock_server_other(const struct sock *sck)
67126 +{
67127 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
67128 + if (grsec_enable_socket_server &&
67129 + in_group_p(grsec_socket_server_gid) &&
67130 + sck && (sck->sk_family != AF_UNIX) &&
67131 + (sck->sk_family != AF_LOCAL)) {
67132 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
67133 + return -EACCES;
67134 + }
67135 +#endif
67136 + return 0;
67137 +}
67138 +
67139 +int
67140 +gr_handle_sock_client(const struct sockaddr *sck)
67141 +{
67142 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
67143 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
67144 + sck && (sck->sa_family != AF_UNIX) &&
67145 + (sck->sa_family != AF_LOCAL)) {
67146 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
67147 + return -EACCES;
67148 + }
67149 +#endif
67150 + return 0;
67151 +}
67152 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
67153 new file mode 100644
67154 index 0000000..7624d1c
67155 --- /dev/null
67156 +++ b/grsecurity/grsec_sysctl.c
67157 @@ -0,0 +1,460 @@
67158 +#include <linux/kernel.h>
67159 +#include <linux/sched.h>
67160 +#include <linux/sysctl.h>
67161 +#include <linux/grsecurity.h>
67162 +#include <linux/grinternal.h>
67163 +
67164 +int
67165 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
67166 +{
67167 +#ifdef CONFIG_GRKERNSEC_SYSCTL
67168 + if (dirname == NULL || name == NULL)
67169 + return 0;
67170 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
67171 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
67172 + return -EACCES;
67173 + }
67174 +#endif
67175 + return 0;
67176 +}
67177 +
67178 +#ifdef CONFIG_GRKERNSEC_ROFS
67179 +static int __maybe_unused one = 1;
67180 +#endif
67181 +
67182 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
67183 +struct ctl_table grsecurity_table[] = {
67184 +#ifdef CONFIG_GRKERNSEC_SYSCTL
67185 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
67186 +#ifdef CONFIG_GRKERNSEC_IO
67187 + {
67188 + .procname = "disable_priv_io",
67189 + .data = &grsec_disable_privio,
67190 + .maxlen = sizeof(int),
67191 + .mode = 0600,
67192 + .proc_handler = &proc_dointvec,
67193 + },
67194 +#endif
67195 +#endif
67196 +#ifdef CONFIG_GRKERNSEC_LINK
67197 + {
67198 + .procname = "linking_restrictions",
67199 + .data = &grsec_enable_link,
67200 + .maxlen = sizeof(int),
67201 + .mode = 0600,
67202 + .proc_handler = &proc_dointvec,
67203 + },
67204 +#endif
67205 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
67206 + {
67207 + .procname = "enforce_symlinksifowner",
67208 + .data = &grsec_enable_symlinkown,
67209 + .maxlen = sizeof(int),
67210 + .mode = 0600,
67211 + .proc_handler = &proc_dointvec,
67212 + },
67213 + {
67214 + .procname = "symlinkown_gid",
67215 + .data = &grsec_symlinkown_gid,
67216 + .maxlen = sizeof(int),
67217 + .mode = 0600,
67218 + .proc_handler = &proc_dointvec,
67219 + },
67220 +#endif
67221 +#ifdef CONFIG_GRKERNSEC_BRUTE
67222 + {
67223 + .procname = "deter_bruteforce",
67224 + .data = &grsec_enable_brute,
67225 + .maxlen = sizeof(int),
67226 + .mode = 0600,
67227 + .proc_handler = &proc_dointvec,
67228 + },
67229 +#endif
67230 +#ifdef CONFIG_GRKERNSEC_FIFO
67231 + {
67232 + .procname = "fifo_restrictions",
67233 + .data = &grsec_enable_fifo,
67234 + .maxlen = sizeof(int),
67235 + .mode = 0600,
67236 + .proc_handler = &proc_dointvec,
67237 + },
67238 +#endif
67239 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
67240 + {
67241 + .procname = "ptrace_readexec",
67242 + .data = &grsec_enable_ptrace_readexec,
67243 + .maxlen = sizeof(int),
67244 + .mode = 0600,
67245 + .proc_handler = &proc_dointvec,
67246 + },
67247 +#endif
67248 +#ifdef CONFIG_GRKERNSEC_SETXID
67249 + {
67250 + .procname = "consistent_setxid",
67251 + .data = &grsec_enable_setxid,
67252 + .maxlen = sizeof(int),
67253 + .mode = 0600,
67254 + .proc_handler = &proc_dointvec,
67255 + },
67256 +#endif
67257 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
67258 + {
67259 + .procname = "ip_blackhole",
67260 + .data = &grsec_enable_blackhole,
67261 + .maxlen = sizeof(int),
67262 + .mode = 0600,
67263 + .proc_handler = &proc_dointvec,
67264 + },
67265 + {
67266 + .procname = "lastack_retries",
67267 + .data = &grsec_lastack_retries,
67268 + .maxlen = sizeof(int),
67269 + .mode = 0600,
67270 + .proc_handler = &proc_dointvec,
67271 + },
67272 +#endif
67273 +#ifdef CONFIG_GRKERNSEC_EXECLOG
67274 + {
67275 + .procname = "exec_logging",
67276 + .data = &grsec_enable_execlog,
67277 + .maxlen = sizeof(int),
67278 + .mode = 0600,
67279 + .proc_handler = &proc_dointvec,
67280 + },
67281 +#endif
67282 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
67283 + {
67284 + .procname = "rwxmap_logging",
67285 + .data = &grsec_enable_log_rwxmaps,
67286 + .maxlen = sizeof(int),
67287 + .mode = 0600,
67288 + .proc_handler = &proc_dointvec,
67289 + },
67290 +#endif
67291 +#ifdef CONFIG_GRKERNSEC_SIGNAL
67292 + {
67293 + .procname = "signal_logging",
67294 + .data = &grsec_enable_signal,
67295 + .maxlen = sizeof(int),
67296 + .mode = 0600,
67297 + .proc_handler = &proc_dointvec,
67298 + },
67299 +#endif
67300 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
67301 + {
67302 + .procname = "forkfail_logging",
67303 + .data = &grsec_enable_forkfail,
67304 + .maxlen = sizeof(int),
67305 + .mode = 0600,
67306 + .proc_handler = &proc_dointvec,
67307 + },
67308 +#endif
67309 +#ifdef CONFIG_GRKERNSEC_TIME
67310 + {
67311 + .procname = "timechange_logging",
67312 + .data = &grsec_enable_time,
67313 + .maxlen = sizeof(int),
67314 + .mode = 0600,
67315 + .proc_handler = &proc_dointvec,
67316 + },
67317 +#endif
67318 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
67319 + {
67320 + .procname = "chroot_deny_shmat",
67321 + .data = &grsec_enable_chroot_shmat,
67322 + .maxlen = sizeof(int),
67323 + .mode = 0600,
67324 + .proc_handler = &proc_dointvec,
67325 + },
67326 +#endif
67327 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
67328 + {
67329 + .procname = "chroot_deny_unix",
67330 + .data = &grsec_enable_chroot_unix,
67331 + .maxlen = sizeof(int),
67332 + .mode = 0600,
67333 + .proc_handler = &proc_dointvec,
67334 + },
67335 +#endif
67336 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
67337 + {
67338 + .procname = "chroot_deny_mount",
67339 + .data = &grsec_enable_chroot_mount,
67340 + .maxlen = sizeof(int),
67341 + .mode = 0600,
67342 + .proc_handler = &proc_dointvec,
67343 + },
67344 +#endif
67345 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
67346 + {
67347 + .procname = "chroot_deny_fchdir",
67348 + .data = &grsec_enable_chroot_fchdir,
67349 + .maxlen = sizeof(int),
67350 + .mode = 0600,
67351 + .proc_handler = &proc_dointvec,
67352 + },
67353 +#endif
67354 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
67355 + {
67356 + .procname = "chroot_deny_chroot",
67357 + .data = &grsec_enable_chroot_double,
67358 + .maxlen = sizeof(int),
67359 + .mode = 0600,
67360 + .proc_handler = &proc_dointvec,
67361 + },
67362 +#endif
67363 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
67364 + {
67365 + .procname = "chroot_deny_pivot",
67366 + .data = &grsec_enable_chroot_pivot,
67367 + .maxlen = sizeof(int),
67368 + .mode = 0600,
67369 + .proc_handler = &proc_dointvec,
67370 + },
67371 +#endif
67372 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
67373 + {
67374 + .procname = "chroot_enforce_chdir",
67375 + .data = &grsec_enable_chroot_chdir,
67376 + .maxlen = sizeof(int),
67377 + .mode = 0600,
67378 + .proc_handler = &proc_dointvec,
67379 + },
67380 +#endif
67381 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
67382 + {
67383 + .procname = "chroot_deny_chmod",
67384 + .data = &grsec_enable_chroot_chmod,
67385 + .maxlen = sizeof(int),
67386 + .mode = 0600,
67387 + .proc_handler = &proc_dointvec,
67388 + },
67389 +#endif
67390 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
67391 + {
67392 + .procname = "chroot_deny_mknod",
67393 + .data = &grsec_enable_chroot_mknod,
67394 + .maxlen = sizeof(int),
67395 + .mode = 0600,
67396 + .proc_handler = &proc_dointvec,
67397 + },
67398 +#endif
67399 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
67400 + {
67401 + .procname = "chroot_restrict_nice",
67402 + .data = &grsec_enable_chroot_nice,
67403 + .maxlen = sizeof(int),
67404 + .mode = 0600,
67405 + .proc_handler = &proc_dointvec,
67406 + },
67407 +#endif
67408 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
67409 + {
67410 + .procname = "chroot_execlog",
67411 + .data = &grsec_enable_chroot_execlog,
67412 + .maxlen = sizeof(int),
67413 + .mode = 0600,
67414 + .proc_handler = &proc_dointvec,
67415 + },
67416 +#endif
67417 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67418 + {
67419 + .procname = "chroot_caps",
67420 + .data = &grsec_enable_chroot_caps,
67421 + .maxlen = sizeof(int),
67422 + .mode = 0600,
67423 + .proc_handler = &proc_dointvec,
67424 + },
67425 +#endif
67426 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
67427 + {
67428 + .procname = "chroot_deny_sysctl",
67429 + .data = &grsec_enable_chroot_sysctl,
67430 + .maxlen = sizeof(int),
67431 + .mode = 0600,
67432 + .proc_handler = &proc_dointvec,
67433 + },
67434 +#endif
67435 +#ifdef CONFIG_GRKERNSEC_TPE
67436 + {
67437 + .procname = "tpe",
67438 + .data = &grsec_enable_tpe,
67439 + .maxlen = sizeof(int),
67440 + .mode = 0600,
67441 + .proc_handler = &proc_dointvec,
67442 + },
67443 + {
67444 + .procname = "tpe_gid",
67445 + .data = &grsec_tpe_gid,
67446 + .maxlen = sizeof(int),
67447 + .mode = 0600,
67448 + .proc_handler = &proc_dointvec,
67449 + },
67450 +#endif
67451 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67452 + {
67453 + .procname = "tpe_invert",
67454 + .data = &grsec_enable_tpe_invert,
67455 + .maxlen = sizeof(int),
67456 + .mode = 0600,
67457 + .proc_handler = &proc_dointvec,
67458 + },
67459 +#endif
67460 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
67461 + {
67462 + .procname = "tpe_restrict_all",
67463 + .data = &grsec_enable_tpe_all,
67464 + .maxlen = sizeof(int),
67465 + .mode = 0600,
67466 + .proc_handler = &proc_dointvec,
67467 + },
67468 +#endif
67469 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
67470 + {
67471 + .procname = "socket_all",
67472 + .data = &grsec_enable_socket_all,
67473 + .maxlen = sizeof(int),
67474 + .mode = 0600,
67475 + .proc_handler = &proc_dointvec,
67476 + },
67477 + {
67478 + .procname = "socket_all_gid",
67479 + .data = &grsec_socket_all_gid,
67480 + .maxlen = sizeof(int),
67481 + .mode = 0600,
67482 + .proc_handler = &proc_dointvec,
67483 + },
67484 +#endif
67485 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
67486 + {
67487 + .procname = "socket_client",
67488 + .data = &grsec_enable_socket_client,
67489 + .maxlen = sizeof(int),
67490 + .mode = 0600,
67491 + .proc_handler = &proc_dointvec,
67492 + },
67493 + {
67494 + .procname = "socket_client_gid",
67495 + .data = &grsec_socket_client_gid,
67496 + .maxlen = sizeof(int),
67497 + .mode = 0600,
67498 + .proc_handler = &proc_dointvec,
67499 + },
67500 +#endif
67501 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
67502 + {
67503 + .procname = "socket_server",
67504 + .data = &grsec_enable_socket_server,
67505 + .maxlen = sizeof(int),
67506 + .mode = 0600,
67507 + .proc_handler = &proc_dointvec,
67508 + },
67509 + {
67510 + .procname = "socket_server_gid",
67511 + .data = &grsec_socket_server_gid,
67512 + .maxlen = sizeof(int),
67513 + .mode = 0600,
67514 + .proc_handler = &proc_dointvec,
67515 + },
67516 +#endif
67517 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
67518 + {
67519 + .procname = "audit_group",
67520 + .data = &grsec_enable_group,
67521 + .maxlen = sizeof(int),
67522 + .mode = 0600,
67523 + .proc_handler = &proc_dointvec,
67524 + },
67525 + {
67526 + .procname = "audit_gid",
67527 + .data = &grsec_audit_gid,
67528 + .maxlen = sizeof(int),
67529 + .mode = 0600,
67530 + .proc_handler = &proc_dointvec,
67531 + },
67532 +#endif
67533 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
67534 + {
67535 + .procname = "audit_chdir",
67536 + .data = &grsec_enable_chdir,
67537 + .maxlen = sizeof(int),
67538 + .mode = 0600,
67539 + .proc_handler = &proc_dointvec,
67540 + },
67541 +#endif
67542 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
67543 + {
67544 + .procname = "audit_mount",
67545 + .data = &grsec_enable_mount,
67546 + .maxlen = sizeof(int),
67547 + .mode = 0600,
67548 + .proc_handler = &proc_dointvec,
67549 + },
67550 +#endif
67551 +#ifdef CONFIG_GRKERNSEC_DMESG
67552 + {
67553 + .procname = "dmesg",
67554 + .data = &grsec_enable_dmesg,
67555 + .maxlen = sizeof(int),
67556 + .mode = 0600,
67557 + .proc_handler = &proc_dointvec,
67558 + },
67559 +#endif
67560 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
67561 + {
67562 + .procname = "chroot_findtask",
67563 + .data = &grsec_enable_chroot_findtask,
67564 + .maxlen = sizeof(int),
67565 + .mode = 0600,
67566 + .proc_handler = &proc_dointvec,
67567 + },
67568 +#endif
67569 +#ifdef CONFIG_GRKERNSEC_RESLOG
67570 + {
67571 + .procname = "resource_logging",
67572 + .data = &grsec_resource_logging,
67573 + .maxlen = sizeof(int),
67574 + .mode = 0600,
67575 + .proc_handler = &proc_dointvec,
67576 + },
67577 +#endif
67578 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
67579 + {
67580 + .procname = "audit_ptrace",
67581 + .data = &grsec_enable_audit_ptrace,
67582 + .maxlen = sizeof(int),
67583 + .mode = 0600,
67584 + .proc_handler = &proc_dointvec,
67585 + },
67586 +#endif
67587 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
67588 + {
67589 + .procname = "harden_ptrace",
67590 + .data = &grsec_enable_harden_ptrace,
67591 + .maxlen = sizeof(int),
67592 + .mode = 0600,
67593 + .proc_handler = &proc_dointvec,
67594 + },
67595 +#endif
67596 + {
67597 + .procname = "grsec_lock",
67598 + .data = &grsec_lock,
67599 + .maxlen = sizeof(int),
67600 + .mode = 0600,
67601 + .proc_handler = &proc_dointvec,
67602 + },
67603 +#endif
67604 +#ifdef CONFIG_GRKERNSEC_ROFS
67605 + {
67606 + .procname = "romount_protect",
67607 + .data = &grsec_enable_rofs,
67608 + .maxlen = sizeof(int),
67609 + .mode = 0600,
67610 + .proc_handler = &proc_dointvec_minmax,
67611 + .extra1 = &one,
67612 + .extra2 = &one,
67613 + },
67614 +#endif
67615 + { }
67616 +};
67617 +#endif
67618 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
67619 new file mode 100644
67620 index 0000000..0dc13c3
67621 --- /dev/null
67622 +++ b/grsecurity/grsec_time.c
67623 @@ -0,0 +1,16 @@
67624 +#include <linux/kernel.h>
67625 +#include <linux/sched.h>
67626 +#include <linux/grinternal.h>
67627 +#include <linux/module.h>
67628 +
67629 +void
67630 +gr_log_timechange(void)
67631 +{
67632 +#ifdef CONFIG_GRKERNSEC_TIME
67633 + if (grsec_enable_time)
67634 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
67635 +#endif
67636 + return;
67637 +}
67638 +
67639 +EXPORT_SYMBOL(gr_log_timechange);
67640 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
67641 new file mode 100644
67642 index 0000000..ee57dcf
67643 --- /dev/null
67644 +++ b/grsecurity/grsec_tpe.c
67645 @@ -0,0 +1,73 @@
67646 +#include <linux/kernel.h>
67647 +#include <linux/sched.h>
67648 +#include <linux/file.h>
67649 +#include <linux/fs.h>
67650 +#include <linux/grinternal.h>
67651 +
67652 +extern int gr_acl_tpe_check(void);
67653 +
67654 +int
67655 +gr_tpe_allow(const struct file *file)
67656 +{
67657 +#ifdef CONFIG_GRKERNSEC
67658 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
67659 + const struct cred *cred = current_cred();
67660 + char *msg = NULL;
67661 + char *msg2 = NULL;
67662 +
67663 + // never restrict root
67664 + if (gr_is_global_root(cred->uid))
67665 + return 1;
67666 +
67667 + if (grsec_enable_tpe) {
67668 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67669 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
67670 + msg = "not being in trusted group";
67671 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
67672 + msg = "being in untrusted group";
67673 +#else
67674 + if (in_group_p(grsec_tpe_gid))
67675 + msg = "being in untrusted group";
67676 +#endif
67677 + }
67678 + if (!msg && gr_acl_tpe_check())
67679 + msg = "being in untrusted role";
67680 +
67681 + // not in any affected group/role
67682 + if (!msg)
67683 + goto next_check;
67684 +
67685 + if (gr_is_global_nonroot(inode->i_uid))
67686 + msg2 = "file in non-root-owned directory";
67687 + else if (inode->i_mode & S_IWOTH)
67688 + msg2 = "file in world-writable directory";
67689 + else if (inode->i_mode & S_IWGRP)
67690 + msg2 = "file in group-writable directory";
67691 +
67692 + if (msg && msg2) {
67693 + char fullmsg[70] = {0};
67694 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
67695 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
67696 + return 0;
67697 + }
67698 + msg = NULL;
67699 +next_check:
67700 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
67701 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
67702 + return 1;
67703 +
67704 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
67705 + msg = "directory not owned by user";
67706 + else if (inode->i_mode & S_IWOTH)
67707 + msg = "file in world-writable directory";
67708 + else if (inode->i_mode & S_IWGRP)
67709 + msg = "file in group-writable directory";
67710 +
67711 + if (msg) {
67712 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
67713 + return 0;
67714 + }
67715 +#endif
67716 +#endif
67717 + return 1;
67718 +}
67719 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
67720 new file mode 100644
67721 index 0000000..9f7b1ac
67722 --- /dev/null
67723 +++ b/grsecurity/grsum.c
67724 @@ -0,0 +1,61 @@
67725 +#include <linux/err.h>
67726 +#include <linux/kernel.h>
67727 +#include <linux/sched.h>
67728 +#include <linux/mm.h>
67729 +#include <linux/scatterlist.h>
67730 +#include <linux/crypto.h>
67731 +#include <linux/gracl.h>
67732 +
67733 +
67734 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
67735 +#error "crypto and sha256 must be built into the kernel"
67736 +#endif
67737 +
67738 +int
67739 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
67740 +{
67741 + char *p;
67742 + struct crypto_hash *tfm;
67743 + struct hash_desc desc;
67744 + struct scatterlist sg;
67745 + unsigned char temp_sum[GR_SHA_LEN];
67746 + volatile int retval = 0;
67747 + volatile int dummy = 0;
67748 + unsigned int i;
67749 +
67750 + sg_init_table(&sg, 1);
67751 +
67752 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67753 + if (IS_ERR(tfm)) {
67754 + /* should never happen, since sha256 should be built in */
67755 + return 1;
67756 + }
67757 +
67758 + desc.tfm = tfm;
67759 + desc.flags = 0;
67760 +
67761 + crypto_hash_init(&desc);
67762 +
67763 + p = salt;
67764 + sg_set_buf(&sg, p, GR_SALT_LEN);
67765 + crypto_hash_update(&desc, &sg, sg.length);
67766 +
67767 + p = entry->pw;
67768 + sg_set_buf(&sg, p, strlen(p));
67769 +
67770 + crypto_hash_update(&desc, &sg, sg.length);
67771 +
67772 + crypto_hash_final(&desc, temp_sum);
67773 +
67774 + memset(entry->pw, 0, GR_PW_LEN);
67775 +
67776 + for (i = 0; i < GR_SHA_LEN; i++)
67777 + if (sum[i] != temp_sum[i])
67778 + retval = 1;
67779 + else
67780 + dummy = 1; // waste a cycle
67781 +
67782 + crypto_free_hash(tfm);
67783 +
67784 + return retval;
67785 +}
67786 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67787 index 77ff547..181834f 100644
67788 --- a/include/asm-generic/4level-fixup.h
67789 +++ b/include/asm-generic/4level-fixup.h
67790 @@ -13,8 +13,10 @@
67791 #define pmd_alloc(mm, pud, address) \
67792 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67793 NULL: pmd_offset(pud, address))
67794 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67795
67796 #define pud_alloc(mm, pgd, address) (pgd)
67797 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67798 #define pud_offset(pgd, start) (pgd)
67799 #define pud_none(pud) 0
67800 #define pud_bad(pud) 0
67801 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67802 index b7babf0..04ad282 100644
67803 --- a/include/asm-generic/atomic-long.h
67804 +++ b/include/asm-generic/atomic-long.h
67805 @@ -22,6 +22,12 @@
67806
67807 typedef atomic64_t atomic_long_t;
67808
67809 +#ifdef CONFIG_PAX_REFCOUNT
67810 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67811 +#else
67812 +typedef atomic64_t atomic_long_unchecked_t;
67813 +#endif
67814 +
67815 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67816
67817 static inline long atomic_long_read(atomic_long_t *l)
67818 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67819 return (long)atomic64_read(v);
67820 }
67821
67822 +#ifdef CONFIG_PAX_REFCOUNT
67823 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67824 +{
67825 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67826 +
67827 + return (long)atomic64_read_unchecked(v);
67828 +}
67829 +#endif
67830 +
67831 static inline void atomic_long_set(atomic_long_t *l, long i)
67832 {
67833 atomic64_t *v = (atomic64_t *)l;
67834 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67835 atomic64_set(v, i);
67836 }
67837
67838 +#ifdef CONFIG_PAX_REFCOUNT
67839 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67840 +{
67841 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67842 +
67843 + atomic64_set_unchecked(v, i);
67844 +}
67845 +#endif
67846 +
67847 static inline void atomic_long_inc(atomic_long_t *l)
67848 {
67849 atomic64_t *v = (atomic64_t *)l;
67850 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67851 atomic64_inc(v);
67852 }
67853
67854 +#ifdef CONFIG_PAX_REFCOUNT
67855 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67856 +{
67857 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67858 +
67859 + atomic64_inc_unchecked(v);
67860 +}
67861 +#endif
67862 +
67863 static inline void atomic_long_dec(atomic_long_t *l)
67864 {
67865 atomic64_t *v = (atomic64_t *)l;
67866 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67867 atomic64_dec(v);
67868 }
67869
67870 +#ifdef CONFIG_PAX_REFCOUNT
67871 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67872 +{
67873 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67874 +
67875 + atomic64_dec_unchecked(v);
67876 +}
67877 +#endif
67878 +
67879 static inline void atomic_long_add(long i, atomic_long_t *l)
67880 {
67881 atomic64_t *v = (atomic64_t *)l;
67882 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67883 atomic64_add(i, v);
67884 }
67885
67886 +#ifdef CONFIG_PAX_REFCOUNT
67887 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67888 +{
67889 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67890 +
67891 + atomic64_add_unchecked(i, v);
67892 +}
67893 +#endif
67894 +
67895 static inline void atomic_long_sub(long i, atomic_long_t *l)
67896 {
67897 atomic64_t *v = (atomic64_t *)l;
67898 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67899 atomic64_sub(i, v);
67900 }
67901
67902 +#ifdef CONFIG_PAX_REFCOUNT
67903 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67904 +{
67905 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67906 +
67907 + atomic64_sub_unchecked(i, v);
67908 +}
67909 +#endif
67910 +
67911 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67912 {
67913 atomic64_t *v = (atomic64_t *)l;
67914 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67915 return (long)atomic64_add_return(i, v);
67916 }
67917
67918 +#ifdef CONFIG_PAX_REFCOUNT
67919 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67920 +{
67921 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67922 +
67923 + return (long)atomic64_add_return_unchecked(i, v);
67924 +}
67925 +#endif
67926 +
67927 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67928 {
67929 atomic64_t *v = (atomic64_t *)l;
67930 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67931 return (long)atomic64_inc_return(v);
67932 }
67933
67934 +#ifdef CONFIG_PAX_REFCOUNT
67935 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67936 +{
67937 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67938 +
67939 + return (long)atomic64_inc_return_unchecked(v);
67940 +}
67941 +#endif
67942 +
67943 static inline long atomic_long_dec_return(atomic_long_t *l)
67944 {
67945 atomic64_t *v = (atomic64_t *)l;
67946 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67947
67948 typedef atomic_t atomic_long_t;
67949
67950 +#ifdef CONFIG_PAX_REFCOUNT
67951 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67952 +#else
67953 +typedef atomic_t atomic_long_unchecked_t;
67954 +#endif
67955 +
67956 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67957 static inline long atomic_long_read(atomic_long_t *l)
67958 {
67959 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67960 return (long)atomic_read(v);
67961 }
67962
67963 +#ifdef CONFIG_PAX_REFCOUNT
67964 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67965 +{
67966 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67967 +
67968 + return (long)atomic_read_unchecked(v);
67969 +}
67970 +#endif
67971 +
67972 static inline void atomic_long_set(atomic_long_t *l, long i)
67973 {
67974 atomic_t *v = (atomic_t *)l;
67975 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67976 atomic_set(v, i);
67977 }
67978
67979 +#ifdef CONFIG_PAX_REFCOUNT
67980 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67981 +{
67982 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67983 +
67984 + atomic_set_unchecked(v, i);
67985 +}
67986 +#endif
67987 +
67988 static inline void atomic_long_inc(atomic_long_t *l)
67989 {
67990 atomic_t *v = (atomic_t *)l;
67991 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67992 atomic_inc(v);
67993 }
67994
67995 +#ifdef CONFIG_PAX_REFCOUNT
67996 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67997 +{
67998 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67999 +
68000 + atomic_inc_unchecked(v);
68001 +}
68002 +#endif
68003 +
68004 static inline void atomic_long_dec(atomic_long_t *l)
68005 {
68006 atomic_t *v = (atomic_t *)l;
68007 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
68008 atomic_dec(v);
68009 }
68010
68011 +#ifdef CONFIG_PAX_REFCOUNT
68012 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
68013 +{
68014 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68015 +
68016 + atomic_dec_unchecked(v);
68017 +}
68018 +#endif
68019 +
68020 static inline void atomic_long_add(long i, atomic_long_t *l)
68021 {
68022 atomic_t *v = (atomic_t *)l;
68023 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
68024 atomic_add(i, v);
68025 }
68026
68027 +#ifdef CONFIG_PAX_REFCOUNT
68028 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
68029 +{
68030 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68031 +
68032 + atomic_add_unchecked(i, v);
68033 +}
68034 +#endif
68035 +
68036 static inline void atomic_long_sub(long i, atomic_long_t *l)
68037 {
68038 atomic_t *v = (atomic_t *)l;
68039 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
68040 atomic_sub(i, v);
68041 }
68042
68043 +#ifdef CONFIG_PAX_REFCOUNT
68044 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
68045 +{
68046 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68047 +
68048 + atomic_sub_unchecked(i, v);
68049 +}
68050 +#endif
68051 +
68052 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
68053 {
68054 atomic_t *v = (atomic_t *)l;
68055 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
68056 return (long)atomic_add_return(i, v);
68057 }
68058
68059 +#ifdef CONFIG_PAX_REFCOUNT
68060 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
68061 +{
68062 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68063 +
68064 + return (long)atomic_add_return_unchecked(i, v);
68065 +}
68066 +
68067 +#endif
68068 +
68069 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
68070 {
68071 atomic_t *v = (atomic_t *)l;
68072 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
68073 return (long)atomic_inc_return(v);
68074 }
68075
68076 +#ifdef CONFIG_PAX_REFCOUNT
68077 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
68078 +{
68079 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
68080 +
68081 + return (long)atomic_inc_return_unchecked(v);
68082 +}
68083 +#endif
68084 +
68085 static inline long atomic_long_dec_return(atomic_long_t *l)
68086 {
68087 atomic_t *v = (atomic_t *)l;
68088 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
68089
68090 #endif /* BITS_PER_LONG == 64 */
68091
68092 +#ifdef CONFIG_PAX_REFCOUNT
68093 +static inline void pax_refcount_needs_these_functions(void)
68094 +{
68095 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
68096 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
68097 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
68098 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
68099 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
68100 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
68101 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
68102 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
68103 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
68104 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
68105 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
68106 +#ifdef CONFIG_X86
68107 + atomic_clear_mask_unchecked(0, NULL);
68108 + atomic_set_mask_unchecked(0, NULL);
68109 +#endif
68110 +
68111 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
68112 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
68113 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
68114 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
68115 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
68116 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
68117 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
68118 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
68119 +}
68120 +#else
68121 +#define atomic_read_unchecked(v) atomic_read(v)
68122 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
68123 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
68124 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
68125 +#define atomic_inc_unchecked(v) atomic_inc(v)
68126 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
68127 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
68128 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
68129 +#define atomic_dec_unchecked(v) atomic_dec(v)
68130 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
68131 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
68132 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
68133 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
68134 +
68135 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
68136 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
68137 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
68138 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
68139 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
68140 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
68141 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
68142 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
68143 +#endif
68144 +
68145 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
68146 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
68147 index 33bd2de..f31bff97 100644
68148 --- a/include/asm-generic/atomic.h
68149 +++ b/include/asm-generic/atomic.h
68150 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
68151 * Atomically clears the bits set in @mask from @v
68152 */
68153 #ifndef atomic_clear_mask
68154 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
68155 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
68156 {
68157 unsigned long flags;
68158
68159 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
68160 index b18ce4f..2ee2843 100644
68161 --- a/include/asm-generic/atomic64.h
68162 +++ b/include/asm-generic/atomic64.h
68163 @@ -16,6 +16,8 @@ typedef struct {
68164 long long counter;
68165 } atomic64_t;
68166
68167 +typedef atomic64_t atomic64_unchecked_t;
68168 +
68169 #define ATOMIC64_INIT(i) { (i) }
68170
68171 extern long long atomic64_read(const atomic64_t *v);
68172 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
68173 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
68174 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
68175
68176 +#define atomic64_read_unchecked(v) atomic64_read(v)
68177 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
68178 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
68179 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
68180 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
68181 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
68182 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
68183 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
68184 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
68185 +
68186 #endif /* _ASM_GENERIC_ATOMIC64_H */
68187 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
68188 index 1bfcfe5..e04c5c9 100644
68189 --- a/include/asm-generic/cache.h
68190 +++ b/include/asm-generic/cache.h
68191 @@ -6,7 +6,7 @@
68192 * cache lines need to provide their own cache.h.
68193 */
68194
68195 -#define L1_CACHE_SHIFT 5
68196 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
68197 +#define L1_CACHE_SHIFT 5UL
68198 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
68199
68200 #endif /* __ASM_GENERIC_CACHE_H */
68201 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
68202 index 0d68a1e..b74a761 100644
68203 --- a/include/asm-generic/emergency-restart.h
68204 +++ b/include/asm-generic/emergency-restart.h
68205 @@ -1,7 +1,7 @@
68206 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
68207 #define _ASM_GENERIC_EMERGENCY_RESTART_H
68208
68209 -static inline void machine_emergency_restart(void)
68210 +static inline __noreturn void machine_emergency_restart(void)
68211 {
68212 machine_restart(NULL);
68213 }
68214 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
68215 index 90f99c7..00ce236 100644
68216 --- a/include/asm-generic/kmap_types.h
68217 +++ b/include/asm-generic/kmap_types.h
68218 @@ -2,9 +2,9 @@
68219 #define _ASM_GENERIC_KMAP_TYPES_H
68220
68221 #ifdef __WITH_KM_FENCE
68222 -# define KM_TYPE_NR 41
68223 +# define KM_TYPE_NR 42
68224 #else
68225 -# define KM_TYPE_NR 20
68226 +# define KM_TYPE_NR 21
68227 #endif
68228
68229 #endif
68230 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
68231 index 9ceb03b..62b0b8f 100644
68232 --- a/include/asm-generic/local.h
68233 +++ b/include/asm-generic/local.h
68234 @@ -23,24 +23,37 @@ typedef struct
68235 atomic_long_t a;
68236 } local_t;
68237
68238 +typedef struct {
68239 + atomic_long_unchecked_t a;
68240 +} local_unchecked_t;
68241 +
68242 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
68243
68244 #define local_read(l) atomic_long_read(&(l)->a)
68245 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
68246 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
68247 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
68248 #define local_inc(l) atomic_long_inc(&(l)->a)
68249 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
68250 #define local_dec(l) atomic_long_dec(&(l)->a)
68251 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
68252 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
68253 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
68254 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
68255 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
68256
68257 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
68258 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
68259 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
68260 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
68261 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
68262 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
68263 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
68264 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
68265 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
68266
68267 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
68268 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
68269 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
68270 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
68271 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
68272 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
68273 index 725612b..9cc513a 100644
68274 --- a/include/asm-generic/pgtable-nopmd.h
68275 +++ b/include/asm-generic/pgtable-nopmd.h
68276 @@ -1,14 +1,19 @@
68277 #ifndef _PGTABLE_NOPMD_H
68278 #define _PGTABLE_NOPMD_H
68279
68280 -#ifndef __ASSEMBLY__
68281 -
68282 #include <asm-generic/pgtable-nopud.h>
68283
68284 -struct mm_struct;
68285 -
68286 #define __PAGETABLE_PMD_FOLDED
68287
68288 +#define PMD_SHIFT PUD_SHIFT
68289 +#define PTRS_PER_PMD 1
68290 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
68291 +#define PMD_MASK (~(PMD_SIZE-1))
68292 +
68293 +#ifndef __ASSEMBLY__
68294 +
68295 +struct mm_struct;
68296 +
68297 /*
68298 * Having the pmd type consist of a pud gets the size right, and allows
68299 * us to conceptually access the pud entry that this pmd is folded into
68300 @@ -16,11 +21,6 @@ struct mm_struct;
68301 */
68302 typedef struct { pud_t pud; } pmd_t;
68303
68304 -#define PMD_SHIFT PUD_SHIFT
68305 -#define PTRS_PER_PMD 1
68306 -#define PMD_SIZE (1UL << PMD_SHIFT)
68307 -#define PMD_MASK (~(PMD_SIZE-1))
68308 -
68309 /*
68310 * The "pud_xxx()" functions here are trivial for a folded two-level
68311 * setup: the pmd is never bad, and a pmd always exists (as it's folded
68312 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
68313 index 810431d..0ec4804f 100644
68314 --- a/include/asm-generic/pgtable-nopud.h
68315 +++ b/include/asm-generic/pgtable-nopud.h
68316 @@ -1,10 +1,15 @@
68317 #ifndef _PGTABLE_NOPUD_H
68318 #define _PGTABLE_NOPUD_H
68319
68320 -#ifndef __ASSEMBLY__
68321 -
68322 #define __PAGETABLE_PUD_FOLDED
68323
68324 +#define PUD_SHIFT PGDIR_SHIFT
68325 +#define PTRS_PER_PUD 1
68326 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
68327 +#define PUD_MASK (~(PUD_SIZE-1))
68328 +
68329 +#ifndef __ASSEMBLY__
68330 +
68331 /*
68332 * Having the pud type consist of a pgd gets the size right, and allows
68333 * us to conceptually access the pgd entry that this pud is folded into
68334 @@ -12,11 +17,6 @@
68335 */
68336 typedef struct { pgd_t pgd; } pud_t;
68337
68338 -#define PUD_SHIFT PGDIR_SHIFT
68339 -#define PTRS_PER_PUD 1
68340 -#define PUD_SIZE (1UL << PUD_SHIFT)
68341 -#define PUD_MASK (~(PUD_SIZE-1))
68342 -
68343 /*
68344 * The "pgd_xxx()" functions here are trivial for a folded two-level
68345 * setup: the pud is never bad, and a pud always exists (as it's folded
68346 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
68347 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
68348
68349 #define pgd_populate(mm, pgd, pud) do { } while (0)
68350 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
68351 /*
68352 * (puds are folded into pgds so this doesn't get actually called,
68353 * but the define is needed for a generic inline function.)
68354 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
68355 index a59ff51..2594a70 100644
68356 --- a/include/asm-generic/pgtable.h
68357 +++ b/include/asm-generic/pgtable.h
68358 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
68359 }
68360 #endif /* CONFIG_NUMA_BALANCING */
68361
68362 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
68363 +static inline unsigned long pax_open_kernel(void) { return 0; }
68364 +#endif
68365 +
68366 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
68367 +static inline unsigned long pax_close_kernel(void) { return 0; }
68368 +#endif
68369 +
68370 #endif /* CONFIG_MMU */
68371
68372 #endif /* !__ASSEMBLY__ */
68373 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
68374 index eb58d2d..df131bf 100644
68375 --- a/include/asm-generic/vmlinux.lds.h
68376 +++ b/include/asm-generic/vmlinux.lds.h
68377 @@ -239,6 +239,7 @@
68378 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
68379 VMLINUX_SYMBOL(__start_rodata) = .; \
68380 *(.rodata) *(.rodata.*) \
68381 + *(.data..read_only) \
68382 *(__vermagic) /* Kernel version magic */ \
68383 . = ALIGN(8); \
68384 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
68385 @@ -749,17 +750,18 @@
68386 * section in the linker script will go there too. @phdr should have
68387 * a leading colon.
68388 *
68389 - * Note that this macros defines __per_cpu_load as an absolute symbol.
68390 + * Note that this macros defines per_cpu_load as an absolute symbol.
68391 * If there is no need to put the percpu section at a predetermined
68392 * address, use PERCPU_SECTION.
68393 */
68394 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
68395 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
68396 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
68397 + per_cpu_load = .; \
68398 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
68399 - LOAD_OFFSET) { \
68400 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
68401 PERCPU_INPUT(cacheline) \
68402 } phdr \
68403 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
68404 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
68405
68406 /**
68407 * PERCPU_SECTION - define output section for percpu area, simple version
68408 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
68409 index 418d270..bfd2794 100644
68410 --- a/include/crypto/algapi.h
68411 +++ b/include/crypto/algapi.h
68412 @@ -34,7 +34,7 @@ struct crypto_type {
68413 unsigned int maskclear;
68414 unsigned int maskset;
68415 unsigned int tfmsize;
68416 -};
68417 +} __do_const;
68418
68419 struct crypto_instance {
68420 struct crypto_alg alg;
68421 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
68422 index 63d17ee..716de2b 100644
68423 --- a/include/drm/drmP.h
68424 +++ b/include/drm/drmP.h
68425 @@ -72,6 +72,7 @@
68426 #include <linux/workqueue.h>
68427 #include <linux/poll.h>
68428 #include <asm/pgalloc.h>
68429 +#include <asm/local.h>
68430 #include <drm/drm.h>
68431 #include <drm/drm_sarea.h>
68432
68433 @@ -296,10 +297,12 @@ do { \
68434 * \param cmd command.
68435 * \param arg argument.
68436 */
68437 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
68438 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
68439 + struct drm_file *file_priv);
68440 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
68441 struct drm_file *file_priv);
68442
68443 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
68444 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
68445 unsigned long arg);
68446
68447 #define DRM_IOCTL_NR(n) _IOC_NR(n)
68448 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
68449 struct drm_ioctl_desc {
68450 unsigned int cmd;
68451 int flags;
68452 - drm_ioctl_t *func;
68453 + drm_ioctl_t func;
68454 unsigned int cmd_drv;
68455 const char *name;
68456 -};
68457 +} __do_const;
68458
68459 /**
68460 * Creates a driver or general drm_ioctl_desc array entry for the given
68461 @@ -1015,7 +1018,7 @@ struct drm_info_list {
68462 int (*show)(struct seq_file*, void*); /** show callback */
68463 u32 driver_features; /**< Required driver features for this entry */
68464 void *data;
68465 -};
68466 +} __do_const;
68467
68468 /**
68469 * debugfs node structure. This structure represents a debugfs file.
68470 @@ -1088,7 +1091,7 @@ struct drm_device {
68471
68472 /** \name Usage Counters */
68473 /*@{ */
68474 - int open_count; /**< Outstanding files open */
68475 + local_t open_count; /**< Outstanding files open */
68476 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
68477 atomic_t vma_count; /**< Outstanding vma areas open */
68478 int buf_use; /**< Buffers in use -- cannot alloc */
68479 @@ -1099,7 +1102,7 @@ struct drm_device {
68480 /*@{ */
68481 unsigned long counters;
68482 enum drm_stat_type types[15];
68483 - atomic_t counts[15];
68484 + atomic_unchecked_t counts[15];
68485 /*@} */
68486
68487 struct list_head filelist;
68488 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
68489 index f43d556..94d9343 100644
68490 --- a/include/drm/drm_crtc_helper.h
68491 +++ b/include/drm/drm_crtc_helper.h
68492 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
68493 struct drm_connector *connector);
68494 /* disable encoder when not in use - more explicit than dpms off */
68495 void (*disable)(struct drm_encoder *encoder);
68496 -};
68497 +} __no_const;
68498
68499 /**
68500 * drm_connector_helper_funcs - helper operations for connectors
68501 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
68502 index 72dcbe8..8db58d7 100644
68503 --- a/include/drm/ttm/ttm_memory.h
68504 +++ b/include/drm/ttm/ttm_memory.h
68505 @@ -48,7 +48,7 @@
68506
68507 struct ttm_mem_shrink {
68508 int (*do_shrink) (struct ttm_mem_shrink *);
68509 -};
68510 +} __no_const;
68511
68512 /**
68513 * struct ttm_mem_global - Global memory accounting structure.
68514 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
68515 index 4b840e8..155d235 100644
68516 --- a/include/keys/asymmetric-subtype.h
68517 +++ b/include/keys/asymmetric-subtype.h
68518 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
68519 /* Verify the signature on a key of this subtype (optional) */
68520 int (*verify_signature)(const struct key *key,
68521 const struct public_key_signature *sig);
68522 -};
68523 +} __do_const;
68524
68525 /**
68526 * asymmetric_key_subtype - Get the subtype from an asymmetric key
68527 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
68528 index c1da539..1dcec55 100644
68529 --- a/include/linux/atmdev.h
68530 +++ b/include/linux/atmdev.h
68531 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
68532 #endif
68533
68534 struct k_atm_aal_stats {
68535 -#define __HANDLE_ITEM(i) atomic_t i
68536 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
68537 __AAL_STAT_ITEMS
68538 #undef __HANDLE_ITEM
68539 };
68540 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
68541 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
68542 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
68543 struct module *owner;
68544 -};
68545 +} __do_const ;
68546
68547 struct atmphy_ops {
68548 int (*start)(struct atm_dev *dev);
68549 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
68550 index 70cf138..0418ee2 100644
68551 --- a/include/linux/binfmts.h
68552 +++ b/include/linux/binfmts.h
68553 @@ -73,8 +73,10 @@ struct linux_binfmt {
68554 int (*load_binary)(struct linux_binprm *);
68555 int (*load_shlib)(struct file *);
68556 int (*core_dump)(struct coredump_params *cprm);
68557 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
68558 + void (*handle_mmap)(struct file *);
68559 unsigned long min_coredump; /* minimal dump size */
68560 -};
68561 +} __do_const;
68562
68563 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
68564
68565 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
68566 index 2fdb4a4..54aad7e 100644
68567 --- a/include/linux/blkdev.h
68568 +++ b/include/linux/blkdev.h
68569 @@ -1526,7 +1526,7 @@ struct block_device_operations {
68570 /* this callback is with swap_lock and sometimes page table lock held */
68571 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
68572 struct module *owner;
68573 -};
68574 +} __do_const;
68575
68576 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
68577 unsigned long);
68578 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
68579 index 7c2e030..b72475d 100644
68580 --- a/include/linux/blktrace_api.h
68581 +++ b/include/linux/blktrace_api.h
68582 @@ -23,7 +23,7 @@ struct blk_trace {
68583 struct dentry *dir;
68584 struct dentry *dropped_file;
68585 struct dentry *msg_file;
68586 - atomic_t dropped;
68587 + atomic_unchecked_t dropped;
68588 };
68589
68590 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
68591 diff --git a/include/linux/cache.h b/include/linux/cache.h
68592 index 4c57065..4307975 100644
68593 --- a/include/linux/cache.h
68594 +++ b/include/linux/cache.h
68595 @@ -16,6 +16,10 @@
68596 #define __read_mostly
68597 #endif
68598
68599 +#ifndef __read_only
68600 +#define __read_only __read_mostly
68601 +#endif
68602 +
68603 #ifndef ____cacheline_aligned
68604 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
68605 #endif
68606 diff --git a/include/linux/capability.h b/include/linux/capability.h
68607 index d9a4f7f4..19f77d6 100644
68608 --- a/include/linux/capability.h
68609 +++ b/include/linux/capability.h
68610 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
68611 extern bool nsown_capable(int cap);
68612 extern bool inode_capable(const struct inode *inode, int cap);
68613 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
68614 +extern bool capable_nolog(int cap);
68615 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
68616 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
68617
68618 /* audit system wants to get cap info from files as well */
68619 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
68620
68621 +extern int is_privileged_binary(const struct dentry *dentry);
68622 +
68623 #endif /* !_LINUX_CAPABILITY_H */
68624 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
68625 index 8609d57..86e4d79 100644
68626 --- a/include/linux/cdrom.h
68627 +++ b/include/linux/cdrom.h
68628 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
68629
68630 /* driver specifications */
68631 const int capability; /* capability flags */
68632 - int n_minors; /* number of active minor devices */
68633 /* handle uniform packets for scsi type devices (scsi,atapi) */
68634 int (*generic_packet) (struct cdrom_device_info *,
68635 struct packet_command *);
68636 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
68637 index 4ce9056..86caac6 100644
68638 --- a/include/linux/cleancache.h
68639 +++ b/include/linux/cleancache.h
68640 @@ -31,7 +31,7 @@ struct cleancache_ops {
68641 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
68642 void (*invalidate_inode)(int, struct cleancache_filekey);
68643 void (*invalidate_fs)(int);
68644 -};
68645 +} __no_const;
68646
68647 extern struct cleancache_ops *
68648 cleancache_register_ops(struct cleancache_ops *ops);
68649 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
68650 index 1186098..f87e53d 100644
68651 --- a/include/linux/clk-provider.h
68652 +++ b/include/linux/clk-provider.h
68653 @@ -132,6 +132,7 @@ struct clk_ops {
68654 unsigned long);
68655 void (*init)(struct clk_hw *hw);
68656 };
68657 +typedef struct clk_ops __no_const clk_ops_no_const;
68658
68659 /**
68660 * struct clk_init_data - holds init data that's common to all clocks and is
68661 diff --git a/include/linux/compat.h b/include/linux/compat.h
68662 index 7f0c1dd..b5729c6 100644
68663 --- a/include/linux/compat.h
68664 +++ b/include/linux/compat.h
68665 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
68666 compat_size_t __user *len_ptr);
68667
68668 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
68669 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
68670 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
68671 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
68672 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
68673 compat_ssize_t msgsz, int msgflg);
68674 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
68675 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
68676 compat_ulong_t addr, compat_ulong_t data);
68677 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
68678 - compat_long_t addr, compat_long_t data);
68679 + compat_ulong_t addr, compat_ulong_t data);
68680
68681 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
68682 /*
68683 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
68684 index 842de22..7f3a41f 100644
68685 --- a/include/linux/compiler-gcc4.h
68686 +++ b/include/linux/compiler-gcc4.h
68687 @@ -39,9 +39,29 @@
68688 # define __compiletime_warning(message) __attribute__((warning(message)))
68689 # define __compiletime_error(message) __attribute__((error(message)))
68690 #endif /* __CHECKER__ */
68691 +
68692 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
68693 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
68694 +#define __bos0(ptr) __bos((ptr), 0)
68695 +#define __bos1(ptr) __bos((ptr), 1)
68696 #endif /* GCC_VERSION >= 40300 */
68697
68698 #if GCC_VERSION >= 40500
68699 +
68700 +#ifdef CONSTIFY_PLUGIN
68701 +#define __no_const __attribute__((no_const))
68702 +#define __do_const __attribute__((do_const))
68703 +#endif
68704 +
68705 +#ifdef SIZE_OVERFLOW_PLUGIN
68706 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
68707 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
68708 +#endif
68709 +
68710 +#ifdef LATENT_ENTROPY_PLUGIN
68711 +#define __latent_entropy __attribute__((latent_entropy))
68712 +#endif
68713 +
68714 /*
68715 * Mark a position in code as unreachable. This can be used to
68716 * suppress control flow warnings after asm blocks that transfer
68717 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
68718 index 92669cd..1771a15 100644
68719 --- a/include/linux/compiler.h
68720 +++ b/include/linux/compiler.h
68721 @@ -5,11 +5,14 @@
68722
68723 #ifdef __CHECKER__
68724 # define __user __attribute__((noderef, address_space(1)))
68725 +# define __force_user __force __user
68726 # define __kernel __attribute__((address_space(0)))
68727 +# define __force_kernel __force __kernel
68728 # define __safe __attribute__((safe))
68729 # define __force __attribute__((force))
68730 # define __nocast __attribute__((nocast))
68731 # define __iomem __attribute__((noderef, address_space(2)))
68732 +# define __force_iomem __force __iomem
68733 # define __must_hold(x) __attribute__((context(x,1,1)))
68734 # define __acquires(x) __attribute__((context(x,0,1)))
68735 # define __releases(x) __attribute__((context(x,1,0)))
68736 @@ -17,20 +20,37 @@
68737 # define __release(x) __context__(x,-1)
68738 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
68739 # define __percpu __attribute__((noderef, address_space(3)))
68740 +# define __force_percpu __force __percpu
68741 #ifdef CONFIG_SPARSE_RCU_POINTER
68742 # define __rcu __attribute__((noderef, address_space(4)))
68743 +# define __force_rcu __force __rcu
68744 #else
68745 # define __rcu
68746 +# define __force_rcu
68747 #endif
68748 extern void __chk_user_ptr(const volatile void __user *);
68749 extern void __chk_io_ptr(const volatile void __iomem *);
68750 #else
68751 -# define __user
68752 -# define __kernel
68753 +# ifdef CHECKER_PLUGIN
68754 +//# define __user
68755 +//# define __force_user
68756 +//# define __kernel
68757 +//# define __force_kernel
68758 +# else
68759 +# ifdef STRUCTLEAK_PLUGIN
68760 +# define __user __attribute__((user))
68761 +# else
68762 +# define __user
68763 +# endif
68764 +# define __force_user
68765 +# define __kernel
68766 +# define __force_kernel
68767 +# endif
68768 # define __safe
68769 # define __force
68770 # define __nocast
68771 # define __iomem
68772 +# define __force_iomem
68773 # define __chk_user_ptr(x) (void)0
68774 # define __chk_io_ptr(x) (void)0
68775 # define __builtin_warning(x, y...) (1)
68776 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68777 # define __release(x) (void)0
68778 # define __cond_lock(x,c) (c)
68779 # define __percpu
68780 +# define __force_percpu
68781 # define __rcu
68782 +# define __force_rcu
68783 #endif
68784
68785 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68786 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68787 # define __attribute_const__ /* unimplemented */
68788 #endif
68789
68790 +#ifndef __no_const
68791 +# define __no_const
68792 +#endif
68793 +
68794 +#ifndef __do_const
68795 +# define __do_const
68796 +#endif
68797 +
68798 +#ifndef __size_overflow
68799 +# define __size_overflow(...)
68800 +#endif
68801 +
68802 +#ifndef __intentional_overflow
68803 +# define __intentional_overflow(...)
68804 +#endif
68805 +
68806 +#ifndef __latent_entropy
68807 +# define __latent_entropy
68808 +#endif
68809 +
68810 /*
68811 * Tell gcc if a function is cold. The compiler will assume any path
68812 * directly leading to the call is unlikely.
68813 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68814 #define __cold
68815 #endif
68816
68817 +#ifndef __alloc_size
68818 +#define __alloc_size(...)
68819 +#endif
68820 +
68821 +#ifndef __bos
68822 +#define __bos(ptr, arg)
68823 +#endif
68824 +
68825 +#ifndef __bos0
68826 +#define __bos0(ptr)
68827 +#endif
68828 +
68829 +#ifndef __bos1
68830 +#define __bos1(ptr)
68831 +#endif
68832 +
68833 /* Simple shorthand for a section definition */
68834 #ifndef __section
68835 # define __section(S) __attribute__ ((__section__(#S)))
68836 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68837 * use is to mediate communication between process-level code and irq/NMI
68838 * handlers, all running on the same CPU.
68839 */
68840 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68841 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68842 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68843
68844 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
68845 #ifdef CONFIG_KPROBES
68846 diff --git a/include/linux/completion.h b/include/linux/completion.h
68847 index 33f0280..35c6568 100644
68848 --- a/include/linux/completion.h
68849 +++ b/include/linux/completion.h
68850 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
68851 extern void wait_for_completion(struct completion *);
68852 extern void wait_for_completion_io(struct completion *);
68853 extern int wait_for_completion_interruptible(struct completion *x);
68854 -extern int wait_for_completion_killable(struct completion *x);
68855 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68856 extern unsigned long wait_for_completion_timeout(struct completion *x,
68857 unsigned long timeout);
68858 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
68859 unsigned long timeout);
68860 extern long wait_for_completion_interruptible_timeout(
68861 - struct completion *x, unsigned long timeout);
68862 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68863 extern long wait_for_completion_killable_timeout(
68864 - struct completion *x, unsigned long timeout);
68865 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68866 extern bool try_wait_for_completion(struct completion *x);
68867 extern bool completion_done(struct completion *x);
68868
68869 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68870 index 34025df..d94bbbc 100644
68871 --- a/include/linux/configfs.h
68872 +++ b/include/linux/configfs.h
68873 @@ -125,7 +125,7 @@ struct configfs_attribute {
68874 const char *ca_name;
68875 struct module *ca_owner;
68876 umode_t ca_mode;
68877 -};
68878 +} __do_const;
68879
68880 /*
68881 * Users often need to create attribute structures for their configurable
68882 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68883 index 9f3c7e8..a18c7b6 100644
68884 --- a/include/linux/cpu.h
68885 +++ b/include/linux/cpu.h
68886 @@ -115,7 +115,7 @@ enum {
68887 /* Need to know about CPUs going up/down? */
68888 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68889 #define cpu_notifier(fn, pri) { \
68890 - static struct notifier_block fn##_nb __cpuinitdata = \
68891 + static struct notifier_block fn##_nb = \
68892 { .notifier_call = fn, .priority = pri }; \
68893 register_cpu_notifier(&fn##_nb); \
68894 }
68895 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68896 index 037d36a..ca5fe6e 100644
68897 --- a/include/linux/cpufreq.h
68898 +++ b/include/linux/cpufreq.h
68899 @@ -262,7 +262,7 @@ struct cpufreq_driver {
68900 int (*suspend) (struct cpufreq_policy *policy);
68901 int (*resume) (struct cpufreq_policy *policy);
68902 struct freq_attr **attr;
68903 -};
68904 +} __do_const;
68905
68906 /* flags */
68907
68908 @@ -321,6 +321,7 @@ struct global_attr {
68909 ssize_t (*store)(struct kobject *a, struct attribute *b,
68910 const char *c, size_t count);
68911 };
68912 +typedef struct global_attr __no_const global_attr_no_const;
68913
68914 #define define_one_global_ro(_name) \
68915 static struct global_attr _name = \
68916 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68917 index 8f04062..900239a 100644
68918 --- a/include/linux/cpuidle.h
68919 +++ b/include/linux/cpuidle.h
68920 @@ -52,7 +52,8 @@ struct cpuidle_state {
68921 int index);
68922
68923 int (*enter_dead) (struct cpuidle_device *dev, int index);
68924 -};
68925 +} __do_const;
68926 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68927
68928 /* Idle State Flags */
68929 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68930 @@ -191,7 +192,7 @@ struct cpuidle_governor {
68931 void (*reflect) (struct cpuidle_device *dev, int index);
68932
68933 struct module *owner;
68934 -};
68935 +} __do_const;
68936
68937 #ifdef CONFIG_CPU_IDLE
68938
68939 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68940 index d08e4d2..95fad61 100644
68941 --- a/include/linux/cpumask.h
68942 +++ b/include/linux/cpumask.h
68943 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68944 }
68945
68946 /* Valid inputs for n are -1 and 0. */
68947 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68948 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68949 {
68950 return n+1;
68951 }
68952
68953 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68954 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68955 {
68956 return n+1;
68957 }
68958
68959 -static inline unsigned int cpumask_next_and(int n,
68960 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68961 const struct cpumask *srcp,
68962 const struct cpumask *andp)
68963 {
68964 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68965 *
68966 * Returns >= nr_cpu_ids if no further cpus set.
68967 */
68968 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68969 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68970 {
68971 /* -1 is a legal arg here. */
68972 if (n != -1)
68973 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68974 *
68975 * Returns >= nr_cpu_ids if no further cpus unset.
68976 */
68977 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68978 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68979 {
68980 /* -1 is a legal arg here. */
68981 if (n != -1)
68982 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68983 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68984 }
68985
68986 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68987 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68988 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68989
68990 /**
68991 diff --git a/include/linux/cred.h b/include/linux/cred.h
68992 index 04421e8..6bce4ef 100644
68993 --- a/include/linux/cred.h
68994 +++ b/include/linux/cred.h
68995 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68996 static inline void validate_process_creds(void)
68997 {
68998 }
68999 +static inline void validate_task_creds(struct task_struct *task)
69000 +{
69001 +}
69002 #endif
69003
69004 /**
69005 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
69006 index b92eadf..b4ecdc1 100644
69007 --- a/include/linux/crypto.h
69008 +++ b/include/linux/crypto.h
69009 @@ -373,7 +373,7 @@ struct cipher_tfm {
69010 const u8 *key, unsigned int keylen);
69011 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
69012 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
69013 -};
69014 +} __no_const;
69015
69016 struct hash_tfm {
69017 int (*init)(struct hash_desc *desc);
69018 @@ -394,13 +394,13 @@ struct compress_tfm {
69019 int (*cot_decompress)(struct crypto_tfm *tfm,
69020 const u8 *src, unsigned int slen,
69021 u8 *dst, unsigned int *dlen);
69022 -};
69023 +} __no_const;
69024
69025 struct rng_tfm {
69026 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
69027 unsigned int dlen);
69028 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
69029 -};
69030 +} __no_const;
69031
69032 #define crt_ablkcipher crt_u.ablkcipher
69033 #define crt_aead crt_u.aead
69034 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
69035 index 653589e..4ef254a 100644
69036 --- a/include/linux/ctype.h
69037 +++ b/include/linux/ctype.h
69038 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
69039 * Fast implementation of tolower() for internal usage. Do not use in your
69040 * code.
69041 */
69042 -static inline char _tolower(const char c)
69043 +static inline unsigned char _tolower(const unsigned char c)
69044 {
69045 return c | 0x20;
69046 }
69047 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
69048 index 7925bf0..d5143d2 100644
69049 --- a/include/linux/decompress/mm.h
69050 +++ b/include/linux/decompress/mm.h
69051 @@ -77,7 +77,7 @@ static void free(void *where)
69052 * warnings when not needed (indeed large_malloc / large_free are not
69053 * needed by inflate */
69054
69055 -#define malloc(a) kmalloc(a, GFP_KERNEL)
69056 +#define malloc(a) kmalloc((a), GFP_KERNEL)
69057 #define free(a) kfree(a)
69058
69059 #define large_malloc(a) vmalloc(a)
69060 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
69061 index fe8c447..bdc1f33 100644
69062 --- a/include/linux/devfreq.h
69063 +++ b/include/linux/devfreq.h
69064 @@ -114,7 +114,7 @@ struct devfreq_governor {
69065 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
69066 int (*event_handler)(struct devfreq *devfreq,
69067 unsigned int event, void *data);
69068 -};
69069 +} __do_const;
69070
69071 /**
69072 * struct devfreq - Device devfreq structure
69073 diff --git a/include/linux/device.h b/include/linux/device.h
69074 index c0a1261..dba7569 100644
69075 --- a/include/linux/device.h
69076 +++ b/include/linux/device.h
69077 @@ -290,7 +290,7 @@ struct subsys_interface {
69078 struct list_head node;
69079 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
69080 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
69081 -};
69082 +} __do_const;
69083
69084 int subsys_interface_register(struct subsys_interface *sif);
69085 void subsys_interface_unregister(struct subsys_interface *sif);
69086 @@ -473,7 +473,7 @@ struct device_type {
69087 void (*release)(struct device *dev);
69088
69089 const struct dev_pm_ops *pm;
69090 -};
69091 +} __do_const;
69092
69093 /* interface for exporting device attributes */
69094 struct device_attribute {
69095 @@ -483,11 +483,12 @@ struct device_attribute {
69096 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
69097 const char *buf, size_t count);
69098 };
69099 +typedef struct device_attribute __no_const device_attribute_no_const;
69100
69101 struct dev_ext_attribute {
69102 struct device_attribute attr;
69103 void *var;
69104 -};
69105 +} __do_const;
69106
69107 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
69108 char *buf);
69109 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
69110 index 94af418..b1ca7a2 100644
69111 --- a/include/linux/dma-mapping.h
69112 +++ b/include/linux/dma-mapping.h
69113 @@ -54,7 +54,7 @@ struct dma_map_ops {
69114 u64 (*get_required_mask)(struct device *dev);
69115 #endif
69116 int is_phys;
69117 -};
69118 +} __do_const;
69119
69120 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
69121
69122 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
69123 index 96d3e4a..dc36433 100644
69124 --- a/include/linux/dmaengine.h
69125 +++ b/include/linux/dmaengine.h
69126 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
69127 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
69128 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
69129
69130 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
69131 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
69132 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
69133 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
69134 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
69135 struct dma_pinned_list *pinned_list, struct page *page,
69136 unsigned int offset, size_t len);
69137
69138 diff --git a/include/linux/efi.h b/include/linux/efi.h
69139 index 2bc0ad7..3f7b006 100644
69140 --- a/include/linux/efi.h
69141 +++ b/include/linux/efi.h
69142 @@ -745,6 +745,7 @@ struct efivar_operations {
69143 efi_set_variable_t *set_variable;
69144 efi_query_variable_store_t *query_variable_store;
69145 };
69146 +typedef struct efivar_operations __no_const efivar_operations_no_const;
69147
69148 struct efivars {
69149 /*
69150 diff --git a/include/linux/elf.h b/include/linux/elf.h
69151 index 40a3c0e..4c45a38 100644
69152 --- a/include/linux/elf.h
69153 +++ b/include/linux/elf.h
69154 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
69155 #define elf_note elf32_note
69156 #define elf_addr_t Elf32_Off
69157 #define Elf_Half Elf32_Half
69158 +#define elf_dyn Elf32_Dyn
69159
69160 #else
69161
69162 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
69163 #define elf_note elf64_note
69164 #define elf_addr_t Elf64_Off
69165 #define Elf_Half Elf64_Half
69166 +#define elf_dyn Elf64_Dyn
69167
69168 #endif
69169
69170 diff --git a/include/linux/err.h b/include/linux/err.h
69171 index f2edce2..cc2082c 100644
69172 --- a/include/linux/err.h
69173 +++ b/include/linux/err.h
69174 @@ -19,12 +19,12 @@
69175
69176 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
69177
69178 -static inline void * __must_check ERR_PTR(long error)
69179 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
69180 {
69181 return (void *) error;
69182 }
69183
69184 -static inline long __must_check PTR_ERR(const void *ptr)
69185 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
69186 {
69187 return (long) ptr;
69188 }
69189 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
69190 index fcb51c8..bdafcf6 100644
69191 --- a/include/linux/extcon.h
69192 +++ b/include/linux/extcon.h
69193 @@ -134,7 +134,7 @@ struct extcon_dev {
69194 /* /sys/class/extcon/.../mutually_exclusive/... */
69195 struct attribute_group attr_g_muex;
69196 struct attribute **attrs_muex;
69197 - struct device_attribute *d_attrs_muex;
69198 + device_attribute_no_const *d_attrs_muex;
69199 };
69200
69201 /**
69202 diff --git a/include/linux/fb.h b/include/linux/fb.h
69203 index d49c60f..2834fbe 100644
69204 --- a/include/linux/fb.h
69205 +++ b/include/linux/fb.h
69206 @@ -304,7 +304,7 @@ struct fb_ops {
69207 /* called at KDB enter and leave time to prepare the console */
69208 int (*fb_debug_enter)(struct fb_info *info);
69209 int (*fb_debug_leave)(struct fb_info *info);
69210 -};
69211 +} __do_const;
69212
69213 #ifdef CONFIG_FB_TILEBLITTING
69214 #define FB_TILE_CURSOR_NONE 0
69215 diff --git a/include/linux/filter.h b/include/linux/filter.h
69216 index f65f5a6..2f4f93a 100644
69217 --- a/include/linux/filter.h
69218 +++ b/include/linux/filter.h
69219 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
69220
69221 struct sk_buff;
69222 struct sock;
69223 +struct bpf_jit_work;
69224
69225 struct sk_filter
69226 {
69227 @@ -27,6 +28,9 @@ struct sk_filter
69228 unsigned int len; /* Number of filter blocks */
69229 unsigned int (*bpf_func)(const struct sk_buff *skb,
69230 const struct sock_filter *filter);
69231 +#ifdef CONFIG_BPF_JIT
69232 + struct bpf_jit_work *work;
69233 +#endif
69234 struct rcu_head rcu;
69235 struct sock_filter insns[0];
69236 };
69237 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
69238 index 8293262..2b3b8bd 100644
69239 --- a/include/linux/frontswap.h
69240 +++ b/include/linux/frontswap.h
69241 @@ -11,7 +11,7 @@ struct frontswap_ops {
69242 int (*load)(unsigned, pgoff_t, struct page *);
69243 void (*invalidate_page)(unsigned, pgoff_t);
69244 void (*invalidate_area)(unsigned);
69245 -};
69246 +} __no_const;
69247
69248 extern bool frontswap_enabled;
69249 extern struct frontswap_ops *
69250 diff --git a/include/linux/fs.h b/include/linux/fs.h
69251 index 65c2be2..4c53f6e 100644
69252 --- a/include/linux/fs.h
69253 +++ b/include/linux/fs.h
69254 @@ -1543,7 +1543,8 @@ struct file_operations {
69255 long (*fallocate)(struct file *file, int mode, loff_t offset,
69256 loff_t len);
69257 int (*show_fdinfo)(struct seq_file *m, struct file *f);
69258 -};
69259 +} __do_const;
69260 +typedef struct file_operations __no_const file_operations_no_const;
69261
69262 struct inode_operations {
69263 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
69264 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
69265 inode->i_flags |= S_NOSEC;
69266 }
69267
69268 +static inline bool is_sidechannel_device(const struct inode *inode)
69269 +{
69270 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
69271 + umode_t mode = inode->i_mode;
69272 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
69273 +#else
69274 + return false;
69275 +#endif
69276 +}
69277 +
69278 #endif /* _LINUX_FS_H */
69279 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
69280 index 2b93a9a..855d94a 100644
69281 --- a/include/linux/fs_struct.h
69282 +++ b/include/linux/fs_struct.h
69283 @@ -6,7 +6,7 @@
69284 #include <linux/seqlock.h>
69285
69286 struct fs_struct {
69287 - int users;
69288 + atomic_t users;
69289 spinlock_t lock;
69290 seqcount_t seq;
69291 int umask;
69292 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
69293 index 5dfa0aa..6acf322 100644
69294 --- a/include/linux/fscache-cache.h
69295 +++ b/include/linux/fscache-cache.h
69296 @@ -112,7 +112,7 @@ struct fscache_operation {
69297 fscache_operation_release_t release;
69298 };
69299
69300 -extern atomic_t fscache_op_debug_id;
69301 +extern atomic_unchecked_t fscache_op_debug_id;
69302 extern void fscache_op_work_func(struct work_struct *work);
69303
69304 extern void fscache_enqueue_operation(struct fscache_operation *);
69305 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
69306 INIT_WORK(&op->work, fscache_op_work_func);
69307 atomic_set(&op->usage, 1);
69308 op->state = FSCACHE_OP_ST_INITIALISED;
69309 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
69310 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
69311 op->processor = processor;
69312 op->release = release;
69313 INIT_LIST_HEAD(&op->pend_link);
69314 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
69315 index 7a08623..4c07b0f 100644
69316 --- a/include/linux/fscache.h
69317 +++ b/include/linux/fscache.h
69318 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
69319 * - this is mandatory for any object that may have data
69320 */
69321 void (*now_uncached)(void *cookie_netfs_data);
69322 -};
69323 +} __do_const;
69324
69325 /*
69326 * fscache cached network filesystem type
69327 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
69328 index a78680a..87bd73e 100644
69329 --- a/include/linux/fsnotify.h
69330 +++ b/include/linux/fsnotify.h
69331 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
69332 struct inode *inode = path->dentry->d_inode;
69333 __u32 mask = FS_ACCESS;
69334
69335 + if (is_sidechannel_device(inode))
69336 + return;
69337 +
69338 if (S_ISDIR(inode->i_mode))
69339 mask |= FS_ISDIR;
69340
69341 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
69342 struct inode *inode = path->dentry->d_inode;
69343 __u32 mask = FS_MODIFY;
69344
69345 + if (is_sidechannel_device(inode))
69346 + return;
69347 +
69348 if (S_ISDIR(inode->i_mode))
69349 mask |= FS_ISDIR;
69350
69351 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
69352 */
69353 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
69354 {
69355 - return kstrdup(name, GFP_KERNEL);
69356 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
69357 }
69358
69359 /*
69360 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
69361 index 9f3c275..911b591 100644
69362 --- a/include/linux/genhd.h
69363 +++ b/include/linux/genhd.h
69364 @@ -194,7 +194,7 @@ struct gendisk {
69365 struct kobject *slave_dir;
69366
69367 struct timer_rand_state *random;
69368 - atomic_t sync_io; /* RAID */
69369 + atomic_unchecked_t sync_io; /* RAID */
69370 struct disk_events *ev;
69371 #ifdef CONFIG_BLK_DEV_INTEGRITY
69372 struct blk_integrity *integrity;
69373 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
69374 index 023bc34..b02b46a 100644
69375 --- a/include/linux/genl_magic_func.h
69376 +++ b/include/linux/genl_magic_func.h
69377 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
69378 },
69379
69380 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
69381 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
69382 +static struct genl_ops ZZZ_genl_ops[] = {
69383 #include GENL_MAGIC_INCLUDE_FILE
69384 };
69385
69386 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
69387 index 0f615eb..5c3832f 100644
69388 --- a/include/linux/gfp.h
69389 +++ b/include/linux/gfp.h
69390 @@ -35,6 +35,13 @@ struct vm_area_struct;
69391 #define ___GFP_NO_KSWAPD 0x400000u
69392 #define ___GFP_OTHER_NODE 0x800000u
69393 #define ___GFP_WRITE 0x1000000u
69394 +
69395 +#ifdef CONFIG_PAX_USERCOPY_SLABS
69396 +#define ___GFP_USERCOPY 0x2000000u
69397 +#else
69398 +#define ___GFP_USERCOPY 0
69399 +#endif
69400 +
69401 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
69402
69403 /*
69404 @@ -92,6 +99,7 @@ struct vm_area_struct;
69405 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
69406 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
69407 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
69408 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
69409
69410 /*
69411 * This may seem redundant, but it's a way of annotating false positives vs.
69412 @@ -99,7 +107,7 @@ struct vm_area_struct;
69413 */
69414 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
69415
69416 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
69417 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
69418 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
69419
69420 /* This equals 0, but use constants in case they ever change */
69421 @@ -153,6 +161,8 @@ struct vm_area_struct;
69422 /* 4GB DMA on some platforms */
69423 #define GFP_DMA32 __GFP_DMA32
69424
69425 +#define GFP_USERCOPY __GFP_USERCOPY
69426 +
69427 /* Convert GFP flags to their corresponding migrate type */
69428 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
69429 {
69430 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
69431 new file mode 100644
69432 index 0000000..ebe6d72
69433 --- /dev/null
69434 +++ b/include/linux/gracl.h
69435 @@ -0,0 +1,319 @@
69436 +#ifndef GR_ACL_H
69437 +#define GR_ACL_H
69438 +
69439 +#include <linux/grdefs.h>
69440 +#include <linux/resource.h>
69441 +#include <linux/capability.h>
69442 +#include <linux/dcache.h>
69443 +#include <asm/resource.h>
69444 +
69445 +/* Major status information */
69446 +
69447 +#define GR_VERSION "grsecurity 2.9.1"
69448 +#define GRSECURITY_VERSION 0x2901
69449 +
69450 +enum {
69451 + GR_SHUTDOWN = 0,
69452 + GR_ENABLE = 1,
69453 + GR_SPROLE = 2,
69454 + GR_RELOAD = 3,
69455 + GR_SEGVMOD = 4,
69456 + GR_STATUS = 5,
69457 + GR_UNSPROLE = 6,
69458 + GR_PASSSET = 7,
69459 + GR_SPROLEPAM = 8,
69460 +};
69461 +
69462 +/* Password setup definitions
69463 + * kernel/grhash.c */
69464 +enum {
69465 + GR_PW_LEN = 128,
69466 + GR_SALT_LEN = 16,
69467 + GR_SHA_LEN = 32,
69468 +};
69469 +
69470 +enum {
69471 + GR_SPROLE_LEN = 64,
69472 +};
69473 +
69474 +enum {
69475 + GR_NO_GLOB = 0,
69476 + GR_REG_GLOB,
69477 + GR_CREATE_GLOB
69478 +};
69479 +
69480 +#define GR_NLIMITS 32
69481 +
69482 +/* Begin Data Structures */
69483 +
69484 +struct sprole_pw {
69485 + unsigned char *rolename;
69486 + unsigned char salt[GR_SALT_LEN];
69487 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
69488 +};
69489 +
69490 +struct name_entry {
69491 + __u32 key;
69492 + ino_t inode;
69493 + dev_t device;
69494 + char *name;
69495 + __u16 len;
69496 + __u8 deleted;
69497 + struct name_entry *prev;
69498 + struct name_entry *next;
69499 +};
69500 +
69501 +struct inodev_entry {
69502 + struct name_entry *nentry;
69503 + struct inodev_entry *prev;
69504 + struct inodev_entry *next;
69505 +};
69506 +
69507 +struct acl_role_db {
69508 + struct acl_role_label **r_hash;
69509 + __u32 r_size;
69510 +};
69511 +
69512 +struct inodev_db {
69513 + struct inodev_entry **i_hash;
69514 + __u32 i_size;
69515 +};
69516 +
69517 +struct name_db {
69518 + struct name_entry **n_hash;
69519 + __u32 n_size;
69520 +};
69521 +
69522 +struct crash_uid {
69523 + uid_t uid;
69524 + unsigned long expires;
69525 +};
69526 +
69527 +struct gr_hash_struct {
69528 + void **table;
69529 + void **nametable;
69530 + void *first;
69531 + __u32 table_size;
69532 + __u32 used_size;
69533 + int type;
69534 +};
69535 +
69536 +/* Userspace Grsecurity ACL data structures */
69537 +
69538 +struct acl_subject_label {
69539 + char *filename;
69540 + ino_t inode;
69541 + dev_t device;
69542 + __u32 mode;
69543 + kernel_cap_t cap_mask;
69544 + kernel_cap_t cap_lower;
69545 + kernel_cap_t cap_invert_audit;
69546 +
69547 + struct rlimit res[GR_NLIMITS];
69548 + __u32 resmask;
69549 +
69550 + __u8 user_trans_type;
69551 + __u8 group_trans_type;
69552 + uid_t *user_transitions;
69553 + gid_t *group_transitions;
69554 + __u16 user_trans_num;
69555 + __u16 group_trans_num;
69556 +
69557 + __u32 sock_families[2];
69558 + __u32 ip_proto[8];
69559 + __u32 ip_type;
69560 + struct acl_ip_label **ips;
69561 + __u32 ip_num;
69562 + __u32 inaddr_any_override;
69563 +
69564 + __u32 crashes;
69565 + unsigned long expires;
69566 +
69567 + struct acl_subject_label *parent_subject;
69568 + struct gr_hash_struct *hash;
69569 + struct acl_subject_label *prev;
69570 + struct acl_subject_label *next;
69571 +
69572 + struct acl_object_label **obj_hash;
69573 + __u32 obj_hash_size;
69574 + __u16 pax_flags;
69575 +};
69576 +
69577 +struct role_allowed_ip {
69578 + __u32 addr;
69579 + __u32 netmask;
69580 +
69581 + struct role_allowed_ip *prev;
69582 + struct role_allowed_ip *next;
69583 +};
69584 +
69585 +struct role_transition {
69586 + char *rolename;
69587 +
69588 + struct role_transition *prev;
69589 + struct role_transition *next;
69590 +};
69591 +
69592 +struct acl_role_label {
69593 + char *rolename;
69594 + uid_t uidgid;
69595 + __u16 roletype;
69596 +
69597 + __u16 auth_attempts;
69598 + unsigned long expires;
69599 +
69600 + struct acl_subject_label *root_label;
69601 + struct gr_hash_struct *hash;
69602 +
69603 + struct acl_role_label *prev;
69604 + struct acl_role_label *next;
69605 +
69606 + struct role_transition *transitions;
69607 + struct role_allowed_ip *allowed_ips;
69608 + uid_t *domain_children;
69609 + __u16 domain_child_num;
69610 +
69611 + umode_t umask;
69612 +
69613 + struct acl_subject_label **subj_hash;
69614 + __u32 subj_hash_size;
69615 +};
69616 +
69617 +struct user_acl_role_db {
69618 + struct acl_role_label **r_table;
69619 + __u32 num_pointers; /* Number of allocations to track */
69620 + __u32 num_roles; /* Number of roles */
69621 + __u32 num_domain_children; /* Number of domain children */
69622 + __u32 num_subjects; /* Number of subjects */
69623 + __u32 num_objects; /* Number of objects */
69624 +};
69625 +
69626 +struct acl_object_label {
69627 + char *filename;
69628 + ino_t inode;
69629 + dev_t device;
69630 + __u32 mode;
69631 +
69632 + struct acl_subject_label *nested;
69633 + struct acl_object_label *globbed;
69634 +
69635 + /* next two structures not used */
69636 +
69637 + struct acl_object_label *prev;
69638 + struct acl_object_label *next;
69639 +};
69640 +
69641 +struct acl_ip_label {
69642 + char *iface;
69643 + __u32 addr;
69644 + __u32 netmask;
69645 + __u16 low, high;
69646 + __u8 mode;
69647 + __u32 type;
69648 + __u32 proto[8];
69649 +
69650 + /* next two structures not used */
69651 +
69652 + struct acl_ip_label *prev;
69653 + struct acl_ip_label *next;
69654 +};
69655 +
69656 +struct gr_arg {
69657 + struct user_acl_role_db role_db;
69658 + unsigned char pw[GR_PW_LEN];
69659 + unsigned char salt[GR_SALT_LEN];
69660 + unsigned char sum[GR_SHA_LEN];
69661 + unsigned char sp_role[GR_SPROLE_LEN];
69662 + struct sprole_pw *sprole_pws;
69663 + dev_t segv_device;
69664 + ino_t segv_inode;
69665 + uid_t segv_uid;
69666 + __u16 num_sprole_pws;
69667 + __u16 mode;
69668 +};
69669 +
69670 +struct gr_arg_wrapper {
69671 + struct gr_arg *arg;
69672 + __u32 version;
69673 + __u32 size;
69674 +};
69675 +
69676 +struct subject_map {
69677 + struct acl_subject_label *user;
69678 + struct acl_subject_label *kernel;
69679 + struct subject_map *prev;
69680 + struct subject_map *next;
69681 +};
69682 +
69683 +struct acl_subj_map_db {
69684 + struct subject_map **s_hash;
69685 + __u32 s_size;
69686 +};
69687 +
69688 +/* End Data Structures Section */
69689 +
69690 +/* Hash functions generated by empirical testing by Brad Spengler
69691 + Makes good use of the low bits of the inode. Generally 0-1 times
69692 + in loop for successful match. 0-3 for unsuccessful match.
69693 + Shift/add algorithm with modulus of table size and an XOR*/
69694 +
69695 +static __inline__ unsigned int
69696 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
69697 +{
69698 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
69699 +}
69700 +
69701 + static __inline__ unsigned int
69702 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
69703 +{
69704 + return ((const unsigned long)userp % sz);
69705 +}
69706 +
69707 +static __inline__ unsigned int
69708 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
69709 +{
69710 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
69711 +}
69712 +
69713 +static __inline__ unsigned int
69714 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
69715 +{
69716 + return full_name_hash((const unsigned char *)name, len) % sz;
69717 +}
69718 +
69719 +#define FOR_EACH_ROLE_START(role) \
69720 + role = role_list; \
69721 + while (role) {
69722 +
69723 +#define FOR_EACH_ROLE_END(role) \
69724 + role = role->prev; \
69725 + }
69726 +
69727 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
69728 + subj = NULL; \
69729 + iter = 0; \
69730 + while (iter < role->subj_hash_size) { \
69731 + if (subj == NULL) \
69732 + subj = role->subj_hash[iter]; \
69733 + if (subj == NULL) { \
69734 + iter++; \
69735 + continue; \
69736 + }
69737 +
69738 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69739 + subj = subj->next; \
69740 + if (subj == NULL) \
69741 + iter++; \
69742 + }
69743 +
69744 +
69745 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69746 + subj = role->hash->first; \
69747 + while (subj != NULL) {
69748 +
69749 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69750 + subj = subj->next; \
69751 + }
69752 +
69753 +#endif
69754 +
69755 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
69756 new file mode 100644
69757 index 0000000..33ebd1f
69758 --- /dev/null
69759 +++ b/include/linux/gracl_compat.h
69760 @@ -0,0 +1,156 @@
69761 +#ifndef GR_ACL_COMPAT_H
69762 +#define GR_ACL_COMPAT_H
69763 +
69764 +#include <linux/resource.h>
69765 +#include <asm/resource.h>
69766 +
69767 +struct sprole_pw_compat {
69768 + compat_uptr_t rolename;
69769 + unsigned char salt[GR_SALT_LEN];
69770 + unsigned char sum[GR_SHA_LEN];
69771 +};
69772 +
69773 +struct gr_hash_struct_compat {
69774 + compat_uptr_t table;
69775 + compat_uptr_t nametable;
69776 + compat_uptr_t first;
69777 + __u32 table_size;
69778 + __u32 used_size;
69779 + int type;
69780 +};
69781 +
69782 +struct acl_subject_label_compat {
69783 + compat_uptr_t filename;
69784 + compat_ino_t inode;
69785 + __u32 device;
69786 + __u32 mode;
69787 + kernel_cap_t cap_mask;
69788 + kernel_cap_t cap_lower;
69789 + kernel_cap_t cap_invert_audit;
69790 +
69791 + struct compat_rlimit res[GR_NLIMITS];
69792 + __u32 resmask;
69793 +
69794 + __u8 user_trans_type;
69795 + __u8 group_trans_type;
69796 + compat_uptr_t user_transitions;
69797 + compat_uptr_t group_transitions;
69798 + __u16 user_trans_num;
69799 + __u16 group_trans_num;
69800 +
69801 + __u32 sock_families[2];
69802 + __u32 ip_proto[8];
69803 + __u32 ip_type;
69804 + compat_uptr_t ips;
69805 + __u32 ip_num;
69806 + __u32 inaddr_any_override;
69807 +
69808 + __u32 crashes;
69809 + compat_ulong_t expires;
69810 +
69811 + compat_uptr_t parent_subject;
69812 + compat_uptr_t hash;
69813 + compat_uptr_t prev;
69814 + compat_uptr_t next;
69815 +
69816 + compat_uptr_t obj_hash;
69817 + __u32 obj_hash_size;
69818 + __u16 pax_flags;
69819 +};
69820 +
69821 +struct role_allowed_ip_compat {
69822 + __u32 addr;
69823 + __u32 netmask;
69824 +
69825 + compat_uptr_t prev;
69826 + compat_uptr_t next;
69827 +};
69828 +
69829 +struct role_transition_compat {
69830 + compat_uptr_t rolename;
69831 +
69832 + compat_uptr_t prev;
69833 + compat_uptr_t next;
69834 +};
69835 +
69836 +struct acl_role_label_compat {
69837 + compat_uptr_t rolename;
69838 + uid_t uidgid;
69839 + __u16 roletype;
69840 +
69841 + __u16 auth_attempts;
69842 + compat_ulong_t expires;
69843 +
69844 + compat_uptr_t root_label;
69845 + compat_uptr_t hash;
69846 +
69847 + compat_uptr_t prev;
69848 + compat_uptr_t next;
69849 +
69850 + compat_uptr_t transitions;
69851 + compat_uptr_t allowed_ips;
69852 + compat_uptr_t domain_children;
69853 + __u16 domain_child_num;
69854 +
69855 + umode_t umask;
69856 +
69857 + compat_uptr_t subj_hash;
69858 + __u32 subj_hash_size;
69859 +};
69860 +
69861 +struct user_acl_role_db_compat {
69862 + compat_uptr_t r_table;
69863 + __u32 num_pointers;
69864 + __u32 num_roles;
69865 + __u32 num_domain_children;
69866 + __u32 num_subjects;
69867 + __u32 num_objects;
69868 +};
69869 +
69870 +struct acl_object_label_compat {
69871 + compat_uptr_t filename;
69872 + compat_ino_t inode;
69873 + __u32 device;
69874 + __u32 mode;
69875 +
69876 + compat_uptr_t nested;
69877 + compat_uptr_t globbed;
69878 +
69879 + compat_uptr_t prev;
69880 + compat_uptr_t next;
69881 +};
69882 +
69883 +struct acl_ip_label_compat {
69884 + compat_uptr_t iface;
69885 + __u32 addr;
69886 + __u32 netmask;
69887 + __u16 low, high;
69888 + __u8 mode;
69889 + __u32 type;
69890 + __u32 proto[8];
69891 +
69892 + compat_uptr_t prev;
69893 + compat_uptr_t next;
69894 +};
69895 +
69896 +struct gr_arg_compat {
69897 + struct user_acl_role_db_compat role_db;
69898 + unsigned char pw[GR_PW_LEN];
69899 + unsigned char salt[GR_SALT_LEN];
69900 + unsigned char sum[GR_SHA_LEN];
69901 + unsigned char sp_role[GR_SPROLE_LEN];
69902 + compat_uptr_t sprole_pws;
69903 + __u32 segv_device;
69904 + compat_ino_t segv_inode;
69905 + uid_t segv_uid;
69906 + __u16 num_sprole_pws;
69907 + __u16 mode;
69908 +};
69909 +
69910 +struct gr_arg_wrapper_compat {
69911 + compat_uptr_t arg;
69912 + __u32 version;
69913 + __u32 size;
69914 +};
69915 +
69916 +#endif
69917 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69918 new file mode 100644
69919 index 0000000..323ecf2
69920 --- /dev/null
69921 +++ b/include/linux/gralloc.h
69922 @@ -0,0 +1,9 @@
69923 +#ifndef __GRALLOC_H
69924 +#define __GRALLOC_H
69925 +
69926 +void acl_free_all(void);
69927 +int acl_alloc_stack_init(unsigned long size);
69928 +void *acl_alloc(unsigned long len);
69929 +void *acl_alloc_num(unsigned long num, unsigned long len);
69930 +
69931 +#endif
69932 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69933 new file mode 100644
69934 index 0000000..be66033
69935 --- /dev/null
69936 +++ b/include/linux/grdefs.h
69937 @@ -0,0 +1,140 @@
69938 +#ifndef GRDEFS_H
69939 +#define GRDEFS_H
69940 +
69941 +/* Begin grsecurity status declarations */
69942 +
69943 +enum {
69944 + GR_READY = 0x01,
69945 + GR_STATUS_INIT = 0x00 // disabled state
69946 +};
69947 +
69948 +/* Begin ACL declarations */
69949 +
69950 +/* Role flags */
69951 +
69952 +enum {
69953 + GR_ROLE_USER = 0x0001,
69954 + GR_ROLE_GROUP = 0x0002,
69955 + GR_ROLE_DEFAULT = 0x0004,
69956 + GR_ROLE_SPECIAL = 0x0008,
69957 + GR_ROLE_AUTH = 0x0010,
69958 + GR_ROLE_NOPW = 0x0020,
69959 + GR_ROLE_GOD = 0x0040,
69960 + GR_ROLE_LEARN = 0x0080,
69961 + GR_ROLE_TPE = 0x0100,
69962 + GR_ROLE_DOMAIN = 0x0200,
69963 + GR_ROLE_PAM = 0x0400,
69964 + GR_ROLE_PERSIST = 0x0800
69965 +};
69966 +
69967 +/* ACL Subject and Object mode flags */
69968 +enum {
69969 + GR_DELETED = 0x80000000
69970 +};
69971 +
69972 +/* ACL Object-only mode flags */
69973 +enum {
69974 + GR_READ = 0x00000001,
69975 + GR_APPEND = 0x00000002,
69976 + GR_WRITE = 0x00000004,
69977 + GR_EXEC = 0x00000008,
69978 + GR_FIND = 0x00000010,
69979 + GR_INHERIT = 0x00000020,
69980 + GR_SETID = 0x00000040,
69981 + GR_CREATE = 0x00000080,
69982 + GR_DELETE = 0x00000100,
69983 + GR_LINK = 0x00000200,
69984 + GR_AUDIT_READ = 0x00000400,
69985 + GR_AUDIT_APPEND = 0x00000800,
69986 + GR_AUDIT_WRITE = 0x00001000,
69987 + GR_AUDIT_EXEC = 0x00002000,
69988 + GR_AUDIT_FIND = 0x00004000,
69989 + GR_AUDIT_INHERIT= 0x00008000,
69990 + GR_AUDIT_SETID = 0x00010000,
69991 + GR_AUDIT_CREATE = 0x00020000,
69992 + GR_AUDIT_DELETE = 0x00040000,
69993 + GR_AUDIT_LINK = 0x00080000,
69994 + GR_PTRACERD = 0x00100000,
69995 + GR_NOPTRACE = 0x00200000,
69996 + GR_SUPPRESS = 0x00400000,
69997 + GR_NOLEARN = 0x00800000,
69998 + GR_INIT_TRANSFER= 0x01000000
69999 +};
70000 +
70001 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
70002 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
70003 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
70004 +
70005 +/* ACL subject-only mode flags */
70006 +enum {
70007 + GR_KILL = 0x00000001,
70008 + GR_VIEW = 0x00000002,
70009 + GR_PROTECTED = 0x00000004,
70010 + GR_LEARN = 0x00000008,
70011 + GR_OVERRIDE = 0x00000010,
70012 + /* just a placeholder, this mode is only used in userspace */
70013 + GR_DUMMY = 0x00000020,
70014 + GR_PROTSHM = 0x00000040,
70015 + GR_KILLPROC = 0x00000080,
70016 + GR_KILLIPPROC = 0x00000100,
70017 + /* just a placeholder, this mode is only used in userspace */
70018 + GR_NOTROJAN = 0x00000200,
70019 + GR_PROTPROCFD = 0x00000400,
70020 + GR_PROCACCT = 0x00000800,
70021 + GR_RELAXPTRACE = 0x00001000,
70022 + //GR_NESTED = 0x00002000,
70023 + GR_INHERITLEARN = 0x00004000,
70024 + GR_PROCFIND = 0x00008000,
70025 + GR_POVERRIDE = 0x00010000,
70026 + GR_KERNELAUTH = 0x00020000,
70027 + GR_ATSECURE = 0x00040000,
70028 + GR_SHMEXEC = 0x00080000
70029 +};
70030 +
70031 +enum {
70032 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
70033 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
70034 + GR_PAX_ENABLE_MPROTECT = 0x0004,
70035 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
70036 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
70037 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
70038 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
70039 + GR_PAX_DISABLE_MPROTECT = 0x0400,
70040 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
70041 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
70042 +};
70043 +
70044 +enum {
70045 + GR_ID_USER = 0x01,
70046 + GR_ID_GROUP = 0x02,
70047 +};
70048 +
70049 +enum {
70050 + GR_ID_ALLOW = 0x01,
70051 + GR_ID_DENY = 0x02,
70052 +};
70053 +
70054 +#define GR_CRASH_RES 31
70055 +#define GR_UIDTABLE_MAX 500
70056 +
70057 +/* begin resource learning section */
70058 +enum {
70059 + GR_RLIM_CPU_BUMP = 60,
70060 + GR_RLIM_FSIZE_BUMP = 50000,
70061 + GR_RLIM_DATA_BUMP = 10000,
70062 + GR_RLIM_STACK_BUMP = 1000,
70063 + GR_RLIM_CORE_BUMP = 10000,
70064 + GR_RLIM_RSS_BUMP = 500000,
70065 + GR_RLIM_NPROC_BUMP = 1,
70066 + GR_RLIM_NOFILE_BUMP = 5,
70067 + GR_RLIM_MEMLOCK_BUMP = 50000,
70068 + GR_RLIM_AS_BUMP = 500000,
70069 + GR_RLIM_LOCKS_BUMP = 2,
70070 + GR_RLIM_SIGPENDING_BUMP = 5,
70071 + GR_RLIM_MSGQUEUE_BUMP = 10000,
70072 + GR_RLIM_NICE_BUMP = 1,
70073 + GR_RLIM_RTPRIO_BUMP = 1,
70074 + GR_RLIM_RTTIME_BUMP = 1000000
70075 +};
70076 +
70077 +#endif
70078 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
70079 new file mode 100644
70080 index 0000000..fd8598b
70081 --- /dev/null
70082 +++ b/include/linux/grinternal.h
70083 @@ -0,0 +1,228 @@
70084 +#ifndef __GRINTERNAL_H
70085 +#define __GRINTERNAL_H
70086 +
70087 +#ifdef CONFIG_GRKERNSEC
70088 +
70089 +#include <linux/fs.h>
70090 +#include <linux/mnt_namespace.h>
70091 +#include <linux/nsproxy.h>
70092 +#include <linux/gracl.h>
70093 +#include <linux/grdefs.h>
70094 +#include <linux/grmsg.h>
70095 +
70096 +void gr_add_learn_entry(const char *fmt, ...)
70097 + __attribute__ ((format (printf, 1, 2)));
70098 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
70099 + const struct vfsmount *mnt);
70100 +__u32 gr_check_create(const struct dentry *new_dentry,
70101 + const struct dentry *parent,
70102 + const struct vfsmount *mnt, const __u32 mode);
70103 +int gr_check_protected_task(const struct task_struct *task);
70104 +__u32 to_gr_audit(const __u32 reqmode);
70105 +int gr_set_acls(const int type);
70106 +int gr_apply_subject_to_task(struct task_struct *task);
70107 +int gr_acl_is_enabled(void);
70108 +char gr_roletype_to_char(void);
70109 +
70110 +void gr_handle_alertkill(struct task_struct *task);
70111 +char *gr_to_filename(const struct dentry *dentry,
70112 + const struct vfsmount *mnt);
70113 +char *gr_to_filename1(const struct dentry *dentry,
70114 + const struct vfsmount *mnt);
70115 +char *gr_to_filename2(const struct dentry *dentry,
70116 + const struct vfsmount *mnt);
70117 +char *gr_to_filename3(const struct dentry *dentry,
70118 + const struct vfsmount *mnt);
70119 +
70120 +extern int grsec_enable_ptrace_readexec;
70121 +extern int grsec_enable_harden_ptrace;
70122 +extern int grsec_enable_link;
70123 +extern int grsec_enable_fifo;
70124 +extern int grsec_enable_execve;
70125 +extern int grsec_enable_shm;
70126 +extern int grsec_enable_execlog;
70127 +extern int grsec_enable_signal;
70128 +extern int grsec_enable_audit_ptrace;
70129 +extern int grsec_enable_forkfail;
70130 +extern int grsec_enable_time;
70131 +extern int grsec_enable_rofs;
70132 +extern int grsec_enable_chroot_shmat;
70133 +extern int grsec_enable_chroot_mount;
70134 +extern int grsec_enable_chroot_double;
70135 +extern int grsec_enable_chroot_pivot;
70136 +extern int grsec_enable_chroot_chdir;
70137 +extern int grsec_enable_chroot_chmod;
70138 +extern int grsec_enable_chroot_mknod;
70139 +extern int grsec_enable_chroot_fchdir;
70140 +extern int grsec_enable_chroot_nice;
70141 +extern int grsec_enable_chroot_execlog;
70142 +extern int grsec_enable_chroot_caps;
70143 +extern int grsec_enable_chroot_sysctl;
70144 +extern int grsec_enable_chroot_unix;
70145 +extern int grsec_enable_symlinkown;
70146 +extern kgid_t grsec_symlinkown_gid;
70147 +extern int grsec_enable_tpe;
70148 +extern kgid_t grsec_tpe_gid;
70149 +extern int grsec_enable_tpe_all;
70150 +extern int grsec_enable_tpe_invert;
70151 +extern int grsec_enable_socket_all;
70152 +extern kgid_t grsec_socket_all_gid;
70153 +extern int grsec_enable_socket_client;
70154 +extern kgid_t grsec_socket_client_gid;
70155 +extern int grsec_enable_socket_server;
70156 +extern kgid_t grsec_socket_server_gid;
70157 +extern kgid_t grsec_audit_gid;
70158 +extern int grsec_enable_group;
70159 +extern int grsec_enable_log_rwxmaps;
70160 +extern int grsec_enable_mount;
70161 +extern int grsec_enable_chdir;
70162 +extern int grsec_resource_logging;
70163 +extern int grsec_enable_blackhole;
70164 +extern int grsec_lastack_retries;
70165 +extern int grsec_enable_brute;
70166 +extern int grsec_lock;
70167 +
70168 +extern spinlock_t grsec_alert_lock;
70169 +extern unsigned long grsec_alert_wtime;
70170 +extern unsigned long grsec_alert_fyet;
70171 +
70172 +extern spinlock_t grsec_audit_lock;
70173 +
70174 +extern rwlock_t grsec_exec_file_lock;
70175 +
70176 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
70177 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
70178 + (tsk)->exec_file->f_path.mnt) : "/")
70179 +
70180 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
70181 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
70182 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
70183 +
70184 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
70185 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
70186 + (tsk)->exec_file->f_path.mnt) : "/")
70187 +
70188 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
70189 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
70190 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
70191 +
70192 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
70193 +
70194 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
70195 +
70196 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
70197 +{
70198 + if (file1 && file2) {
70199 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
70200 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
70201 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
70202 + return true;
70203 + }
70204 +
70205 + return false;
70206 +}
70207 +
70208 +#define GR_CHROOT_CAPS {{ \
70209 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
70210 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
70211 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
70212 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
70213 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
70214 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
70215 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
70216 +
70217 +#define security_learn(normal_msg,args...) \
70218 +({ \
70219 + read_lock(&grsec_exec_file_lock); \
70220 + gr_add_learn_entry(normal_msg "\n", ## args); \
70221 + read_unlock(&grsec_exec_file_lock); \
70222 +})
70223 +
70224 +enum {
70225 + GR_DO_AUDIT,
70226 + GR_DONT_AUDIT,
70227 + /* used for non-audit messages that we shouldn't kill the task on */
70228 + GR_DONT_AUDIT_GOOD
70229 +};
70230 +
70231 +enum {
70232 + GR_TTYSNIFF,
70233 + GR_RBAC,
70234 + GR_RBAC_STR,
70235 + GR_STR_RBAC,
70236 + GR_RBAC_MODE2,
70237 + GR_RBAC_MODE3,
70238 + GR_FILENAME,
70239 + GR_SYSCTL_HIDDEN,
70240 + GR_NOARGS,
70241 + GR_ONE_INT,
70242 + GR_ONE_INT_TWO_STR,
70243 + GR_ONE_STR,
70244 + GR_STR_INT,
70245 + GR_TWO_STR_INT,
70246 + GR_TWO_INT,
70247 + GR_TWO_U64,
70248 + GR_THREE_INT,
70249 + GR_FIVE_INT_TWO_STR,
70250 + GR_TWO_STR,
70251 + GR_THREE_STR,
70252 + GR_FOUR_STR,
70253 + GR_STR_FILENAME,
70254 + GR_FILENAME_STR,
70255 + GR_FILENAME_TWO_INT,
70256 + GR_FILENAME_TWO_INT_STR,
70257 + GR_TEXTREL,
70258 + GR_PTRACE,
70259 + GR_RESOURCE,
70260 + GR_CAP,
70261 + GR_SIG,
70262 + GR_SIG2,
70263 + GR_CRASH1,
70264 + GR_CRASH2,
70265 + GR_PSACCT,
70266 + GR_RWXMAP,
70267 + GR_RWXMAPVMA
70268 +};
70269 +
70270 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
70271 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
70272 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
70273 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
70274 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
70275 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
70276 +#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)
70277 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
70278 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
70279 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
70280 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
70281 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
70282 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
70283 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
70284 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
70285 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
70286 +#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)
70287 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
70288 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
70289 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
70290 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
70291 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
70292 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
70293 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
70294 +#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)
70295 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
70296 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
70297 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
70298 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
70299 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
70300 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
70301 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
70302 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
70303 +#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)
70304 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
70305 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
70306 +
70307 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
70308 +
70309 +#endif
70310 +
70311 +#endif
70312 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
70313 new file mode 100644
70314 index 0000000..a4396b5
70315 --- /dev/null
70316 +++ b/include/linux/grmsg.h
70317 @@ -0,0 +1,113 @@
70318 +#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"
70319 +#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"
70320 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
70321 +#define GR_STOPMOD_MSG "denied modification of module state by "
70322 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
70323 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
70324 +#define GR_IOPERM_MSG "denied use of ioperm() by "
70325 +#define GR_IOPL_MSG "denied use of iopl() by "
70326 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
70327 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
70328 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
70329 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
70330 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
70331 +#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"
70332 +#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"
70333 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
70334 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
70335 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
70336 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
70337 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
70338 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
70339 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
70340 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
70341 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
70342 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
70343 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
70344 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
70345 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
70346 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
70347 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
70348 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
70349 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
70350 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
70351 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
70352 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
70353 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
70354 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
70355 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
70356 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
70357 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
70358 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
70359 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
70360 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
70361 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
70362 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
70363 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
70364 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
70365 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
70366 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
70367 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
70368 +#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"
70369 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
70370 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
70371 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
70372 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
70373 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
70374 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
70375 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
70376 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
70377 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
70378 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
70379 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
70380 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
70381 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
70382 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
70383 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
70384 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
70385 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
70386 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
70387 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
70388 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
70389 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
70390 +#define GR_NICE_CHROOT_MSG "denied priority change by "
70391 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
70392 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
70393 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
70394 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
70395 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
70396 +#define GR_TIME_MSG "time set by "
70397 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
70398 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
70399 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
70400 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
70401 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
70402 +#define GR_BIND_MSG "denied bind() by "
70403 +#define GR_CONNECT_MSG "denied connect() by "
70404 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
70405 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
70406 +#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"
70407 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
70408 +#define GR_CAP_ACL_MSG "use of %s denied for "
70409 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
70410 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
70411 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
70412 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
70413 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
70414 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
70415 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
70416 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
70417 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
70418 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
70419 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
70420 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
70421 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
70422 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
70423 +#define GR_VM86_MSG "denied use of vm86 by "
70424 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
70425 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
70426 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
70427 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
70428 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
70429 +#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 "
70430 +#define GR_BRUTE_SUID_MSG "bruteforce prevention initiated due to crash of %.950s against uid %u, banning suid/sgid execs for %u minutes. Please investigate the crash report for "
70431 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
70432 new file mode 100644
70433 index 0000000..3676b0b
70434 --- /dev/null
70435 +++ b/include/linux/grsecurity.h
70436 @@ -0,0 +1,242 @@
70437 +#ifndef GR_SECURITY_H
70438 +#define GR_SECURITY_H
70439 +#include <linux/fs.h>
70440 +#include <linux/fs_struct.h>
70441 +#include <linux/binfmts.h>
70442 +#include <linux/gracl.h>
70443 +
70444 +/* notify of brain-dead configs */
70445 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70446 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
70447 +#endif
70448 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
70449 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
70450 +#endif
70451 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
70452 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
70453 +#endif
70454 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
70455 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
70456 +#endif
70457 +
70458 +void gr_handle_brute_attach(unsigned long mm_flags);
70459 +void gr_handle_brute_check(void);
70460 +void gr_handle_kernel_exploit(void);
70461 +
70462 +char gr_roletype_to_char(void);
70463 +
70464 +int gr_acl_enable_at_secure(void);
70465 +
70466 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
70467 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
70468 +
70469 +void gr_del_task_from_ip_table(struct task_struct *p);
70470 +
70471 +int gr_pid_is_chrooted(struct task_struct *p);
70472 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
70473 +int gr_handle_chroot_nice(void);
70474 +int gr_handle_chroot_sysctl(const int op);
70475 +int gr_handle_chroot_setpriority(struct task_struct *p,
70476 + const int niceval);
70477 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
70478 +int gr_handle_chroot_chroot(const struct dentry *dentry,
70479 + const struct vfsmount *mnt);
70480 +void gr_handle_chroot_chdir(const struct path *path);
70481 +int gr_handle_chroot_chmod(const struct dentry *dentry,
70482 + const struct vfsmount *mnt, const int mode);
70483 +int gr_handle_chroot_mknod(const struct dentry *dentry,
70484 + const struct vfsmount *mnt, const int mode);
70485 +int gr_handle_chroot_mount(const struct dentry *dentry,
70486 + const struct vfsmount *mnt,
70487 + const char *dev_name);
70488 +int gr_handle_chroot_pivot(void);
70489 +int gr_handle_chroot_unix(const pid_t pid);
70490 +
70491 +int gr_handle_rawio(const struct inode *inode);
70492 +
70493 +void gr_handle_ioperm(void);
70494 +void gr_handle_iopl(void);
70495 +
70496 +umode_t gr_acl_umask(void);
70497 +
70498 +int gr_tpe_allow(const struct file *file);
70499 +
70500 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
70501 +void gr_clear_chroot_entries(struct task_struct *task);
70502 +
70503 +void gr_log_forkfail(const int retval);
70504 +void gr_log_timechange(void);
70505 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
70506 +void gr_log_chdir(const struct dentry *dentry,
70507 + const struct vfsmount *mnt);
70508 +void gr_log_chroot_exec(const struct dentry *dentry,
70509 + const struct vfsmount *mnt);
70510 +void gr_log_remount(const char *devname, const int retval);
70511 +void gr_log_unmount(const char *devname, const int retval);
70512 +void gr_log_mount(const char *from, const char *to, const int retval);
70513 +void gr_log_textrel(struct vm_area_struct *vma);
70514 +void gr_log_ptgnustack(struct file *file);
70515 +void gr_log_rwxmmap(struct file *file);
70516 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
70517 +
70518 +int gr_handle_follow_link(const struct inode *parent,
70519 + const struct inode *inode,
70520 + const struct dentry *dentry,
70521 + const struct vfsmount *mnt);
70522 +int gr_handle_fifo(const struct dentry *dentry,
70523 + const struct vfsmount *mnt,
70524 + const struct dentry *dir, const int flag,
70525 + const int acc_mode);
70526 +int gr_handle_hardlink(const struct dentry *dentry,
70527 + const struct vfsmount *mnt,
70528 + struct inode *inode,
70529 + const int mode, const struct filename *to);
70530 +
70531 +int gr_is_capable(const int cap);
70532 +int gr_is_capable_nolog(const int cap);
70533 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70534 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
70535 +
70536 +void gr_copy_label(struct task_struct *tsk);
70537 +void gr_handle_crash(struct task_struct *task, const int sig);
70538 +int gr_handle_signal(const struct task_struct *p, const int sig);
70539 +int gr_check_crash_uid(const kuid_t uid);
70540 +int gr_check_protected_task(const struct task_struct *task);
70541 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
70542 +int gr_acl_handle_mmap(const struct file *file,
70543 + const unsigned long prot);
70544 +int gr_acl_handle_mprotect(const struct file *file,
70545 + const unsigned long prot);
70546 +int gr_check_hidden_task(const struct task_struct *tsk);
70547 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
70548 + const struct vfsmount *mnt);
70549 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
70550 + const struct vfsmount *mnt);
70551 +__u32 gr_acl_handle_access(const struct dentry *dentry,
70552 + const struct vfsmount *mnt, const int fmode);
70553 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
70554 + const struct vfsmount *mnt, umode_t *mode);
70555 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
70556 + const struct vfsmount *mnt);
70557 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
70558 + const struct vfsmount *mnt);
70559 +int gr_handle_ptrace(struct task_struct *task, const long request);
70560 +int gr_handle_proc_ptrace(struct task_struct *task);
70561 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
70562 + const struct vfsmount *mnt);
70563 +int gr_check_crash_exec(const struct file *filp);
70564 +int gr_acl_is_enabled(void);
70565 +void gr_set_kernel_label(struct task_struct *task);
70566 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
70567 + const kgid_t gid);
70568 +int gr_set_proc_label(const struct dentry *dentry,
70569 + const struct vfsmount *mnt,
70570 + const int unsafe_flags);
70571 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
70572 + const struct vfsmount *mnt);
70573 +__u32 gr_acl_handle_open(const struct dentry *dentry,
70574 + const struct vfsmount *mnt, int acc_mode);
70575 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
70576 + const struct dentry *p_dentry,
70577 + const struct vfsmount *p_mnt,
70578 + int open_flags, int acc_mode, const int imode);
70579 +void gr_handle_create(const struct dentry *dentry,
70580 + const struct vfsmount *mnt);
70581 +void gr_handle_proc_create(const struct dentry *dentry,
70582 + const struct inode *inode);
70583 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
70584 + const struct dentry *parent_dentry,
70585 + const struct vfsmount *parent_mnt,
70586 + const int mode);
70587 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
70588 + const struct dentry *parent_dentry,
70589 + const struct vfsmount *parent_mnt);
70590 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
70591 + const struct vfsmount *mnt);
70592 +void gr_handle_delete(const ino_t ino, const dev_t dev);
70593 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
70594 + const struct vfsmount *mnt);
70595 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
70596 + const struct dentry *parent_dentry,
70597 + const struct vfsmount *parent_mnt,
70598 + const struct filename *from);
70599 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
70600 + const struct dentry *parent_dentry,
70601 + const struct vfsmount *parent_mnt,
70602 + const struct dentry *old_dentry,
70603 + const struct vfsmount *old_mnt, const struct filename *to);
70604 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
70605 +int gr_acl_handle_rename(struct dentry *new_dentry,
70606 + struct dentry *parent_dentry,
70607 + const struct vfsmount *parent_mnt,
70608 + struct dentry *old_dentry,
70609 + struct inode *old_parent_inode,
70610 + struct vfsmount *old_mnt, const struct filename *newname);
70611 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70612 + struct dentry *old_dentry,
70613 + struct dentry *new_dentry,
70614 + struct vfsmount *mnt, const __u8 replace);
70615 +__u32 gr_check_link(const struct dentry *new_dentry,
70616 + const struct dentry *parent_dentry,
70617 + const struct vfsmount *parent_mnt,
70618 + const struct dentry *old_dentry,
70619 + const struct vfsmount *old_mnt);
70620 +int gr_acl_handle_filldir(const struct file *file, const char *name,
70621 + const unsigned int namelen, const ino_t ino);
70622 +
70623 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
70624 + const struct vfsmount *mnt);
70625 +void gr_acl_handle_exit(void);
70626 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
70627 +int gr_acl_handle_procpidmem(const struct task_struct *task);
70628 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
70629 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
70630 +void gr_audit_ptrace(struct task_struct *task);
70631 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
70632 +void gr_put_exec_file(struct task_struct *task);
70633 +
70634 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
70635 +
70636 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
70637 +extern void gr_learn_resource(const struct task_struct *task, const int res,
70638 + const unsigned long wanted, const int gt);
70639 +#else
70640 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
70641 + const unsigned long wanted, const int gt)
70642 +{
70643 +}
70644 +#endif
70645 +
70646 +#ifdef CONFIG_GRKERNSEC_RESLOG
70647 +extern void gr_log_resource(const struct task_struct *task, const int res,
70648 + const unsigned long wanted, const int gt);
70649 +#else
70650 +static inline void gr_log_resource(const struct task_struct *task, const int res,
70651 + const unsigned long wanted, const int gt)
70652 +{
70653 +}
70654 +#endif
70655 +
70656 +#ifdef CONFIG_GRKERNSEC
70657 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
70658 +void gr_handle_vm86(void);
70659 +void gr_handle_mem_readwrite(u64 from, u64 to);
70660 +
70661 +void gr_log_badprocpid(const char *entry);
70662 +
70663 +extern int grsec_enable_dmesg;
70664 +extern int grsec_disable_privio;
70665 +
70666 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
70667 +extern kgid_t grsec_proc_gid;
70668 +#endif
70669 +
70670 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70671 +extern int grsec_enable_chroot_findtask;
70672 +#endif
70673 +#ifdef CONFIG_GRKERNSEC_SETXID
70674 +extern int grsec_enable_setxid;
70675 +#endif
70676 +#endif
70677 +
70678 +#endif
70679 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
70680 new file mode 100644
70681 index 0000000..e7ffaaf
70682 --- /dev/null
70683 +++ b/include/linux/grsock.h
70684 @@ -0,0 +1,19 @@
70685 +#ifndef __GRSOCK_H
70686 +#define __GRSOCK_H
70687 +
70688 +extern void gr_attach_curr_ip(const struct sock *sk);
70689 +extern int gr_handle_sock_all(const int family, const int type,
70690 + const int protocol);
70691 +extern int gr_handle_sock_server(const struct sockaddr *sck);
70692 +extern int gr_handle_sock_server_other(const struct sock *sck);
70693 +extern int gr_handle_sock_client(const struct sockaddr *sck);
70694 +extern int gr_search_connect(struct socket * sock,
70695 + struct sockaddr_in * addr);
70696 +extern int gr_search_bind(struct socket * sock,
70697 + struct sockaddr_in * addr);
70698 +extern int gr_search_listen(struct socket * sock);
70699 +extern int gr_search_accept(struct socket * sock);
70700 +extern int gr_search_socket(const int domain, const int type,
70701 + const int protocol);
70702 +
70703 +#endif
70704 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
70705 index 7fb31da..08b5114 100644
70706 --- a/include/linux/highmem.h
70707 +++ b/include/linux/highmem.h
70708 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
70709 kunmap_atomic(kaddr);
70710 }
70711
70712 +static inline void sanitize_highpage(struct page *page)
70713 +{
70714 + void *kaddr;
70715 + unsigned long flags;
70716 +
70717 + local_irq_save(flags);
70718 + kaddr = kmap_atomic(page);
70719 + clear_page(kaddr);
70720 + kunmap_atomic(kaddr);
70721 + local_irq_restore(flags);
70722 +}
70723 +
70724 static inline void zero_user_segments(struct page *page,
70725 unsigned start1, unsigned end1,
70726 unsigned start2, unsigned end2)
70727 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
70728 index 1c7b89a..7f52502 100644
70729 --- a/include/linux/hwmon-sysfs.h
70730 +++ b/include/linux/hwmon-sysfs.h
70731 @@ -25,7 +25,8 @@
70732 struct sensor_device_attribute{
70733 struct device_attribute dev_attr;
70734 int index;
70735 -};
70736 +} __do_const;
70737 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
70738 #define to_sensor_dev_attr(_dev_attr) \
70739 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
70740
70741 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
70742 struct device_attribute dev_attr;
70743 u8 index;
70744 u8 nr;
70745 -};
70746 +} __do_const;
70747 #define to_sensor_dev_attr_2(_dev_attr) \
70748 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
70749
70750 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
70751 index e988fa9..ff9f17e 100644
70752 --- a/include/linux/i2c.h
70753 +++ b/include/linux/i2c.h
70754 @@ -366,6 +366,7 @@ struct i2c_algorithm {
70755 /* To determine what the adapter supports */
70756 u32 (*functionality) (struct i2c_adapter *);
70757 };
70758 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
70759
70760 /**
70761 * struct i2c_bus_recovery_info - I2C bus recovery information
70762 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
70763 index d23c3c2..eb63c81 100644
70764 --- a/include/linux/i2o.h
70765 +++ b/include/linux/i2o.h
70766 @@ -565,7 +565,7 @@ struct i2o_controller {
70767 struct i2o_device *exec; /* Executive */
70768 #if BITS_PER_LONG == 64
70769 spinlock_t context_list_lock; /* lock for context_list */
70770 - atomic_t context_list_counter; /* needed for unique contexts */
70771 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
70772 struct list_head context_list; /* list of context id's
70773 and pointers */
70774 #endif
70775 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
70776 index aff7ad8..3942bbd 100644
70777 --- a/include/linux/if_pppox.h
70778 +++ b/include/linux/if_pppox.h
70779 @@ -76,7 +76,7 @@ struct pppox_proto {
70780 int (*ioctl)(struct socket *sock, unsigned int cmd,
70781 unsigned long arg);
70782 struct module *owner;
70783 -};
70784 +} __do_const;
70785
70786 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
70787 extern void unregister_pppox_proto(int proto_num);
70788 diff --git a/include/linux/init.h b/include/linux/init.h
70789 index 8618147..0821126 100644
70790 --- a/include/linux/init.h
70791 +++ b/include/linux/init.h
70792 @@ -39,9 +39,36 @@
70793 * Also note, that this data cannot be "const".
70794 */
70795
70796 +#ifdef MODULE
70797 +#define add_init_latent_entropy
70798 +#define add_devinit_latent_entropy
70799 +#define add_cpuinit_latent_entropy
70800 +#define add_meminit_latent_entropy
70801 +#else
70802 +#define add_init_latent_entropy __latent_entropy
70803 +
70804 +#ifdef CONFIG_HOTPLUG
70805 +#define add_devinit_latent_entropy
70806 +#else
70807 +#define add_devinit_latent_entropy __latent_entropy
70808 +#endif
70809 +
70810 +#ifdef CONFIG_HOTPLUG_CPU
70811 +#define add_cpuinit_latent_entropy
70812 +#else
70813 +#define add_cpuinit_latent_entropy __latent_entropy
70814 +#endif
70815 +
70816 +#ifdef CONFIG_MEMORY_HOTPLUG
70817 +#define add_meminit_latent_entropy
70818 +#else
70819 +#define add_meminit_latent_entropy __latent_entropy
70820 +#endif
70821 +#endif
70822 +
70823 /* These are for everybody (although not all archs will actually
70824 discard it in modules) */
70825 -#define __init __section(.init.text) __cold notrace
70826 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
70827 #define __initdata __section(.init.data)
70828 #define __initconst __constsection(.init.rodata)
70829 #define __exitdata __section(.exit.data)
70830 @@ -94,7 +121,7 @@
70831 #define __exit __section(.exit.text) __exitused __cold notrace
70832
70833 /* Used for HOTPLUG_CPU */
70834 -#define __cpuinit __section(.cpuinit.text) __cold notrace
70835 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
70836 #define __cpuinitdata __section(.cpuinit.data)
70837 #define __cpuinitconst __constsection(.cpuinit.rodata)
70838 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
70839 @@ -102,7 +129,7 @@
70840 #define __cpuexitconst __constsection(.cpuexit.rodata)
70841
70842 /* Used for MEMORY_HOTPLUG */
70843 -#define __meminit __section(.meminit.text) __cold notrace
70844 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
70845 #define __meminitdata __section(.meminit.data)
70846 #define __meminitconst __constsection(.meminit.rodata)
70847 #define __memexit __section(.memexit.text) __exitused __cold notrace
70848 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
70849 index 5cd0f09..c9f67cc 100644
70850 --- a/include/linux/init_task.h
70851 +++ b/include/linux/init_task.h
70852 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
70853
70854 #define INIT_TASK_COMM "swapper"
70855
70856 +#ifdef CONFIG_X86
70857 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
70858 +#else
70859 +#define INIT_TASK_THREAD_INFO
70860 +#endif
70861 +
70862 /*
70863 * INIT_TASK is used to set up the first task table, touch at
70864 * your own risk!. Base=0, limit=0x1fffff (=2MB)
70865 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
70866 RCU_POINTER_INITIALIZER(cred, &init_cred), \
70867 .comm = INIT_TASK_COMM, \
70868 .thread = INIT_THREAD, \
70869 + INIT_TASK_THREAD_INFO \
70870 .fs = &init_fs, \
70871 .files = &init_files, \
70872 .signal = &init_signals, \
70873 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
70874 index 5fa5afe..ac55b25 100644
70875 --- a/include/linux/interrupt.h
70876 +++ b/include/linux/interrupt.h
70877 @@ -430,7 +430,7 @@ enum
70878 /* map softirq index to softirq name. update 'softirq_to_name' in
70879 * kernel/softirq.c when adding a new softirq.
70880 */
70881 -extern char *softirq_to_name[NR_SOFTIRQS];
70882 +extern const char * const softirq_to_name[NR_SOFTIRQS];
70883
70884 /* softirq mask and active fields moved to irq_cpustat_t in
70885 * asm/hardirq.h to get better cache usage. KAO
70886 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
70887
70888 struct softirq_action
70889 {
70890 - void (*action)(struct softirq_action *);
70891 -};
70892 + void (*action)(void);
70893 +} __no_const;
70894
70895 asmlinkage void do_softirq(void);
70896 asmlinkage void __do_softirq(void);
70897 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
70898 +extern void open_softirq(int nr, void (*action)(void));
70899 extern void softirq_init(void);
70900 extern void __raise_softirq_irqoff(unsigned int nr);
70901
70902 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
70903 index 3aeb730..2177f39 100644
70904 --- a/include/linux/iommu.h
70905 +++ b/include/linux/iommu.h
70906 @@ -113,7 +113,7 @@ struct iommu_ops {
70907 u32 (*domain_get_windows)(struct iommu_domain *domain);
70908
70909 unsigned long pgsize_bitmap;
70910 -};
70911 +} __do_const;
70912
70913 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70914 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70915 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
70916 index 89b7c24..382af74 100644
70917 --- a/include/linux/ioport.h
70918 +++ b/include/linux/ioport.h
70919 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
70920 int adjust_resource(struct resource *res, resource_size_t start,
70921 resource_size_t size);
70922 resource_size_t resource_alignment(struct resource *res);
70923 -static inline resource_size_t resource_size(const struct resource *res)
70924 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
70925 {
70926 return res->end - res->start + 1;
70927 }
70928 diff --git a/include/linux/irq.h b/include/linux/irq.h
70929 index bc4e066..50468a9 100644
70930 --- a/include/linux/irq.h
70931 +++ b/include/linux/irq.h
70932 @@ -328,7 +328,8 @@ struct irq_chip {
70933 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70934
70935 unsigned long flags;
70936 -};
70937 +} __do_const;
70938 +typedef struct irq_chip __no_const irq_chip_no_const;
70939
70940 /*
70941 * irq_chip specific flags
70942 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
70943 index 3e203eb..3fe68d0 100644
70944 --- a/include/linux/irqchip/arm-gic.h
70945 +++ b/include/linux/irqchip/arm-gic.h
70946 @@ -59,9 +59,11 @@
70947
70948 #ifndef __ASSEMBLY__
70949
70950 +#include <linux/irq.h>
70951 +
70952 struct device_node;
70953
70954 -extern struct irq_chip gic_arch_extn;
70955 +extern irq_chip_no_const gic_arch_extn;
70956
70957 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
70958 u32 offset, struct device_node *);
70959 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70960 index 6883e19..06992b1 100644
70961 --- a/include/linux/kallsyms.h
70962 +++ b/include/linux/kallsyms.h
70963 @@ -15,7 +15,8 @@
70964
70965 struct module;
70966
70967 -#ifdef CONFIG_KALLSYMS
70968 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70969 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70970 /* Lookup the address for a symbol. Returns 0 if not found. */
70971 unsigned long kallsyms_lookup_name(const char *name);
70972
70973 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70974 /* Stupid that this does nothing, but I didn't create this mess. */
70975 #define __print_symbol(fmt, addr)
70976 #endif /*CONFIG_KALLSYMS*/
70977 +#else /* when included by kallsyms.c, vsnprintf.c, or
70978 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70979 +extern void __print_symbol(const char *fmt, unsigned long address);
70980 +extern int sprint_backtrace(char *buffer, unsigned long address);
70981 +extern int sprint_symbol(char *buffer, unsigned long address);
70982 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70983 +const char *kallsyms_lookup(unsigned long addr,
70984 + unsigned long *symbolsize,
70985 + unsigned long *offset,
70986 + char **modname, char *namebuf);
70987 +#endif
70988
70989 /* This macro allows us to keep printk typechecking */
70990 static __printf(1, 2)
70991 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70992 index 518a53a..5e28358 100644
70993 --- a/include/linux/key-type.h
70994 +++ b/include/linux/key-type.h
70995 @@ -125,7 +125,7 @@ struct key_type {
70996 /* internal fields */
70997 struct list_head link; /* link in types list */
70998 struct lock_class_key lock_class; /* key->sem lock class */
70999 -};
71000 +} __do_const;
71001
71002 extern struct key_type key_type_keyring;
71003
71004 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
71005 index c6e091b..a940adf 100644
71006 --- a/include/linux/kgdb.h
71007 +++ b/include/linux/kgdb.h
71008 @@ -52,7 +52,7 @@ extern int kgdb_connected;
71009 extern int kgdb_io_module_registered;
71010
71011 extern atomic_t kgdb_setting_breakpoint;
71012 -extern atomic_t kgdb_cpu_doing_single_step;
71013 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
71014
71015 extern struct task_struct *kgdb_usethread;
71016 extern struct task_struct *kgdb_contthread;
71017 @@ -254,7 +254,7 @@ struct kgdb_arch {
71018 void (*correct_hw_break)(void);
71019
71020 void (*enable_nmi)(bool on);
71021 -};
71022 +} __do_const;
71023
71024 /**
71025 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
71026 @@ -279,7 +279,7 @@ struct kgdb_io {
71027 void (*pre_exception) (void);
71028 void (*post_exception) (void);
71029 int is_console;
71030 -};
71031 +} __do_const;
71032
71033 extern struct kgdb_arch arch_kgdb_ops;
71034
71035 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
71036 index 0555cc6..b16a7a4 100644
71037 --- a/include/linux/kmod.h
71038 +++ b/include/linux/kmod.h
71039 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
71040 * usually useless though. */
71041 extern __printf(2, 3)
71042 int __request_module(bool wait, const char *name, ...);
71043 +extern __printf(3, 4)
71044 +int ___request_module(bool wait, char *param_name, const char *name, ...);
71045 #define request_module(mod...) __request_module(true, mod)
71046 #define request_module_nowait(mod...) __request_module(false, mod)
71047 #define try_then_request_module(x, mod...) \
71048 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
71049 index 939b112..ed6ed51 100644
71050 --- a/include/linux/kobject.h
71051 +++ b/include/linux/kobject.h
71052 @@ -111,7 +111,7 @@ struct kobj_type {
71053 struct attribute **default_attrs;
71054 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
71055 const void *(*namespace)(struct kobject *kobj);
71056 -};
71057 +} __do_const;
71058
71059 struct kobj_uevent_env {
71060 char *envp[UEVENT_NUM_ENVP];
71061 @@ -134,6 +134,7 @@ struct kobj_attribute {
71062 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
71063 const char *buf, size_t count);
71064 };
71065 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
71066
71067 extern const struct sysfs_ops kobj_sysfs_ops;
71068
71069 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
71070 index f66b065..c2c29b4 100644
71071 --- a/include/linux/kobject_ns.h
71072 +++ b/include/linux/kobject_ns.h
71073 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
71074 const void *(*netlink_ns)(struct sock *sk);
71075 const void *(*initial_ns)(void);
71076 void (*drop_ns)(void *);
71077 -};
71078 +} __do_const;
71079
71080 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
71081 int kobj_ns_type_registered(enum kobj_ns_type type);
71082 diff --git a/include/linux/kref.h b/include/linux/kref.h
71083 index 484604d..0f6c5b6 100644
71084 --- a/include/linux/kref.h
71085 +++ b/include/linux/kref.h
71086 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
71087 static inline int kref_sub(struct kref *kref, unsigned int count,
71088 void (*release)(struct kref *kref))
71089 {
71090 - WARN_ON(release == NULL);
71091 + BUG_ON(release == NULL);
71092
71093 if (atomic_sub_and_test((int) count, &kref->refcount)) {
71094 release(kref);
71095 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
71096 index 8db53cf..c21121d 100644
71097 --- a/include/linux/kvm_host.h
71098 +++ b/include/linux/kvm_host.h
71099 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
71100 {
71101 }
71102 #endif
71103 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
71104 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
71105 struct module *module);
71106 void kvm_exit(void);
71107
71108 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
71109 struct kvm_guest_debug *dbg);
71110 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
71111
71112 -int kvm_arch_init(void *opaque);
71113 +int kvm_arch_init(const void *opaque);
71114 void kvm_arch_exit(void);
71115
71116 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
71117 diff --git a/include/linux/libata.h b/include/linux/libata.h
71118 index eae7a05..2cdd875 100644
71119 --- a/include/linux/libata.h
71120 +++ b/include/linux/libata.h
71121 @@ -919,7 +919,7 @@ struct ata_port_operations {
71122 * fields must be pointers.
71123 */
71124 const struct ata_port_operations *inherits;
71125 -};
71126 +} __do_const;
71127
71128 struct ata_port_info {
71129 unsigned long flags;
71130 diff --git a/include/linux/list.h b/include/linux/list.h
71131 index b83e565..baa6c1d 100644
71132 --- a/include/linux/list.h
71133 +++ b/include/linux/list.h
71134 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
71135 extern void list_del(struct list_head *entry);
71136 #endif
71137
71138 +extern void __pax_list_add(struct list_head *new,
71139 + struct list_head *prev,
71140 + struct list_head *next);
71141 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
71142 +{
71143 + __pax_list_add(new, head, head->next);
71144 +}
71145 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
71146 +{
71147 + __pax_list_add(new, head->prev, head);
71148 +}
71149 +extern void pax_list_del(struct list_head *entry);
71150 +
71151 /**
71152 * list_replace - replace old entry by new one
71153 * @old : the element to be replaced
71154 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
71155 INIT_LIST_HEAD(entry);
71156 }
71157
71158 +extern void pax_list_del_init(struct list_head *entry);
71159 +
71160 /**
71161 * list_move - delete from one list and add as another's head
71162 * @list: the entry to move
71163 diff --git a/include/linux/math64.h b/include/linux/math64.h
71164 index 2913b86..4209244 100644
71165 --- a/include/linux/math64.h
71166 +++ b/include/linux/math64.h
71167 @@ -15,7 +15,7 @@
71168 * This is commonly provided by 32bit archs to provide an optimized 64bit
71169 * divide.
71170 */
71171 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71172 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71173 {
71174 *remainder = dividend % divisor;
71175 return dividend / divisor;
71176 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
71177 #define div64_ul(x, y) div_u64((x), (y))
71178
71179 #ifndef div_u64_rem
71180 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71181 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
71182 {
71183 *remainder = do_div(dividend, divisor);
71184 return dividend;
71185 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
71186 * divide.
71187 */
71188 #ifndef div_u64
71189 -static inline u64 div_u64(u64 dividend, u32 divisor)
71190 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
71191 {
71192 u32 remainder;
71193 return div_u64_rem(dividend, divisor, &remainder);
71194 diff --git a/include/linux/mm.h b/include/linux/mm.h
71195 index e0c8528..bcf0c29 100644
71196 --- a/include/linux/mm.h
71197 +++ b/include/linux/mm.h
71198 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
71199 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
71200 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
71201 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
71202 +
71203 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
71204 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
71205 +#endif
71206 +
71207 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
71208
71209 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
71210 @@ -205,8 +210,8 @@ struct vm_operations_struct {
71211 /* called by access_process_vm when get_user_pages() fails, typically
71212 * for use by special VMAs that can switch between memory and hardware
71213 */
71214 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
71215 - void *buf, int len, int write);
71216 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
71217 + void *buf, size_t len, int write);
71218 #ifdef CONFIG_NUMA
71219 /*
71220 * set_policy() op must add a reference to any non-NULL @new mempolicy
71221 @@ -236,6 +241,7 @@ struct vm_operations_struct {
71222 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
71223 unsigned long size, pgoff_t pgoff);
71224 };
71225 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
71226
71227 struct mmu_gather;
71228 struct inode;
71229 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
71230 unsigned long *pfn);
71231 int follow_phys(struct vm_area_struct *vma, unsigned long address,
71232 unsigned int flags, unsigned long *prot, resource_size_t *phys);
71233 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
71234 - void *buf, int len, int write);
71235 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
71236 + void *buf, size_t len, int write);
71237
71238 static inline void unmap_shared_mapping_range(struct address_space *mapping,
71239 loff_t const holebegin, loff_t const holelen)
71240 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
71241 }
71242 #endif
71243
71244 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
71245 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
71246 - void *buf, int len, int write);
71247 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
71248 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
71249 + void *buf, size_t len, int write);
71250
71251 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
71252 unsigned long start, unsigned long nr_pages,
71253 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
71254 int set_page_dirty_lock(struct page *page);
71255 int clear_page_dirty_for_io(struct page *page);
71256
71257 -/* Is the vma a continuation of the stack vma above it? */
71258 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
71259 -{
71260 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
71261 -}
71262 -
71263 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
71264 - unsigned long addr)
71265 -{
71266 - return (vma->vm_flags & VM_GROWSDOWN) &&
71267 - (vma->vm_start == addr) &&
71268 - !vma_growsdown(vma->vm_prev, addr);
71269 -}
71270 -
71271 -/* Is the vma a continuation of the stack vma below it? */
71272 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
71273 -{
71274 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
71275 -}
71276 -
71277 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
71278 - unsigned long addr)
71279 -{
71280 - return (vma->vm_flags & VM_GROWSUP) &&
71281 - (vma->vm_end == addr) &&
71282 - !vma_growsup(vma->vm_next, addr);
71283 -}
71284 -
71285 extern pid_t
71286 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
71287
71288 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
71289 }
71290 #endif
71291
71292 +#ifdef CONFIG_MMU
71293 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
71294 +#else
71295 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
71296 +{
71297 + return __pgprot(0);
71298 +}
71299 +#endif
71300 +
71301 int vma_wants_writenotify(struct vm_area_struct *vma);
71302
71303 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
71304 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
71305 {
71306 return 0;
71307 }
71308 +
71309 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
71310 + unsigned long address)
71311 +{
71312 + return 0;
71313 +}
71314 #else
71315 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
71316 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
71317 #endif
71318
71319 #ifdef __PAGETABLE_PMD_FOLDED
71320 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
71321 {
71322 return 0;
71323 }
71324 +
71325 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
71326 + unsigned long address)
71327 +{
71328 + return 0;
71329 +}
71330 #else
71331 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
71332 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
71333 #endif
71334
71335 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
71336 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
71337 NULL: pud_offset(pgd, address);
71338 }
71339
71340 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
71341 +{
71342 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
71343 + NULL: pud_offset(pgd, address);
71344 +}
71345 +
71346 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
71347 {
71348 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
71349 NULL: pmd_offset(pud, address);
71350 }
71351 +
71352 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
71353 +{
71354 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
71355 + NULL: pmd_offset(pud, address);
71356 +}
71357 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
71358
71359 #if USE_SPLIT_PTLOCKS
71360 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
71361 unsigned long len, unsigned long prot, unsigned long flags,
71362 unsigned long pgoff, unsigned long *populate);
71363 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
71364 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
71365
71366 #ifdef CONFIG_MMU
71367 extern int __mm_populate(unsigned long addr, unsigned long len,
71368 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
71369 unsigned long high_limit;
71370 unsigned long align_mask;
71371 unsigned long align_offset;
71372 + unsigned long threadstack_offset;
71373 };
71374
71375 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
71376 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
71377 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
71378 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
71379
71380 /*
71381 * Search for an unmapped address range.
71382 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
71383 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
71384 */
71385 static inline unsigned long
71386 -vm_unmapped_area(struct vm_unmapped_area_info *info)
71387 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
71388 {
71389 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
71390 return unmapped_area(info);
71391 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
71392 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
71393 struct vm_area_struct **pprev);
71394
71395 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
71396 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
71397 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
71398 +
71399 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
71400 NULL if none. Assume start_addr < end_addr. */
71401 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
71402 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
71403 return vma;
71404 }
71405
71406 -#ifdef CONFIG_MMU
71407 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
71408 -#else
71409 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
71410 -{
71411 - return __pgprot(0);
71412 -}
71413 -#endif
71414 -
71415 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
71416 unsigned long change_prot_numa(struct vm_area_struct *vma,
71417 unsigned long start, unsigned long end);
71418 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
71419 static inline void vm_stat_account(struct mm_struct *mm,
71420 unsigned long flags, struct file *file, long pages)
71421 {
71422 +
71423 +#ifdef CONFIG_PAX_RANDMMAP
71424 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
71425 +#endif
71426 +
71427 mm->total_vm += pages;
71428 }
71429 #endif /* CONFIG_PROC_FS */
71430 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
71431 extern int sysctl_memory_failure_early_kill;
71432 extern int sysctl_memory_failure_recovery;
71433 extern void shake_page(struct page *p, int access);
71434 -extern atomic_long_t num_poisoned_pages;
71435 +extern atomic_long_unchecked_t num_poisoned_pages;
71436 extern int soft_offline_page(struct page *page, int flags);
71437
71438 extern void dump_page(struct page *page);
71439 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
71440 static inline void setup_nr_node_ids(void) {}
71441 #endif
71442
71443 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
71444 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
71445 +#else
71446 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
71447 +#endif
71448 +
71449 #endif /* __KERNEL__ */
71450 #endif /* _LINUX_MM_H */
71451 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
71452 index ace9a5f..81bdb59 100644
71453 --- a/include/linux/mm_types.h
71454 +++ b/include/linux/mm_types.h
71455 @@ -289,6 +289,8 @@ struct vm_area_struct {
71456 #ifdef CONFIG_NUMA
71457 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
71458 #endif
71459 +
71460 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
71461 };
71462
71463 struct core_thread {
71464 @@ -437,6 +439,24 @@ struct mm_struct {
71465 int first_nid;
71466 #endif
71467 struct uprobes_state uprobes_state;
71468 +
71469 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71470 + unsigned long pax_flags;
71471 +#endif
71472 +
71473 +#ifdef CONFIG_PAX_DLRESOLVE
71474 + unsigned long call_dl_resolve;
71475 +#endif
71476 +
71477 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
71478 + unsigned long call_syscall;
71479 +#endif
71480 +
71481 +#ifdef CONFIG_PAX_ASLR
71482 + unsigned long delta_mmap; /* randomized offset */
71483 + unsigned long delta_stack; /* randomized offset */
71484 +#endif
71485 +
71486 };
71487
71488 /* first nid will either be a valid NID or one of these values */
71489 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
71490 index c5d5278..f0b68c8 100644
71491 --- a/include/linux/mmiotrace.h
71492 +++ b/include/linux/mmiotrace.h
71493 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
71494 /* Called from ioremap.c */
71495 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
71496 void __iomem *addr);
71497 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
71498 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
71499
71500 /* For anyone to insert markers. Remember trailing newline. */
71501 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
71502 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
71503 {
71504 }
71505
71506 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
71507 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
71508 {
71509 }
71510
71511 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
71512 index 5c76737..61f518e 100644
71513 --- a/include/linux/mmzone.h
71514 +++ b/include/linux/mmzone.h
71515 @@ -396,7 +396,7 @@ struct zone {
71516 unsigned long flags; /* zone flags, see below */
71517
71518 /* Zone statistics */
71519 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71520 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71521
71522 /*
71523 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
71524 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
71525 index b508016..237cfe5 100644
71526 --- a/include/linux/mod_devicetable.h
71527 +++ b/include/linux/mod_devicetable.h
71528 @@ -13,7 +13,7 @@
71529 typedef unsigned long kernel_ulong_t;
71530 #endif
71531
71532 -#define PCI_ANY_ID (~0)
71533 +#define PCI_ANY_ID ((__u16)~0)
71534
71535 struct pci_device_id {
71536 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
71537 @@ -139,7 +139,7 @@ struct usb_device_id {
71538 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
71539 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
71540
71541 -#define HID_ANY_ID (~0)
71542 +#define HID_ANY_ID (~0U)
71543 #define HID_BUS_ANY 0xffff
71544 #define HID_GROUP_ANY 0x0000
71545
71546 @@ -465,7 +465,7 @@ struct dmi_system_id {
71547 const char *ident;
71548 struct dmi_strmatch matches[4];
71549 void *driver_data;
71550 -};
71551 +} __do_const;
71552 /*
71553 * struct dmi_device_id appears during expansion of
71554 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
71555 diff --git a/include/linux/module.h b/include/linux/module.h
71556 index 46f1ea0..a34ca37 100644
71557 --- a/include/linux/module.h
71558 +++ b/include/linux/module.h
71559 @@ -17,9 +17,11 @@
71560 #include <linux/moduleparam.h>
71561 #include <linux/tracepoint.h>
71562 #include <linux/export.h>
71563 +#include <linux/fs.h>
71564
71565 #include <linux/percpu.h>
71566 #include <asm/module.h>
71567 +#include <asm/pgtable.h>
71568
71569 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
71570 #define MODULE_SIG_STRING "~Module signature appended~\n"
71571 @@ -54,12 +56,13 @@ struct module_attribute {
71572 int (*test)(struct module *);
71573 void (*free)(struct module *);
71574 };
71575 +typedef struct module_attribute __no_const module_attribute_no_const;
71576
71577 struct module_version_attribute {
71578 struct module_attribute mattr;
71579 const char *module_name;
71580 const char *version;
71581 -} __attribute__ ((__aligned__(sizeof(void *))));
71582 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
71583
71584 extern ssize_t __modver_version_show(struct module_attribute *,
71585 struct module_kobject *, char *);
71586 @@ -232,7 +235,7 @@ struct module
71587
71588 /* Sysfs stuff. */
71589 struct module_kobject mkobj;
71590 - struct module_attribute *modinfo_attrs;
71591 + module_attribute_no_const *modinfo_attrs;
71592 const char *version;
71593 const char *srcversion;
71594 struct kobject *holders_dir;
71595 @@ -281,19 +284,16 @@ struct module
71596 int (*init)(void);
71597
71598 /* If this is non-NULL, vfree after init() returns */
71599 - void *module_init;
71600 + void *module_init_rx, *module_init_rw;
71601
71602 /* Here is the actual code + data, vfree'd on unload. */
71603 - void *module_core;
71604 + void *module_core_rx, *module_core_rw;
71605
71606 /* Here are the sizes of the init and core sections */
71607 - unsigned int init_size, core_size;
71608 + unsigned int init_size_rw, core_size_rw;
71609
71610 /* The size of the executable code in each section. */
71611 - unsigned int init_text_size, core_text_size;
71612 -
71613 - /* Size of RO sections of the module (text+rodata) */
71614 - unsigned int init_ro_size, core_ro_size;
71615 + unsigned int init_size_rx, core_size_rx;
71616
71617 /* Arch-specific module values */
71618 struct mod_arch_specific arch;
71619 @@ -349,6 +349,10 @@ struct module
71620 #ifdef CONFIG_EVENT_TRACING
71621 struct ftrace_event_call **trace_events;
71622 unsigned int num_trace_events;
71623 + struct file_operations trace_id;
71624 + struct file_operations trace_enable;
71625 + struct file_operations trace_format;
71626 + struct file_operations trace_filter;
71627 #endif
71628 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
71629 unsigned int num_ftrace_callsites;
71630 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
71631 bool is_module_percpu_address(unsigned long addr);
71632 bool is_module_text_address(unsigned long addr);
71633
71634 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
71635 +{
71636 +
71637 +#ifdef CONFIG_PAX_KERNEXEC
71638 + if (ktla_ktva(addr) >= (unsigned long)start &&
71639 + ktla_ktva(addr) < (unsigned long)start + size)
71640 + return 1;
71641 +#endif
71642 +
71643 + return ((void *)addr >= start && (void *)addr < start + size);
71644 +}
71645 +
71646 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
71647 +{
71648 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
71649 +}
71650 +
71651 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
71652 +{
71653 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
71654 +}
71655 +
71656 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
71657 +{
71658 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
71659 +}
71660 +
71661 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
71662 +{
71663 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
71664 +}
71665 +
71666 static inline int within_module_core(unsigned long addr, const struct module *mod)
71667 {
71668 - return (unsigned long)mod->module_core <= addr &&
71669 - addr < (unsigned long)mod->module_core + mod->core_size;
71670 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
71671 }
71672
71673 static inline int within_module_init(unsigned long addr, const struct module *mod)
71674 {
71675 - return (unsigned long)mod->module_init <= addr &&
71676 - addr < (unsigned long)mod->module_init + mod->init_size;
71677 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
71678 }
71679
71680 /* Search for module by name: must hold module_mutex. */
71681 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
71682 index 560ca53..ef621ef 100644
71683 --- a/include/linux/moduleloader.h
71684 +++ b/include/linux/moduleloader.h
71685 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
71686 sections. Returns NULL on failure. */
71687 void *module_alloc(unsigned long size);
71688
71689 +#ifdef CONFIG_PAX_KERNEXEC
71690 +void *module_alloc_exec(unsigned long size);
71691 +#else
71692 +#define module_alloc_exec(x) module_alloc(x)
71693 +#endif
71694 +
71695 /* Free memory returned from module_alloc. */
71696 void module_free(struct module *mod, void *module_region);
71697
71698 +#ifdef CONFIG_PAX_KERNEXEC
71699 +void module_free_exec(struct module *mod, void *module_region);
71700 +#else
71701 +#define module_free_exec(x, y) module_free((x), (y))
71702 +#endif
71703 +
71704 /*
71705 * Apply the given relocation to the (simplified) ELF. Return -error
71706 * or 0.
71707 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
71708 unsigned int relsec,
71709 struct module *me)
71710 {
71711 +#ifdef CONFIG_MODULES
71712 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
71713 +#endif
71714 return -ENOEXEC;
71715 }
71716 #endif
71717 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
71718 unsigned int relsec,
71719 struct module *me)
71720 {
71721 +#ifdef CONFIG_MODULES
71722 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
71723 +#endif
71724 return -ENOEXEC;
71725 }
71726 #endif
71727 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
71728 index 137b419..fe663ec 100644
71729 --- a/include/linux/moduleparam.h
71730 +++ b/include/linux/moduleparam.h
71731 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
71732 * @len is usually just sizeof(string).
71733 */
71734 #define module_param_string(name, string, len, perm) \
71735 - static const struct kparam_string __param_string_##name \
71736 + static const struct kparam_string __param_string_##name __used \
71737 = { len, string }; \
71738 __module_param_call(MODULE_PARAM_PREFIX, name, \
71739 &param_ops_string, \
71740 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
71741 */
71742 #define module_param_array_named(name, array, type, nump, perm) \
71743 param_check_##type(name, &(array)[0]); \
71744 - static const struct kparam_array __param_arr_##name \
71745 + static const struct kparam_array __param_arr_##name __used \
71746 = { .max = ARRAY_SIZE(array), .num = nump, \
71747 .ops = &param_ops_##type, \
71748 .elemsize = sizeof(array[0]), .elem = array }; \
71749 diff --git a/include/linux/namei.h b/include/linux/namei.h
71750 index 5a5ff57..5ae5070 100644
71751 --- a/include/linux/namei.h
71752 +++ b/include/linux/namei.h
71753 @@ -19,7 +19,7 @@ struct nameidata {
71754 unsigned seq;
71755 int last_type;
71756 unsigned depth;
71757 - char *saved_names[MAX_NESTED_LINKS + 1];
71758 + const char *saved_names[MAX_NESTED_LINKS + 1];
71759 };
71760
71761 /*
71762 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
71763
71764 extern void nd_jump_link(struct nameidata *nd, struct path *path);
71765
71766 -static inline void nd_set_link(struct nameidata *nd, char *path)
71767 +static inline void nd_set_link(struct nameidata *nd, const char *path)
71768 {
71769 nd->saved_names[nd->depth] = path;
71770 }
71771
71772 -static inline char *nd_get_link(struct nameidata *nd)
71773 +static inline const char *nd_get_link(const struct nameidata *nd)
71774 {
71775 return nd->saved_names[nd->depth];
71776 }
71777 diff --git a/include/linux/net.h b/include/linux/net.h
71778 index 99c9f0c..e1cf296 100644
71779 --- a/include/linux/net.h
71780 +++ b/include/linux/net.h
71781 @@ -183,7 +183,7 @@ struct net_proto_family {
71782 int (*create)(struct net *net, struct socket *sock,
71783 int protocol, int kern);
71784 struct module *owner;
71785 -};
71786 +} __do_const;
71787
71788 struct iovec;
71789 struct kvec;
71790 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
71791 index 96e4c21..9cc8278 100644
71792 --- a/include/linux/netdevice.h
71793 +++ b/include/linux/netdevice.h
71794 @@ -1026,6 +1026,7 @@ struct net_device_ops {
71795 int (*ndo_change_carrier)(struct net_device *dev,
71796 bool new_carrier);
71797 };
71798 +typedef struct net_device_ops __no_const net_device_ops_no_const;
71799
71800 /*
71801 * The DEVICE structure.
71802 @@ -1094,7 +1095,7 @@ struct net_device {
71803 int iflink;
71804
71805 struct net_device_stats stats;
71806 - atomic_long_t rx_dropped; /* dropped packets by core network
71807 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
71808 * Do not use this in drivers.
71809 */
71810
71811 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
71812 index 0060fde..481c6ae 100644
71813 --- a/include/linux/netfilter.h
71814 +++ b/include/linux/netfilter.h
71815 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
71816 #endif
71817 /* Use the module struct to lock set/get code in place */
71818 struct module *owner;
71819 -};
71820 +} __do_const;
71821
71822 /* Function to register/unregister hook points. */
71823 int nf_register_hook(struct nf_hook_ops *reg);
71824 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
71825 index d80e275..c3510b8 100644
71826 --- a/include/linux/netfilter/ipset/ip_set.h
71827 +++ b/include/linux/netfilter/ipset/ip_set.h
71828 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
71829 /* Return true if "b" set is the same as "a"
71830 * according to the create set parameters */
71831 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
71832 -};
71833 +} __do_const;
71834
71835 /* The core set type structure */
71836 struct ip_set_type {
71837 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
71838 index cadb740..d7c37c0 100644
71839 --- a/include/linux/netfilter/nfnetlink.h
71840 +++ b/include/linux/netfilter/nfnetlink.h
71841 @@ -16,7 +16,7 @@ struct nfnl_callback {
71842 const struct nlattr * const cda[]);
71843 const struct nla_policy *policy; /* netlink attribute policy */
71844 const u_int16_t attr_count; /* number of nlattr's */
71845 -};
71846 +} __do_const;
71847
71848 struct nfnetlink_subsystem {
71849 const char *name;
71850 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
71851 new file mode 100644
71852 index 0000000..33f4af8
71853 --- /dev/null
71854 +++ b/include/linux/netfilter/xt_gradm.h
71855 @@ -0,0 +1,9 @@
71856 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
71857 +#define _LINUX_NETFILTER_XT_GRADM_H 1
71858 +
71859 +struct xt_gradm_mtinfo {
71860 + __u16 flags;
71861 + __u16 invflags;
71862 +};
71863 +
71864 +#endif
71865 diff --git a/include/linux/nls.h b/include/linux/nls.h
71866 index 5dc635f..35f5e11 100644
71867 --- a/include/linux/nls.h
71868 +++ b/include/linux/nls.h
71869 @@ -31,7 +31,7 @@ struct nls_table {
71870 const unsigned char *charset2upper;
71871 struct module *owner;
71872 struct nls_table *next;
71873 -};
71874 +} __do_const;
71875
71876 /* this value hold the maximum octet of charset */
71877 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
71878 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
71879 index d14a4c3..a078786 100644
71880 --- a/include/linux/notifier.h
71881 +++ b/include/linux/notifier.h
71882 @@ -54,7 +54,8 @@ struct notifier_block {
71883 notifier_fn_t notifier_call;
71884 struct notifier_block __rcu *next;
71885 int priority;
71886 -};
71887 +} __do_const;
71888 +typedef struct notifier_block __no_const notifier_block_no_const;
71889
71890 struct atomic_notifier_head {
71891 spinlock_t lock;
71892 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
71893 index a4c5624..79d6d88 100644
71894 --- a/include/linux/oprofile.h
71895 +++ b/include/linux/oprofile.h
71896 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
71897 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
71898 char const * name, ulong * val);
71899
71900 -/** Create a file for read-only access to an atomic_t. */
71901 +/** Create a file for read-only access to an atomic_unchecked_t. */
71902 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
71903 - char const * name, atomic_t * val);
71904 + char const * name, atomic_unchecked_t * val);
71905
71906 /** create a directory */
71907 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
71908 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
71909 index 8db71dc..a76bf2c 100644
71910 --- a/include/linux/pci_hotplug.h
71911 +++ b/include/linux/pci_hotplug.h
71912 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
71913 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
71914 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
71915 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
71916 -};
71917 +} __do_const;
71918 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
71919
71920 /**
71921 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
71922 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
71923 index c5b6dbf..b124155 100644
71924 --- a/include/linux/perf_event.h
71925 +++ b/include/linux/perf_event.h
71926 @@ -318,8 +318,8 @@ struct perf_event {
71927
71928 enum perf_event_active_state state;
71929 unsigned int attach_state;
71930 - local64_t count;
71931 - atomic64_t child_count;
71932 + local64_t count; /* PaX: fix it one day */
71933 + atomic64_unchecked_t child_count;
71934
71935 /*
71936 * These are the total time in nanoseconds that the event
71937 @@ -370,8 +370,8 @@ struct perf_event {
71938 * These accumulate total time (in nanoseconds) that children
71939 * events have been enabled and running, respectively.
71940 */
71941 - atomic64_t child_total_time_enabled;
71942 - atomic64_t child_total_time_running;
71943 + atomic64_unchecked_t child_total_time_enabled;
71944 + atomic64_unchecked_t child_total_time_running;
71945
71946 /*
71947 * Protect attach/detach and child_list:
71948 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
71949 entry->ip[entry->nr++] = ip;
71950 }
71951
71952 -extern int sysctl_perf_event_paranoid;
71953 +extern int sysctl_perf_event_legitimately_concerned;
71954 extern int sysctl_perf_event_mlock;
71955 extern int sysctl_perf_event_sample_rate;
71956
71957 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
71958 void __user *buffer, size_t *lenp,
71959 loff_t *ppos);
71960
71961 +static inline bool perf_paranoid_any(void)
71962 +{
71963 + return sysctl_perf_event_legitimately_concerned > 2;
71964 +}
71965 +
71966 static inline bool perf_paranoid_tracepoint_raw(void)
71967 {
71968 - return sysctl_perf_event_paranoid > -1;
71969 + return sysctl_perf_event_legitimately_concerned > -1;
71970 }
71971
71972 static inline bool perf_paranoid_cpu(void)
71973 {
71974 - return sysctl_perf_event_paranoid > 0;
71975 + return sysctl_perf_event_legitimately_concerned > 0;
71976 }
71977
71978 static inline bool perf_paranoid_kernel(void)
71979 {
71980 - return sysctl_perf_event_paranoid > 1;
71981 + return sysctl_perf_event_legitimately_concerned > 1;
71982 }
71983
71984 extern void perf_event_init(void);
71985 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
71986 */
71987 #define perf_cpu_notifier(fn) \
71988 do { \
71989 - static struct notifier_block fn##_nb __cpuinitdata = \
71990 + static struct notifier_block fn##_nb = \
71991 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71992 unsigned long cpu = smp_processor_id(); \
71993 unsigned long flags; \
71994 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
71995 struct device_attribute attr;
71996 u64 id;
71997 const char *event_str;
71998 -};
71999 +} __do_const;
72000
72001 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
72002 static struct perf_pmu_events_attr _var = { \
72003 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
72004 index b8809fe..ae4ccd0 100644
72005 --- a/include/linux/pipe_fs_i.h
72006 +++ b/include/linux/pipe_fs_i.h
72007 @@ -47,10 +47,10 @@ struct pipe_inode_info {
72008 struct mutex mutex;
72009 wait_queue_head_t wait;
72010 unsigned int nrbufs, curbuf, buffers;
72011 - unsigned int readers;
72012 - unsigned int writers;
72013 - unsigned int files;
72014 - unsigned int waiting_writers;
72015 + atomic_t readers;
72016 + atomic_t writers;
72017 + atomic_t files;
72018 + atomic_t waiting_writers;
72019 unsigned int r_counter;
72020 unsigned int w_counter;
72021 struct page *tmp_page;
72022 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
72023 index 5f28cae..3d23723 100644
72024 --- a/include/linux/platform_data/usb-ehci-s5p.h
72025 +++ b/include/linux/platform_data/usb-ehci-s5p.h
72026 @@ -14,7 +14,7 @@
72027 struct s5p_ehci_platdata {
72028 int (*phy_init)(struct platform_device *pdev, int type);
72029 int (*phy_exit)(struct platform_device *pdev, int type);
72030 -};
72031 +} __no_const;
72032
72033 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
72034
72035 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
72036 index c256c59..8ea94c7 100644
72037 --- a/include/linux/platform_data/usb-ohci-exynos.h
72038 +++ b/include/linux/platform_data/usb-ohci-exynos.h
72039 @@ -14,7 +14,7 @@
72040 struct exynos4_ohci_platdata {
72041 int (*phy_init)(struct platform_device *pdev, int type);
72042 int (*phy_exit)(struct platform_device *pdev, int type);
72043 -};
72044 +} __no_const;
72045
72046 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
72047
72048 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
72049 index 7c1d252..c5c773e 100644
72050 --- a/include/linux/pm_domain.h
72051 +++ b/include/linux/pm_domain.h
72052 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
72053
72054 struct gpd_cpu_data {
72055 unsigned int saved_exit_latency;
72056 - struct cpuidle_state *idle_state;
72057 + cpuidle_state_no_const *idle_state;
72058 };
72059
72060 struct generic_pm_domain {
72061 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
72062 index 7d7e09e..8671ef8 100644
72063 --- a/include/linux/pm_runtime.h
72064 +++ b/include/linux/pm_runtime.h
72065 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
72066
72067 static inline void pm_runtime_mark_last_busy(struct device *dev)
72068 {
72069 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
72070 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
72071 }
72072
72073 #else /* !CONFIG_PM_RUNTIME */
72074 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
72075 index 195aafc..49a7bc2 100644
72076 --- a/include/linux/pnp.h
72077 +++ b/include/linux/pnp.h
72078 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
72079 struct pnp_fixup {
72080 char id[7];
72081 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
72082 -};
72083 +} __do_const;
72084
72085 /* config parameters */
72086 #define PNP_CONFIG_NORMAL 0x0001
72087 diff --git a/include/linux/poison.h b/include/linux/poison.h
72088 index 2110a81..13a11bb 100644
72089 --- a/include/linux/poison.h
72090 +++ b/include/linux/poison.h
72091 @@ -19,8 +19,8 @@
72092 * under normal circumstances, used to verify that nobody uses
72093 * non-initialized list entries.
72094 */
72095 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
72096 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
72097 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
72098 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
72099
72100 /********** include/linux/timer.h **********/
72101 /*
72102 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
72103 index c0f44c2..1572583 100644
72104 --- a/include/linux/power/smartreflex.h
72105 +++ b/include/linux/power/smartreflex.h
72106 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
72107 int (*notify)(struct omap_sr *sr, u32 status);
72108 u8 notify_flags;
72109 u8 class_type;
72110 -};
72111 +} __do_const;
72112
72113 /**
72114 * struct omap_sr_nvalue_table - Smartreflex n-target value info
72115 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
72116 index 4ea1d37..80f4b33 100644
72117 --- a/include/linux/ppp-comp.h
72118 +++ b/include/linux/ppp-comp.h
72119 @@ -84,7 +84,7 @@ struct compressor {
72120 struct module *owner;
72121 /* Extra skb space needed by the compressor algorithm */
72122 unsigned int comp_extra;
72123 -};
72124 +} __do_const;
72125
72126 /*
72127 * The return value from decompress routine is the length of the
72128 diff --git a/include/linux/printk.h b/include/linux/printk.h
72129 index 22c7052..ad3fa0a 100644
72130 --- a/include/linux/printk.h
72131 +++ b/include/linux/printk.h
72132 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
72133 void early_printk(const char *s, ...) { }
72134 #endif
72135
72136 +extern int kptr_restrict;
72137 +
72138 #ifdef CONFIG_PRINTK
72139 asmlinkage __printf(5, 0)
72140 int vprintk_emit(int facility, int level,
72141 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
72142
72143 extern int printk_delay_msec;
72144 extern int dmesg_restrict;
72145 -extern int kptr_restrict;
72146
72147 extern void wake_up_klogd(void);
72148
72149 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
72150 index 608e60a..c26f864 100644
72151 --- a/include/linux/proc_fs.h
72152 +++ b/include/linux/proc_fs.h
72153 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
72154 return proc_create_data(name, mode, parent, proc_fops, NULL);
72155 }
72156
72157 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
72158 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
72159 +{
72160 +#ifdef CONFIG_GRKERNSEC_PROC_USER
72161 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
72162 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
72163 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
72164 +#else
72165 + return proc_create_data(name, mode, parent, proc_fops, NULL);
72166 +#endif
72167 +}
72168 +
72169 +
72170 extern void proc_set_size(struct proc_dir_entry *, loff_t);
72171 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
72172 extern void *PDE_DATA(const struct inode *);
72173 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
72174 index 34a1e10..03a6d03 100644
72175 --- a/include/linux/proc_ns.h
72176 +++ b/include/linux/proc_ns.h
72177 @@ -14,7 +14,7 @@ struct proc_ns_operations {
72178 void (*put)(void *ns);
72179 int (*install)(struct nsproxy *nsproxy, void *ns);
72180 unsigned int (*inum)(void *ns);
72181 -};
72182 +} __do_const;
72183
72184 struct proc_ns {
72185 void *ns;
72186 diff --git a/include/linux/random.h b/include/linux/random.h
72187 index 3b9377d..61b506a 100644
72188 --- a/include/linux/random.h
72189 +++ b/include/linux/random.h
72190 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
72191 u32 prandom_u32_state(struct rnd_state *);
72192 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
72193
72194 +static inline unsigned long pax_get_random_long(void)
72195 +{
72196 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
72197 +}
72198 +
72199 /*
72200 * Handle minimum values for seeds
72201 */
72202 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
72203 index f4b1001..8ddb2b6 100644
72204 --- a/include/linux/rculist.h
72205 +++ b/include/linux/rculist.h
72206 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
72207 struct list_head *prev, struct list_head *next);
72208 #endif
72209
72210 +extern void __pax_list_add_rcu(struct list_head *new,
72211 + struct list_head *prev, struct list_head *next);
72212 +
72213 /**
72214 * list_add_rcu - add a new entry to rcu-protected list
72215 * @new: new entry to be added
72216 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
72217 __list_add_rcu(new, head, head->next);
72218 }
72219
72220 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
72221 +{
72222 + __pax_list_add_rcu(new, head, head->next);
72223 +}
72224 +
72225 /**
72226 * list_add_tail_rcu - add a new entry to rcu-protected list
72227 * @new: new entry to be added
72228 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
72229 __list_add_rcu(new, head->prev, head);
72230 }
72231
72232 +static inline void pax_list_add_tail_rcu(struct list_head *new,
72233 + struct list_head *head)
72234 +{
72235 + __pax_list_add_rcu(new, head->prev, head);
72236 +}
72237 +
72238 /**
72239 * list_del_rcu - deletes entry from list without re-initialization
72240 * @entry: the element to delete from the list.
72241 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
72242 entry->prev = LIST_POISON2;
72243 }
72244
72245 +extern void pax_list_del_rcu(struct list_head *entry);
72246 +
72247 /**
72248 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
72249 * @n: the element to delete from the hash list.
72250 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
72251 index 23b3630..e1bc12b 100644
72252 --- a/include/linux/reboot.h
72253 +++ b/include/linux/reboot.h
72254 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
72255 * Architecture-specific implementations of sys_reboot commands.
72256 */
72257
72258 -extern void machine_restart(char *cmd);
72259 -extern void machine_halt(void);
72260 -extern void machine_power_off(void);
72261 +extern void machine_restart(char *cmd) __noreturn;
72262 +extern void machine_halt(void) __noreturn;
72263 +extern void machine_power_off(void) __noreturn;
72264
72265 extern void machine_shutdown(void);
72266 struct pt_regs;
72267 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
72268 */
72269
72270 extern void kernel_restart_prepare(char *cmd);
72271 -extern void kernel_restart(char *cmd);
72272 -extern void kernel_halt(void);
72273 -extern void kernel_power_off(void);
72274 +extern void kernel_restart(char *cmd) __noreturn;
72275 +extern void kernel_halt(void) __noreturn;
72276 +extern void kernel_power_off(void) __noreturn;
72277
72278 extern int C_A_D; /* for sysctl */
72279 void ctrl_alt_del(void);
72280 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
72281 * Emergency restart, callable from an interrupt handler.
72282 */
72283
72284 -extern void emergency_restart(void);
72285 +extern void emergency_restart(void) __noreturn;
72286 #include <asm/emergency-restart.h>
72287
72288 #endif /* _LINUX_REBOOT_H */
72289 diff --git a/include/linux/regset.h b/include/linux/regset.h
72290 index 8e0c9fe..ac4d221 100644
72291 --- a/include/linux/regset.h
72292 +++ b/include/linux/regset.h
72293 @@ -161,7 +161,8 @@ struct user_regset {
72294 unsigned int align;
72295 unsigned int bias;
72296 unsigned int core_note_type;
72297 -};
72298 +} __do_const;
72299 +typedef struct user_regset __no_const user_regset_no_const;
72300
72301 /**
72302 * struct user_regset_view - available regsets
72303 diff --git a/include/linux/relay.h b/include/linux/relay.h
72304 index d7c8359..818daf5 100644
72305 --- a/include/linux/relay.h
72306 +++ b/include/linux/relay.h
72307 @@ -157,7 +157,7 @@ struct rchan_callbacks
72308 * The callback should return 0 if successful, negative if not.
72309 */
72310 int (*remove_buf_file)(struct dentry *dentry);
72311 -};
72312 +} __no_const;
72313
72314 /*
72315 * CONFIG_RELAY kernel API, kernel/relay.c
72316 diff --git a/include/linux/rio.h b/include/linux/rio.h
72317 index 18e0993..8ab5b21 100644
72318 --- a/include/linux/rio.h
72319 +++ b/include/linux/rio.h
72320 @@ -345,7 +345,7 @@ struct rio_ops {
72321 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
72322 u64 rstart, u32 size, u32 flags);
72323 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
72324 -};
72325 +} __no_const;
72326
72327 #define RIO_RESOURCE_MEM 0x00000100
72328 #define RIO_RESOURCE_DOORBELL 0x00000200
72329 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
72330 index 6dacb93..6174423 100644
72331 --- a/include/linux/rmap.h
72332 +++ b/include/linux/rmap.h
72333 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
72334 void anon_vma_init(void); /* create anon_vma_cachep */
72335 int anon_vma_prepare(struct vm_area_struct *);
72336 void unlink_anon_vmas(struct vm_area_struct *);
72337 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
72338 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
72339 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
72340 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
72341
72342 static inline void anon_vma_merge(struct vm_area_struct *vma,
72343 struct vm_area_struct *next)
72344 diff --git a/include/linux/sched.h b/include/linux/sched.h
72345 index 178a8d9..450bf11 100644
72346 --- a/include/linux/sched.h
72347 +++ b/include/linux/sched.h
72348 @@ -62,6 +62,7 @@ struct bio_list;
72349 struct fs_struct;
72350 struct perf_event_context;
72351 struct blk_plug;
72352 +struct linux_binprm;
72353
72354 /*
72355 * List of flags we want to share for kernel threads,
72356 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
72357 extern int in_sched_functions(unsigned long addr);
72358
72359 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
72360 -extern signed long schedule_timeout(signed long timeout);
72361 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
72362 extern signed long schedule_timeout_interruptible(signed long timeout);
72363 extern signed long schedule_timeout_killable(signed long timeout);
72364 extern signed long schedule_timeout_uninterruptible(signed long timeout);
72365 @@ -314,6 +315,19 @@ struct nsproxy;
72366 struct user_namespace;
72367
72368 #ifdef CONFIG_MMU
72369 +
72370 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
72371 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
72372 +#else
72373 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
72374 +{
72375 + return 0;
72376 +}
72377 +#endif
72378 +
72379 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
72380 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
72381 +
72382 extern void arch_pick_mmap_layout(struct mm_struct *mm);
72383 extern unsigned long
72384 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
72385 @@ -591,6 +605,17 @@ struct signal_struct {
72386 #ifdef CONFIG_TASKSTATS
72387 struct taskstats *stats;
72388 #endif
72389 +
72390 +#ifdef CONFIG_GRKERNSEC
72391 + u32 curr_ip;
72392 + u32 saved_ip;
72393 + u32 gr_saddr;
72394 + u32 gr_daddr;
72395 + u16 gr_sport;
72396 + u16 gr_dport;
72397 + u8 used_accept:1;
72398 +#endif
72399 +
72400 #ifdef CONFIG_AUDIT
72401 unsigned audit_tty;
72402 unsigned audit_tty_log_passwd;
72403 @@ -671,6 +696,14 @@ struct user_struct {
72404 struct key *session_keyring; /* UID's default session keyring */
72405 #endif
72406
72407 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72408 + unsigned char kernel_banned;
72409 +#endif
72410 +#ifdef CONFIG_GRKERNSEC_BRUTE
72411 + unsigned char suid_banned;
72412 + unsigned long suid_ban_expires;
72413 +#endif
72414 +
72415 /* Hash table maintenance information */
72416 struct hlist_node uidhash_node;
72417 kuid_t uid;
72418 @@ -1158,8 +1191,8 @@ struct task_struct {
72419 struct list_head thread_group;
72420
72421 struct completion *vfork_done; /* for vfork() */
72422 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
72423 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
72424 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
72425 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
72426
72427 cputime_t utime, stime, utimescaled, stimescaled;
72428 cputime_t gtime;
72429 @@ -1184,11 +1217,6 @@ struct task_struct {
72430 struct task_cputime cputime_expires;
72431 struct list_head cpu_timers[3];
72432
72433 -/* process credentials */
72434 - const struct cred __rcu *real_cred; /* objective and real subjective task
72435 - * credentials (COW) */
72436 - const struct cred __rcu *cred; /* effective (overridable) subjective task
72437 - * credentials (COW) */
72438 char comm[TASK_COMM_LEN]; /* executable name excluding path
72439 - access with [gs]et_task_comm (which lock
72440 it with task_lock())
72441 @@ -1205,6 +1233,10 @@ struct task_struct {
72442 #endif
72443 /* CPU-specific state of this task */
72444 struct thread_struct thread;
72445 +/* thread_info moved to task_struct */
72446 +#ifdef CONFIG_X86
72447 + struct thread_info tinfo;
72448 +#endif
72449 /* filesystem information */
72450 struct fs_struct *fs;
72451 /* open file information */
72452 @@ -1278,6 +1310,10 @@ struct task_struct {
72453 gfp_t lockdep_reclaim_gfp;
72454 #endif
72455
72456 +/* process credentials */
72457 + const struct cred __rcu *real_cred; /* objective and real subjective task
72458 + * credentials (COW) */
72459 +
72460 /* journalling filesystem info */
72461 void *journal_info;
72462
72463 @@ -1316,6 +1352,10 @@ struct task_struct {
72464 /* cg_list protected by css_set_lock and tsk->alloc_lock */
72465 struct list_head cg_list;
72466 #endif
72467 +
72468 + const struct cred __rcu *cred; /* effective (overridable) subjective task
72469 + * credentials (COW) */
72470 +
72471 #ifdef CONFIG_FUTEX
72472 struct robust_list_head __user *robust_list;
72473 #ifdef CONFIG_COMPAT
72474 @@ -1416,8 +1456,76 @@ struct task_struct {
72475 unsigned int sequential_io;
72476 unsigned int sequential_io_avg;
72477 #endif
72478 +
72479 +#ifdef CONFIG_GRKERNSEC
72480 + /* grsecurity */
72481 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
72482 + u64 exec_id;
72483 +#endif
72484 +#ifdef CONFIG_GRKERNSEC_SETXID
72485 + const struct cred *delayed_cred;
72486 +#endif
72487 + struct dentry *gr_chroot_dentry;
72488 + struct acl_subject_label *acl;
72489 + struct acl_role_label *role;
72490 + struct file *exec_file;
72491 + unsigned long brute_expires;
72492 + u16 acl_role_id;
72493 + /* is this the task that authenticated to the special role */
72494 + u8 acl_sp_role;
72495 + u8 is_writable;
72496 + u8 brute;
72497 + u8 gr_is_chrooted;
72498 +#endif
72499 +
72500 };
72501
72502 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
72503 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
72504 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
72505 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
72506 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
72507 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
72508 +
72509 +#ifdef CONFIG_PAX_SOFTMODE
72510 +extern int pax_softmode;
72511 +#endif
72512 +
72513 +extern int pax_check_flags(unsigned long *);
72514 +
72515 +/* if tsk != current then task_lock must be held on it */
72516 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
72517 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
72518 +{
72519 + if (likely(tsk->mm))
72520 + return tsk->mm->pax_flags;
72521 + else
72522 + return 0UL;
72523 +}
72524 +
72525 +/* if tsk != current then task_lock must be held on it */
72526 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
72527 +{
72528 + if (likely(tsk->mm)) {
72529 + tsk->mm->pax_flags = flags;
72530 + return 0;
72531 + }
72532 + return -EINVAL;
72533 +}
72534 +#endif
72535 +
72536 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
72537 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
72538 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
72539 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
72540 +#endif
72541 +
72542 +struct path;
72543 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
72544 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
72545 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
72546 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
72547 +
72548 /* Future-safe accessor for struct task_struct's cpus_allowed. */
72549 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
72550
72551 @@ -1476,7 +1584,7 @@ struct pid_namespace;
72552 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
72553 struct pid_namespace *ns);
72554
72555 -static inline pid_t task_pid_nr(struct task_struct *tsk)
72556 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
72557 {
72558 return tsk->pid;
72559 }
72560 @@ -1919,7 +2027,9 @@ void yield(void);
72561 extern struct exec_domain default_exec_domain;
72562
72563 union thread_union {
72564 +#ifndef CONFIG_X86
72565 struct thread_info thread_info;
72566 +#endif
72567 unsigned long stack[THREAD_SIZE/sizeof(long)];
72568 };
72569
72570 @@ -1952,6 +2062,7 @@ extern struct pid_namespace init_pid_ns;
72571 */
72572
72573 extern struct task_struct *find_task_by_vpid(pid_t nr);
72574 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
72575 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
72576 struct pid_namespace *ns);
72577
72578 @@ -2118,7 +2229,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
72579 extern void exit_itimers(struct signal_struct *);
72580 extern void flush_itimer_signals(void);
72581
72582 -extern void do_group_exit(int);
72583 +extern __noreturn void do_group_exit(int);
72584
72585 extern int allow_signal(int);
72586 extern int disallow_signal(int);
72587 @@ -2309,9 +2420,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
72588
72589 #endif
72590
72591 -static inline int object_is_on_stack(void *obj)
72592 +static inline int object_starts_on_stack(void *obj)
72593 {
72594 - void *stack = task_stack_page(current);
72595 + const void *stack = task_stack_page(current);
72596
72597 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
72598 }
72599 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
72600 index bf8086b..962b035 100644
72601 --- a/include/linux/sched/sysctl.h
72602 +++ b/include/linux/sched/sysctl.h
72603 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
72604 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
72605
72606 extern int sysctl_max_map_count;
72607 +extern unsigned long sysctl_heap_stack_gap;
72608
72609 extern unsigned int sysctl_sched_latency;
72610 extern unsigned int sysctl_sched_min_granularity;
72611 diff --git a/include/linux/security.h b/include/linux/security.h
72612 index 4686491..2bd210e 100644
72613 --- a/include/linux/security.h
72614 +++ b/include/linux/security.h
72615 @@ -26,6 +26,7 @@
72616 #include <linux/capability.h>
72617 #include <linux/slab.h>
72618 #include <linux/err.h>
72619 +#include <linux/grsecurity.h>
72620
72621 struct linux_binprm;
72622 struct cred;
72623 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
72624 index 2da29ac..aac448ec 100644
72625 --- a/include/linux/seq_file.h
72626 +++ b/include/linux/seq_file.h
72627 @@ -26,6 +26,9 @@ struct seq_file {
72628 struct mutex lock;
72629 const struct seq_operations *op;
72630 int poll_event;
72631 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
72632 + u64 exec_id;
72633 +#endif
72634 #ifdef CONFIG_USER_NS
72635 struct user_namespace *user_ns;
72636 #endif
72637 @@ -38,6 +41,7 @@ struct seq_operations {
72638 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
72639 int (*show) (struct seq_file *m, void *v);
72640 };
72641 +typedef struct seq_operations __no_const seq_operations_no_const;
72642
72643 #define SEQ_SKIP 1
72644
72645 diff --git a/include/linux/shm.h b/include/linux/shm.h
72646 index 429c199..4d42e38 100644
72647 --- a/include/linux/shm.h
72648 +++ b/include/linux/shm.h
72649 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
72650
72651 /* The task created the shm object. NULL if the task is dead. */
72652 struct task_struct *shm_creator;
72653 +#ifdef CONFIG_GRKERNSEC
72654 + time_t shm_createtime;
72655 + pid_t shm_lapid;
72656 +#endif
72657 };
72658
72659 /* shm_mode upper byte flags */
72660 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
72661 index dec1748..112c1f9 100644
72662 --- a/include/linux/skbuff.h
72663 +++ b/include/linux/skbuff.h
72664 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
72665 extern struct sk_buff *__alloc_skb(unsigned int size,
72666 gfp_t priority, int flags, int node);
72667 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
72668 -static inline struct sk_buff *alloc_skb(unsigned int size,
72669 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
72670 gfp_t priority)
72671 {
72672 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
72673 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
72674 */
72675 static inline int skb_queue_empty(const struct sk_buff_head *list)
72676 {
72677 - return list->next == (struct sk_buff *)list;
72678 + return list->next == (const struct sk_buff *)list;
72679 }
72680
72681 /**
72682 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
72683 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
72684 const struct sk_buff *skb)
72685 {
72686 - return skb->next == (struct sk_buff *)list;
72687 + return skb->next == (const struct sk_buff *)list;
72688 }
72689
72690 /**
72691 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
72692 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
72693 const struct sk_buff *skb)
72694 {
72695 - return skb->prev == (struct sk_buff *)list;
72696 + return skb->prev == (const struct sk_buff *)list;
72697 }
72698
72699 /**
72700 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
72701 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
72702 */
72703 #ifndef NET_SKB_PAD
72704 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
72705 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
72706 #endif
72707
72708 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
72709 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
72710 int noblock, int *err);
72711 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
72712 struct poll_table_struct *wait);
72713 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
72714 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
72715 int offset, struct iovec *to,
72716 int size);
72717 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
72718 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
72719 nf_bridge_put(skb->nf_bridge);
72720 skb->nf_bridge = NULL;
72721 #endif
72722 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
72723 + skb->nf_trace = 0;
72724 +#endif
72725 }
72726
72727 static inline void nf_reset_trace(struct sk_buff *skb)
72728 diff --git a/include/linux/slab.h b/include/linux/slab.h
72729 index 0c62175..f016ac1 100644
72730 --- a/include/linux/slab.h
72731 +++ b/include/linux/slab.h
72732 @@ -12,15 +12,29 @@
72733 #include <linux/gfp.h>
72734 #include <linux/types.h>
72735 #include <linux/workqueue.h>
72736 -
72737 +#include <linux/err.h>
72738
72739 /*
72740 * Flags to pass to kmem_cache_create().
72741 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
72742 */
72743 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
72744 +
72745 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72746 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
72747 +#else
72748 +#define SLAB_USERCOPY 0x00000000UL
72749 +#endif
72750 +
72751 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
72752 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
72753 +
72754 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
72755 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
72756 +#else
72757 +#define SLAB_NO_SANITIZE 0x00000000UL
72758 +#endif
72759 +
72760 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
72761 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
72762 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
72763 @@ -89,10 +103,13 @@
72764 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
72765 * Both make kfree a no-op.
72766 */
72767 -#define ZERO_SIZE_PTR ((void *)16)
72768 +#define ZERO_SIZE_PTR \
72769 +({ \
72770 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
72771 + (void *)(-MAX_ERRNO-1L); \
72772 +})
72773
72774 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
72775 - (unsigned long)ZERO_SIZE_PTR)
72776 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
72777
72778
72779 struct mem_cgroup;
72780 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
72781 void kfree(const void *);
72782 void kzfree(const void *);
72783 size_t ksize(const void *);
72784 +const char *check_heap_object(const void *ptr, unsigned long n);
72785 +bool is_usercopy_object(const void *ptr);
72786
72787 /*
72788 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
72789 @@ -164,7 +183,7 @@ struct kmem_cache {
72790 unsigned int align; /* Alignment as calculated */
72791 unsigned long flags; /* Active flags on the slab */
72792 const char *name; /* Slab name for sysfs */
72793 - int refcount; /* Use counter */
72794 + atomic_t refcount; /* Use counter */
72795 void (*ctor)(void *); /* Called on object slot creation */
72796 struct list_head list; /* List of all slab caches on the system */
72797 };
72798 @@ -226,6 +245,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
72799 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
72800 #endif
72801
72802 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72803 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
72804 +#endif
72805 +
72806 /*
72807 * Figure out which kmalloc slab an allocation of a certain size
72808 * belongs to.
72809 @@ -234,7 +257,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
72810 * 2 = 120 .. 192 bytes
72811 * n = 2^(n-1) .. 2^n -1
72812 */
72813 -static __always_inline int kmalloc_index(size_t size)
72814 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
72815 {
72816 if (!size)
72817 return 0;
72818 @@ -406,6 +429,7 @@ void print_slabinfo_header(struct seq_file *m);
72819 * for general use, and so are not documented here. For a full list of
72820 * potential flags, always refer to linux/gfp.h.
72821 */
72822 +
72823 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
72824 {
72825 if (size != 0 && n > SIZE_MAX / size)
72826 @@ -465,7 +489,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
72827 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72828 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72829 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72830 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72831 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
72832 #define kmalloc_track_caller(size, flags) \
72833 __kmalloc_track_caller(size, flags, _RET_IP_)
72834 #else
72835 @@ -485,7 +509,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72836 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72837 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72838 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72839 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
72840 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
72841 #define kmalloc_node_track_caller(size, flags, node) \
72842 __kmalloc_node_track_caller(size, flags, node, \
72843 _RET_IP_)
72844 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
72845 index cd40158..4e2f7af 100644
72846 --- a/include/linux/slab_def.h
72847 +++ b/include/linux/slab_def.h
72848 @@ -50,7 +50,7 @@ struct kmem_cache {
72849 /* 4) cache creation/removal */
72850 const char *name;
72851 struct list_head list;
72852 - int refcount;
72853 + atomic_t refcount;
72854 int object_size;
72855 int align;
72856
72857 @@ -66,10 +66,14 @@ struct kmem_cache {
72858 unsigned long node_allocs;
72859 unsigned long node_frees;
72860 unsigned long node_overflow;
72861 - atomic_t allochit;
72862 - atomic_t allocmiss;
72863 - atomic_t freehit;
72864 - atomic_t freemiss;
72865 + atomic_unchecked_t allochit;
72866 + atomic_unchecked_t allocmiss;
72867 + atomic_unchecked_t freehit;
72868 + atomic_unchecked_t freemiss;
72869 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
72870 + atomic_unchecked_t sanitized;
72871 + atomic_unchecked_t not_sanitized;
72872 +#endif
72873
72874 /*
72875 * If debugging is enabled, then the allocator can add additional
72876 @@ -103,7 +107,7 @@ struct kmem_cache {
72877 };
72878
72879 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72880 -void *__kmalloc(size_t size, gfp_t flags);
72881 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
72882
72883 #ifdef CONFIG_TRACING
72884 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
72885 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72886 cachep = kmalloc_dma_caches[i];
72887 else
72888 #endif
72889 +
72890 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72891 + if (flags & GFP_USERCOPY)
72892 + cachep = kmalloc_usercopy_caches[i];
72893 + else
72894 +#endif
72895 +
72896 cachep = kmalloc_caches[i];
72897
72898 ret = kmem_cache_alloc_trace(cachep, flags, size);
72899 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72900 }
72901
72902 #ifdef CONFIG_NUMA
72903 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
72904 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72905 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72906
72907 #ifdef CONFIG_TRACING
72908 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72909 cachep = kmalloc_dma_caches[i];
72910 else
72911 #endif
72912 +
72913 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72914 + if (flags & GFP_USERCOPY)
72915 + cachep = kmalloc_usercopy_caches[i];
72916 + else
72917 +#endif
72918 +
72919 cachep = kmalloc_caches[i];
72920
72921 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
72922 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
72923 index f28e14a..7831211 100644
72924 --- a/include/linux/slob_def.h
72925 +++ b/include/linux/slob_def.h
72926 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
72927 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
72928 }
72929
72930 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72931 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72932
72933 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72934 {
72935 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72936 return __kmalloc_node(size, flags, NUMA_NO_NODE);
72937 }
72938
72939 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
72940 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
72941 {
72942 return kmalloc(size, flags);
72943 }
72944 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
72945 index 027276f..092bfe8 100644
72946 --- a/include/linux/slub_def.h
72947 +++ b/include/linux/slub_def.h
72948 @@ -80,7 +80,7 @@ struct kmem_cache {
72949 struct kmem_cache_order_objects max;
72950 struct kmem_cache_order_objects min;
72951 gfp_t allocflags; /* gfp flags to use on each alloc */
72952 - int refcount; /* Refcount for slab cache destroy */
72953 + atomic_t refcount; /* Refcount for slab cache destroy */
72954 void (*ctor)(void *);
72955 int inuse; /* Offset to metadata */
72956 int align; /* Alignment */
72957 @@ -105,7 +105,7 @@ struct kmem_cache {
72958 };
72959
72960 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72961 -void *__kmalloc(size_t size, gfp_t flags);
72962 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
72963
72964 static __always_inline void *
72965 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
72966 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
72967 }
72968 #endif
72969
72970 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
72971 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
72972 {
72973 unsigned int order = get_order(size);
72974 return kmalloc_order_trace(size, flags, order);
72975 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72976 }
72977
72978 #ifdef CONFIG_NUMA
72979 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72980 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72981 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72982
72983 #ifdef CONFIG_TRACING
72984 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
72985 index 54f91d3..be2c379 100644
72986 --- a/include/linux/sock_diag.h
72987 +++ b/include/linux/sock_diag.h
72988 @@ -11,7 +11,7 @@ struct sock;
72989 struct sock_diag_handler {
72990 __u8 family;
72991 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
72992 -};
72993 +} __do_const;
72994
72995 int sock_diag_register(const struct sock_diag_handler *h);
72996 void sock_diag_unregister(const struct sock_diag_handler *h);
72997 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
72998 index 680f9a3..f13aeb0 100644
72999 --- a/include/linux/sonet.h
73000 +++ b/include/linux/sonet.h
73001 @@ -7,7 +7,7 @@
73002 #include <uapi/linux/sonet.h>
73003
73004 struct k_sonet_stats {
73005 -#define __HANDLE_ITEM(i) atomic_t i
73006 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73007 __SONET_ITEMS
73008 #undef __HANDLE_ITEM
73009 };
73010 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
73011 index 07d8e53..dc934c9 100644
73012 --- a/include/linux/sunrpc/addr.h
73013 +++ b/include/linux/sunrpc/addr.h
73014 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
73015 {
73016 switch (sap->sa_family) {
73017 case AF_INET:
73018 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
73019 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
73020 case AF_INET6:
73021 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
73022 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
73023 }
73024 return 0;
73025 }
73026 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
73027 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
73028 const struct sockaddr *src)
73029 {
73030 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
73031 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
73032 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
73033
73034 dsin->sin_family = ssin->sin_family;
73035 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
73036 if (sa->sa_family != AF_INET6)
73037 return 0;
73038
73039 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
73040 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
73041 }
73042
73043 #endif /* _LINUX_SUNRPC_ADDR_H */
73044 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
73045 index bfe11be..12bc8c4 100644
73046 --- a/include/linux/sunrpc/clnt.h
73047 +++ b/include/linux/sunrpc/clnt.h
73048 @@ -96,7 +96,7 @@ struct rpc_procinfo {
73049 unsigned int p_timer; /* Which RTT timer to use */
73050 u32 p_statidx; /* Which procedure to account */
73051 const char * p_name; /* name of procedure */
73052 -};
73053 +} __do_const;
73054
73055 #ifdef __KERNEL__
73056
73057 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
73058 index 1f0216b..6a4fa50 100644
73059 --- a/include/linux/sunrpc/svc.h
73060 +++ b/include/linux/sunrpc/svc.h
73061 @@ -411,7 +411,7 @@ struct svc_procedure {
73062 unsigned int pc_count; /* call count */
73063 unsigned int pc_cachetype; /* cache info (NFS) */
73064 unsigned int pc_xdrressize; /* maximum size of XDR reply */
73065 -};
73066 +} __do_const;
73067
73068 /*
73069 * Function prototypes.
73070 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
73071 index 0b8e3e6..33e0a01 100644
73072 --- a/include/linux/sunrpc/svc_rdma.h
73073 +++ b/include/linux/sunrpc/svc_rdma.h
73074 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
73075 extern unsigned int svcrdma_max_requests;
73076 extern unsigned int svcrdma_max_req_size;
73077
73078 -extern atomic_t rdma_stat_recv;
73079 -extern atomic_t rdma_stat_read;
73080 -extern atomic_t rdma_stat_write;
73081 -extern atomic_t rdma_stat_sq_starve;
73082 -extern atomic_t rdma_stat_rq_starve;
73083 -extern atomic_t rdma_stat_rq_poll;
73084 -extern atomic_t rdma_stat_rq_prod;
73085 -extern atomic_t rdma_stat_sq_poll;
73086 -extern atomic_t rdma_stat_sq_prod;
73087 +extern atomic_unchecked_t rdma_stat_recv;
73088 +extern atomic_unchecked_t rdma_stat_read;
73089 +extern atomic_unchecked_t rdma_stat_write;
73090 +extern atomic_unchecked_t rdma_stat_sq_starve;
73091 +extern atomic_unchecked_t rdma_stat_rq_starve;
73092 +extern atomic_unchecked_t rdma_stat_rq_poll;
73093 +extern atomic_unchecked_t rdma_stat_rq_prod;
73094 +extern atomic_unchecked_t rdma_stat_sq_poll;
73095 +extern atomic_unchecked_t rdma_stat_sq_prod;
73096
73097 #define RPCRDMA_VERSION 1
73098
73099 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
73100 index ff374ab..7fd2ecb 100644
73101 --- a/include/linux/sunrpc/svcauth.h
73102 +++ b/include/linux/sunrpc/svcauth.h
73103 @@ -109,7 +109,7 @@ struct auth_ops {
73104 int (*release)(struct svc_rqst *rq);
73105 void (*domain_release)(struct auth_domain *);
73106 int (*set_client)(struct svc_rqst *rq);
73107 -};
73108 +} __do_const;
73109
73110 #define SVC_GARBAGE 1
73111 #define SVC_SYSERR 2
73112 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
73113 index a5ffd32..0935dea 100644
73114 --- a/include/linux/swiotlb.h
73115 +++ b/include/linux/swiotlb.h
73116 @@ -60,7 +60,8 @@ extern void
73117
73118 extern void
73119 swiotlb_free_coherent(struct device *hwdev, size_t size,
73120 - void *vaddr, dma_addr_t dma_handle);
73121 + void *vaddr, dma_addr_t dma_handle,
73122 + struct dma_attrs *attrs);
73123
73124 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
73125 unsigned long offset, size_t size,
73126 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
73127 index 4147d70..d356a10 100644
73128 --- a/include/linux/syscalls.h
73129 +++ b/include/linux/syscalls.h
73130 @@ -97,8 +97,12 @@ struct sigaltstack;
73131 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
73132
73133 #define __SC_DECL(t, a) t a
73134 -#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
73135 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
73136 +#define __TYPE_IS_SL(t) (__same_type((t)0, 0L))
73137 +#define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
73138 +#define __TYPE_IS_SLL(t) (__same_type((t)0, 0LL))
73139 +#define __TYPE_IS_ULL(t) (__same_type((t)0, 0ULL))
73140 +#define __TYPE_IS_LL(t) (__TYPE_IS_SLL(t) || __TYPE_IS_ULL(t))
73141 +#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), __builtin_choose_expr(__TYPE_IS_ULL(t), 0ULL, 0LL), __builtin_choose_expr(__TYPE_IS_UL(t), 0UL, 0L))) a
73142 #define __SC_CAST(t, a) (t) a
73143 #define __SC_ARGS(t, a) a
73144 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
73145 @@ -362,11 +366,11 @@ asmlinkage long sys_sync(void);
73146 asmlinkage long sys_fsync(unsigned int fd);
73147 asmlinkage long sys_fdatasync(unsigned int fd);
73148 asmlinkage long sys_bdflush(int func, long data);
73149 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
73150 - char __user *type, unsigned long flags,
73151 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
73152 + const char __user *type, unsigned long flags,
73153 void __user *data);
73154 -asmlinkage long sys_umount(char __user *name, int flags);
73155 -asmlinkage long sys_oldumount(char __user *name);
73156 +asmlinkage long sys_umount(const char __user *name, int flags);
73157 +asmlinkage long sys_oldumount(const char __user *name);
73158 asmlinkage long sys_truncate(const char __user *path, long length);
73159 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
73160 asmlinkage long sys_stat(const char __user *filename,
73161 @@ -578,7 +582,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
73162 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
73163 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
73164 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
73165 - struct sockaddr __user *, int);
73166 + struct sockaddr __user *, int) __intentional_overflow(0);
73167 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
73168 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
73169 unsigned int vlen, unsigned flags);
73170 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
73171 index 27b3b0b..e093dd9 100644
73172 --- a/include/linux/syscore_ops.h
73173 +++ b/include/linux/syscore_ops.h
73174 @@ -16,7 +16,7 @@ struct syscore_ops {
73175 int (*suspend)(void);
73176 void (*resume)(void);
73177 void (*shutdown)(void);
73178 -};
73179 +} __do_const;
73180
73181 extern void register_syscore_ops(struct syscore_ops *ops);
73182 extern void unregister_syscore_ops(struct syscore_ops *ops);
73183 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
73184 index 14a8ff2..af52bad 100644
73185 --- a/include/linux/sysctl.h
73186 +++ b/include/linux/sysctl.h
73187 @@ -34,13 +34,13 @@ struct ctl_table_root;
73188 struct ctl_table_header;
73189 struct ctl_dir;
73190
73191 -typedef struct ctl_table ctl_table;
73192 -
73193 typedef int proc_handler (struct ctl_table *ctl, int write,
73194 void __user *buffer, size_t *lenp, loff_t *ppos);
73195
73196 extern int proc_dostring(struct ctl_table *, int,
73197 void __user *, size_t *, loff_t *);
73198 +extern int proc_dostring_modpriv(struct ctl_table *, int,
73199 + void __user *, size_t *, loff_t *);
73200 extern int proc_dointvec(struct ctl_table *, int,
73201 void __user *, size_t *, loff_t *);
73202 extern int proc_dointvec_minmax(struct ctl_table *, int,
73203 @@ -115,7 +115,9 @@ struct ctl_table
73204 struct ctl_table_poll *poll;
73205 void *extra1;
73206 void *extra2;
73207 -};
73208 +} __do_const;
73209 +typedef struct ctl_table __no_const ctl_table_no_const;
73210 +typedef struct ctl_table ctl_table;
73211
73212 struct ctl_node {
73213 struct rb_node node;
73214 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
73215 index e2cee22..3ddb921 100644
73216 --- a/include/linux/sysfs.h
73217 +++ b/include/linux/sysfs.h
73218 @@ -31,7 +31,8 @@ struct attribute {
73219 struct lock_class_key *key;
73220 struct lock_class_key skey;
73221 #endif
73222 -};
73223 +} __do_const;
73224 +typedef struct attribute __no_const attribute_no_const;
73225
73226 /**
73227 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
73228 @@ -59,8 +60,8 @@ struct attribute_group {
73229 umode_t (*is_visible)(struct kobject *,
73230 struct attribute *, int);
73231 struct attribute **attrs;
73232 -};
73233 -
73234 +} __do_const;
73235 +typedef struct attribute_group __no_const attribute_group_no_const;
73236
73237
73238 /**
73239 @@ -107,7 +108,8 @@ struct bin_attribute {
73240 char *, loff_t, size_t);
73241 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
73242 struct vm_area_struct *vma);
73243 -};
73244 +} __do_const;
73245 +typedef struct bin_attribute __no_const bin_attribute_no_const;
73246
73247 /**
73248 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
73249 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
73250 index 7faf933..9b85a0c 100644
73251 --- a/include/linux/sysrq.h
73252 +++ b/include/linux/sysrq.h
73253 @@ -16,6 +16,7 @@
73254
73255 #include <linux/errno.h>
73256 #include <linux/types.h>
73257 +#include <linux/compiler.h>
73258
73259 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
73260 #define SYSRQ_DEFAULT_ENABLE 1
73261 @@ -36,7 +37,7 @@ struct sysrq_key_op {
73262 char *help_msg;
73263 char *action_msg;
73264 int enable_mask;
73265 -};
73266 +} __do_const;
73267
73268 #ifdef CONFIG_MAGIC_SYSRQ
73269
73270 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
73271 index e7e0473..7989295 100644
73272 --- a/include/linux/thread_info.h
73273 +++ b/include/linux/thread_info.h
73274 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
73275 #error "no set_restore_sigmask() provided and default one won't work"
73276 #endif
73277
73278 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
73279 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
73280 +{
73281 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
73282 + if (!__builtin_constant_p(n))
73283 +#endif
73284 + __check_object_size(ptr, n, to_user);
73285 +}
73286 +
73287 #endif /* __KERNEL__ */
73288
73289 #endif /* _LINUX_THREAD_INFO_H */
73290 diff --git a/include/linux/tty.h b/include/linux/tty.h
73291 index 8780bd2..d1ae08b 100644
73292 --- a/include/linux/tty.h
73293 +++ b/include/linux/tty.h
73294 @@ -194,7 +194,7 @@ struct tty_port {
73295 const struct tty_port_operations *ops; /* Port operations */
73296 spinlock_t lock; /* Lock protecting tty field */
73297 int blocked_open; /* Waiting to open */
73298 - int count; /* Usage count */
73299 + atomic_t count; /* Usage count */
73300 wait_queue_head_t open_wait; /* Open waiters */
73301 wait_queue_head_t close_wait; /* Close waiters */
73302 wait_queue_head_t delta_msr_wait; /* Modem status change */
73303 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
73304 struct tty_struct *tty, struct file *filp);
73305 static inline int tty_port_users(struct tty_port *port)
73306 {
73307 - return port->count + port->blocked_open;
73308 + return atomic_read(&port->count) + port->blocked_open;
73309 }
73310
73311 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
73312 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
73313 index 756a609..b302dd6 100644
73314 --- a/include/linux/tty_driver.h
73315 +++ b/include/linux/tty_driver.h
73316 @@ -285,7 +285,7 @@ struct tty_operations {
73317 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
73318 #endif
73319 const struct file_operations *proc_fops;
73320 -};
73321 +} __do_const;
73322
73323 struct tty_driver {
73324 int magic; /* magic number for this structure */
73325 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
73326 index 58390c7..95e214c 100644
73327 --- a/include/linux/tty_ldisc.h
73328 +++ b/include/linux/tty_ldisc.h
73329 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
73330
73331 struct module *owner;
73332
73333 - int refcount;
73334 + atomic_t refcount;
73335 };
73336
73337 struct tty_ldisc {
73338 diff --git a/include/linux/types.h b/include/linux/types.h
73339 index 4d118ba..c3ee9bf 100644
73340 --- a/include/linux/types.h
73341 +++ b/include/linux/types.h
73342 @@ -176,10 +176,26 @@ typedef struct {
73343 int counter;
73344 } atomic_t;
73345
73346 +#ifdef CONFIG_PAX_REFCOUNT
73347 +typedef struct {
73348 + int counter;
73349 +} atomic_unchecked_t;
73350 +#else
73351 +typedef atomic_t atomic_unchecked_t;
73352 +#endif
73353 +
73354 #ifdef CONFIG_64BIT
73355 typedef struct {
73356 long counter;
73357 } atomic64_t;
73358 +
73359 +#ifdef CONFIG_PAX_REFCOUNT
73360 +typedef struct {
73361 + long counter;
73362 +} atomic64_unchecked_t;
73363 +#else
73364 +typedef atomic64_t atomic64_unchecked_t;
73365 +#endif
73366 #endif
73367
73368 struct list_head {
73369 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
73370 index 5ca0951..ab496a5 100644
73371 --- a/include/linux/uaccess.h
73372 +++ b/include/linux/uaccess.h
73373 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
73374 long ret; \
73375 mm_segment_t old_fs = get_fs(); \
73376 \
73377 - set_fs(KERNEL_DS); \
73378 pagefault_disable(); \
73379 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
73380 - pagefault_enable(); \
73381 + set_fs(KERNEL_DS); \
73382 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
73383 set_fs(old_fs); \
73384 + pagefault_enable(); \
73385 ret; \
73386 })
73387
73388 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
73389 index 8e522cbc..aa8572d 100644
73390 --- a/include/linux/uidgid.h
73391 +++ b/include/linux/uidgid.h
73392 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
73393
73394 #endif /* CONFIG_USER_NS */
73395
73396 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
73397 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
73398 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
73399 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
73400 +
73401 #endif /* _LINUX_UIDGID_H */
73402 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
73403 index 99c1b4d..562e6f3 100644
73404 --- a/include/linux/unaligned/access_ok.h
73405 +++ b/include/linux/unaligned/access_ok.h
73406 @@ -4,34 +4,34 @@
73407 #include <linux/kernel.h>
73408 #include <asm/byteorder.h>
73409
73410 -static inline u16 get_unaligned_le16(const void *p)
73411 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
73412 {
73413 - return le16_to_cpup((__le16 *)p);
73414 + return le16_to_cpup((const __le16 *)p);
73415 }
73416
73417 -static inline u32 get_unaligned_le32(const void *p)
73418 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
73419 {
73420 - return le32_to_cpup((__le32 *)p);
73421 + return le32_to_cpup((const __le32 *)p);
73422 }
73423
73424 -static inline u64 get_unaligned_le64(const void *p)
73425 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
73426 {
73427 - return le64_to_cpup((__le64 *)p);
73428 + return le64_to_cpup((const __le64 *)p);
73429 }
73430
73431 -static inline u16 get_unaligned_be16(const void *p)
73432 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
73433 {
73434 - return be16_to_cpup((__be16 *)p);
73435 + return be16_to_cpup((const __be16 *)p);
73436 }
73437
73438 -static inline u32 get_unaligned_be32(const void *p)
73439 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
73440 {
73441 - return be32_to_cpup((__be32 *)p);
73442 + return be32_to_cpup((const __be32 *)p);
73443 }
73444
73445 -static inline u64 get_unaligned_be64(const void *p)
73446 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
73447 {
73448 - return be64_to_cpup((__be64 *)p);
73449 + return be64_to_cpup((const __be64 *)p);
73450 }
73451
73452 static inline void put_unaligned_le16(u16 val, void *p)
73453 diff --git a/include/linux/usb.h b/include/linux/usb.h
73454 index a0bee5a..5533a52 100644
73455 --- a/include/linux/usb.h
73456 +++ b/include/linux/usb.h
73457 @@ -552,7 +552,7 @@ struct usb_device {
73458 int maxchild;
73459
73460 u32 quirks;
73461 - atomic_t urbnum;
73462 + atomic_unchecked_t urbnum;
73463
73464 unsigned long active_duration;
73465
73466 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
73467
73468 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
73469 __u8 request, __u8 requesttype, __u16 value, __u16 index,
73470 - void *data, __u16 size, int timeout);
73471 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
73472 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
73473 void *data, int len, int *actual_length, int timeout);
73474 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
73475 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
73476 index e452ba6..78f8e80 100644
73477 --- a/include/linux/usb/renesas_usbhs.h
73478 +++ b/include/linux/usb/renesas_usbhs.h
73479 @@ -39,7 +39,7 @@ enum {
73480 */
73481 struct renesas_usbhs_driver_callback {
73482 int (*notify_hotplug)(struct platform_device *pdev);
73483 -};
73484 +} __no_const;
73485
73486 /*
73487 * callback functions for platform
73488 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
73489 index 6f8fbcf..8259001 100644
73490 --- a/include/linux/vermagic.h
73491 +++ b/include/linux/vermagic.h
73492 @@ -25,9 +25,35 @@
73493 #define MODULE_ARCH_VERMAGIC ""
73494 #endif
73495
73496 +#ifdef CONFIG_PAX_REFCOUNT
73497 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
73498 +#else
73499 +#define MODULE_PAX_REFCOUNT ""
73500 +#endif
73501 +
73502 +#ifdef CONSTIFY_PLUGIN
73503 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
73504 +#else
73505 +#define MODULE_CONSTIFY_PLUGIN ""
73506 +#endif
73507 +
73508 +#ifdef STACKLEAK_PLUGIN
73509 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
73510 +#else
73511 +#define MODULE_STACKLEAK_PLUGIN ""
73512 +#endif
73513 +
73514 +#ifdef CONFIG_GRKERNSEC
73515 +#define MODULE_GRSEC "GRSEC "
73516 +#else
73517 +#define MODULE_GRSEC ""
73518 +#endif
73519 +
73520 #define VERMAGIC_STRING \
73521 UTS_RELEASE " " \
73522 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
73523 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
73524 - MODULE_ARCH_VERMAGIC
73525 + MODULE_ARCH_VERMAGIC \
73526 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
73527 + MODULE_GRSEC
73528
73529 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
73530 index 7d5773a..541c01c 100644
73531 --- a/include/linux/vmalloc.h
73532 +++ b/include/linux/vmalloc.h
73533 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
73534 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
73535 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
73536 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
73537 +
73538 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
73539 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
73540 +#endif
73541 +
73542 /* bits [20..32] reserved for arch specific ioremap internals */
73543
73544 /*
73545 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
73546 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
73547 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
73548 unsigned long start, unsigned long end, gfp_t gfp_mask,
73549 - pgprot_t prot, int node, const void *caller);
73550 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
73551 extern void vfree(const void *addr);
73552
73553 extern void *vmap(struct page **pages, unsigned int count,
73554 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
73555 extern void free_vm_area(struct vm_struct *area);
73556
73557 /* for /dev/kmem */
73558 -extern long vread(char *buf, char *addr, unsigned long count);
73559 -extern long vwrite(char *buf, char *addr, unsigned long count);
73560 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
73561 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
73562
73563 /*
73564 * Internals. Dont't use..
73565 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
73566 index c586679..f06b389 100644
73567 --- a/include/linux/vmstat.h
73568 +++ b/include/linux/vmstat.h
73569 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
73570 /*
73571 * Zone based page accounting with per cpu differentials.
73572 */
73573 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73574 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73575
73576 static inline void zone_page_state_add(long x, struct zone *zone,
73577 enum zone_stat_item item)
73578 {
73579 - atomic_long_add(x, &zone->vm_stat[item]);
73580 - atomic_long_add(x, &vm_stat[item]);
73581 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
73582 + atomic_long_add_unchecked(x, &vm_stat[item]);
73583 }
73584
73585 static inline unsigned long global_page_state(enum zone_stat_item item)
73586 {
73587 - long x = atomic_long_read(&vm_stat[item]);
73588 + long x = atomic_long_read_unchecked(&vm_stat[item]);
73589 #ifdef CONFIG_SMP
73590 if (x < 0)
73591 x = 0;
73592 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
73593 static inline unsigned long zone_page_state(struct zone *zone,
73594 enum zone_stat_item item)
73595 {
73596 - long x = atomic_long_read(&zone->vm_stat[item]);
73597 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
73598 #ifdef CONFIG_SMP
73599 if (x < 0)
73600 x = 0;
73601 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
73602 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
73603 enum zone_stat_item item)
73604 {
73605 - long x = atomic_long_read(&zone->vm_stat[item]);
73606 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
73607
73608 #ifdef CONFIG_SMP
73609 int cpu;
73610 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
73611
73612 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
73613 {
73614 - atomic_long_inc(&zone->vm_stat[item]);
73615 - atomic_long_inc(&vm_stat[item]);
73616 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
73617 + atomic_long_inc_unchecked(&vm_stat[item]);
73618 }
73619
73620 static inline void __inc_zone_page_state(struct page *page,
73621 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
73622
73623 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
73624 {
73625 - atomic_long_dec(&zone->vm_stat[item]);
73626 - atomic_long_dec(&vm_stat[item]);
73627 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
73628 + atomic_long_dec_unchecked(&vm_stat[item]);
73629 }
73630
73631 static inline void __dec_zone_page_state(struct page *page,
73632 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
73633 index fdbafc6..49dfe4f 100644
73634 --- a/include/linux/xattr.h
73635 +++ b/include/linux/xattr.h
73636 @@ -28,7 +28,7 @@ struct xattr_handler {
73637 size_t size, int handler_flags);
73638 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
73639 size_t size, int flags, int handler_flags);
73640 -};
73641 +} __do_const;
73642
73643 struct xattr {
73644 char *name;
73645 @@ -37,6 +37,9 @@ struct xattr {
73646 };
73647
73648 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
73649 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
73650 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
73651 +#endif
73652 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
73653 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
73654 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
73655 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
73656 index 9c5a6b4..09c9438 100644
73657 --- a/include/linux/zlib.h
73658 +++ b/include/linux/zlib.h
73659 @@ -31,6 +31,7 @@
73660 #define _ZLIB_H
73661
73662 #include <linux/zconf.h>
73663 +#include <linux/compiler.h>
73664
73665 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
73666 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
73667 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
73668
73669 /* basic functions */
73670
73671 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
73672 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
73673 /*
73674 Returns the number of bytes that needs to be allocated for a per-
73675 stream workspace with the specified parameters. A pointer to this
73676 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
73677 index 95d1c91..6798cca 100644
73678 --- a/include/media/v4l2-dev.h
73679 +++ b/include/media/v4l2-dev.h
73680 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
73681 int (*mmap) (struct file *, struct vm_area_struct *);
73682 int (*open) (struct file *);
73683 int (*release) (struct file *);
73684 -};
73685 +} __do_const;
73686
73687 /*
73688 * Newer version of video_device, handled by videodev2.c
73689 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
73690 index adcbb20..62c2559 100644
73691 --- a/include/net/9p/transport.h
73692 +++ b/include/net/9p/transport.h
73693 @@ -57,7 +57,7 @@ struct p9_trans_module {
73694 int (*cancel) (struct p9_client *, struct p9_req_t *req);
73695 int (*zc_request)(struct p9_client *, struct p9_req_t *,
73696 char *, char *, int , int, int, int);
73697 -};
73698 +} __do_const;
73699
73700 void v9fs_register_trans(struct p9_trans_module *m);
73701 void v9fs_unregister_trans(struct p9_trans_module *m);
73702 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
73703 index fb94cf1..7c0c987 100644
73704 --- a/include/net/bluetooth/l2cap.h
73705 +++ b/include/net/bluetooth/l2cap.h
73706 @@ -551,7 +551,7 @@ struct l2cap_ops {
73707 void (*defer) (struct l2cap_chan *chan);
73708 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
73709 unsigned long len, int nb);
73710 -};
73711 +} __do_const;
73712
73713 struct l2cap_conn {
73714 struct hci_conn *hcon;
73715 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
73716 index f2ae33d..c457cf0 100644
73717 --- a/include/net/caif/cfctrl.h
73718 +++ b/include/net/caif/cfctrl.h
73719 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
73720 void (*radioset_rsp)(void);
73721 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
73722 struct cflayer *client_layer);
73723 -};
73724 +} __no_const;
73725
73726 /* Link Setup Parameters for CAIF-Links. */
73727 struct cfctrl_link_param {
73728 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
73729 struct cfctrl {
73730 struct cfsrvl serv;
73731 struct cfctrl_rsp res;
73732 - atomic_t req_seq_no;
73733 - atomic_t rsp_seq_no;
73734 + atomic_unchecked_t req_seq_no;
73735 + atomic_unchecked_t rsp_seq_no;
73736 struct list_head list;
73737 /* Protects from simultaneous access to first_req list */
73738 spinlock_t info_list_lock;
73739 diff --git a/include/net/flow.h b/include/net/flow.h
73740 index 628e11b..4c475df 100644
73741 --- a/include/net/flow.h
73742 +++ b/include/net/flow.h
73743 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
73744
73745 extern void flow_cache_flush(void);
73746 extern void flow_cache_flush_deferred(void);
73747 -extern atomic_t flow_cache_genid;
73748 +extern atomic_unchecked_t flow_cache_genid;
73749
73750 #endif
73751 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
73752 index 93024a4..eeb6b6e 100644
73753 --- a/include/net/genetlink.h
73754 +++ b/include/net/genetlink.h
73755 @@ -119,7 +119,7 @@ struct genl_ops {
73756 struct netlink_callback *cb);
73757 int (*done)(struct netlink_callback *cb);
73758 struct list_head ops_list;
73759 -};
73760 +} __do_const;
73761
73762 extern int genl_register_family(struct genl_family *family);
73763 extern int genl_register_family_with_ops(struct genl_family *family,
73764 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
73765 index 734d9b5..48a9a4b 100644
73766 --- a/include/net/gro_cells.h
73767 +++ b/include/net/gro_cells.h
73768 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
73769 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
73770
73771 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
73772 - atomic_long_inc(&dev->rx_dropped);
73773 + atomic_long_inc_unchecked(&dev->rx_dropped);
73774 kfree_skb(skb);
73775 return;
73776 }
73777 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
73778 index de2c785..0588a6b 100644
73779 --- a/include/net/inet_connection_sock.h
73780 +++ b/include/net/inet_connection_sock.h
73781 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
73782 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
73783 int (*bind_conflict)(const struct sock *sk,
73784 const struct inet_bind_bucket *tb, bool relax);
73785 -};
73786 +} __do_const;
73787
73788 /** inet_connection_sock - INET connection oriented sock
73789 *
73790 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
73791 index 53f464d..ba76aaa 100644
73792 --- a/include/net/inetpeer.h
73793 +++ b/include/net/inetpeer.h
73794 @@ -47,8 +47,8 @@ struct inet_peer {
73795 */
73796 union {
73797 struct {
73798 - atomic_t rid; /* Frag reception counter */
73799 - atomic_t ip_id_count; /* IP ID for the next packet */
73800 + atomic_unchecked_t rid; /* Frag reception counter */
73801 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
73802 };
73803 struct rcu_head rcu;
73804 struct inet_peer *gc_next;
73805 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
73806 more++;
73807 inet_peer_refcheck(p);
73808 do {
73809 - old = atomic_read(&p->ip_id_count);
73810 + old = atomic_read_unchecked(&p->ip_id_count);
73811 new = old + more;
73812 if (!new)
73813 new = 1;
73814 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
73815 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
73816 return new;
73817 }
73818
73819 diff --git a/include/net/ip.h b/include/net/ip.h
73820 index a68f838..74518ab 100644
73821 --- a/include/net/ip.h
73822 +++ b/include/net/ip.h
73823 @@ -202,7 +202,7 @@ extern struct local_ports {
73824 } sysctl_local_ports;
73825 extern void inet_get_local_port_range(int *low, int *high);
73826
73827 -extern unsigned long *sysctl_local_reserved_ports;
73828 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
73829 static inline int inet_is_reserved_local_port(int port)
73830 {
73831 return test_bit(port, sysctl_local_reserved_ports);
73832 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
73833 index e49db91..76a81de 100644
73834 --- a/include/net/ip_fib.h
73835 +++ b/include/net/ip_fib.h
73836 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
73837
73838 #define FIB_RES_SADDR(net, res) \
73839 ((FIB_RES_NH(res).nh_saddr_genid == \
73840 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
73841 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
73842 FIB_RES_NH(res).nh_saddr : \
73843 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
73844 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
73845 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
73846 index 4c062cc..3562c31 100644
73847 --- a/include/net/ip_vs.h
73848 +++ b/include/net/ip_vs.h
73849 @@ -612,7 +612,7 @@ struct ip_vs_conn {
73850 struct ip_vs_conn *control; /* Master control connection */
73851 atomic_t n_control; /* Number of controlled ones */
73852 struct ip_vs_dest *dest; /* real server */
73853 - atomic_t in_pkts; /* incoming packet counter */
73854 + atomic_unchecked_t in_pkts; /* incoming packet counter */
73855
73856 /* packet transmitter for different forwarding methods. If it
73857 mangles the packet, it must return NF_DROP or better NF_STOLEN,
73858 @@ -761,7 +761,7 @@ struct ip_vs_dest {
73859 __be16 port; /* port number of the server */
73860 union nf_inet_addr addr; /* IP address of the server */
73861 volatile unsigned int flags; /* dest status flags */
73862 - atomic_t conn_flags; /* flags to copy to conn */
73863 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
73864 atomic_t weight; /* server weight */
73865
73866 atomic_t refcnt; /* reference counter */
73867 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
73868 /* ip_vs_lblc */
73869 int sysctl_lblc_expiration;
73870 struct ctl_table_header *lblc_ctl_header;
73871 - struct ctl_table *lblc_ctl_table;
73872 + ctl_table_no_const *lblc_ctl_table;
73873 /* ip_vs_lblcr */
73874 int sysctl_lblcr_expiration;
73875 struct ctl_table_header *lblcr_ctl_header;
73876 - struct ctl_table *lblcr_ctl_table;
73877 + ctl_table_no_const *lblcr_ctl_table;
73878 /* ip_vs_est */
73879 struct list_head est_list; /* estimator list */
73880 spinlock_t est_lock;
73881 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
73882 index 80ffde3..968b0f4 100644
73883 --- a/include/net/irda/ircomm_tty.h
73884 +++ b/include/net/irda/ircomm_tty.h
73885 @@ -35,6 +35,7 @@
73886 #include <linux/termios.h>
73887 #include <linux/timer.h>
73888 #include <linux/tty.h> /* struct tty_struct */
73889 +#include <asm/local.h>
73890
73891 #include <net/irda/irias_object.h>
73892 #include <net/irda/ircomm_core.h>
73893 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
73894 index 714cc9a..ea05f3e 100644
73895 --- a/include/net/iucv/af_iucv.h
73896 +++ b/include/net/iucv/af_iucv.h
73897 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
73898 struct iucv_sock_list {
73899 struct hlist_head head;
73900 rwlock_t lock;
73901 - atomic_t autobind_name;
73902 + atomic_unchecked_t autobind_name;
73903 };
73904
73905 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
73906 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
73907 index df83f69..9b640b8 100644
73908 --- a/include/net/llc_c_ac.h
73909 +++ b/include/net/llc_c_ac.h
73910 @@ -87,7 +87,7 @@
73911 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
73912 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
73913
73914 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73915 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73916
73917 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
73918 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
73919 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
73920 index 6ca3113..f8026dd 100644
73921 --- a/include/net/llc_c_ev.h
73922 +++ b/include/net/llc_c_ev.h
73923 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
73924 return (struct llc_conn_state_ev *)skb->cb;
73925 }
73926
73927 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73928 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73929 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73930 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73931
73932 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
73933 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
73934 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
73935 index 0e79cfb..f46db31 100644
73936 --- a/include/net/llc_c_st.h
73937 +++ b/include/net/llc_c_st.h
73938 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
73939 u8 next_state;
73940 llc_conn_ev_qfyr_t *ev_qualifiers;
73941 llc_conn_action_t *ev_actions;
73942 -};
73943 +} __do_const;
73944
73945 struct llc_conn_state {
73946 u8 current_state;
73947 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
73948 index 37a3bbd..55a4241 100644
73949 --- a/include/net/llc_s_ac.h
73950 +++ b/include/net/llc_s_ac.h
73951 @@ -23,7 +23,7 @@
73952 #define SAP_ACT_TEST_IND 9
73953
73954 /* All action functions must look like this */
73955 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73956 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73957
73958 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
73959 struct sk_buff *skb);
73960 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
73961 index 567c681..cd73ac0 100644
73962 --- a/include/net/llc_s_st.h
73963 +++ b/include/net/llc_s_st.h
73964 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
73965 llc_sap_ev_t ev;
73966 u8 next_state;
73967 llc_sap_action_t *ev_actions;
73968 -};
73969 +} __do_const;
73970
73971 struct llc_sap_state {
73972 u8 curr_state;
73973 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
73974 index 885898a..cdace34 100644
73975 --- a/include/net/mac80211.h
73976 +++ b/include/net/mac80211.h
73977 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
73978 void (*add_sta_debugfs)(void *priv, void *priv_sta,
73979 struct dentry *dir);
73980 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
73981 -};
73982 +} __do_const;
73983
73984 static inline int rate_supported(struct ieee80211_sta *sta,
73985 enum ieee80211_band band,
73986 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
73987 index 7e748ad..5c6229b 100644
73988 --- a/include/net/neighbour.h
73989 +++ b/include/net/neighbour.h
73990 @@ -123,7 +123,7 @@ struct neigh_ops {
73991 void (*error_report)(struct neighbour *, struct sk_buff *);
73992 int (*output)(struct neighbour *, struct sk_buff *);
73993 int (*connected_output)(struct neighbour *, struct sk_buff *);
73994 -};
73995 +} __do_const;
73996
73997 struct pneigh_entry {
73998 struct pneigh_entry *next;
73999 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
74000 index b176978..ea169f4 100644
74001 --- a/include/net/net_namespace.h
74002 +++ b/include/net/net_namespace.h
74003 @@ -117,7 +117,7 @@ struct net {
74004 #endif
74005 struct netns_ipvs *ipvs;
74006 struct sock *diag_nlsk;
74007 - atomic_t rt_genid;
74008 + atomic_unchecked_t rt_genid;
74009 };
74010
74011 /*
74012 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
74013 #define __net_init __init
74014 #define __net_exit __exit_refok
74015 #define __net_initdata __initdata
74016 +#ifdef CONSTIFY_PLUGIN
74017 #define __net_initconst __initconst
74018 +#else
74019 +#define __net_initconst __initdata
74020 +#endif
74021 #endif
74022
74023 struct pernet_operations {
74024 @@ -284,7 +288,7 @@ struct pernet_operations {
74025 void (*exit_batch)(struct list_head *net_exit_list);
74026 int *id;
74027 size_t size;
74028 -};
74029 +} __do_const;
74030
74031 /*
74032 * Use these carefully. If you implement a network device and it
74033 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
74034
74035 static inline int rt_genid(struct net *net)
74036 {
74037 - return atomic_read(&net->rt_genid);
74038 + return atomic_read_unchecked(&net->rt_genid);
74039 }
74040
74041 static inline void rt_genid_bump(struct net *net)
74042 {
74043 - atomic_inc(&net->rt_genid);
74044 + atomic_inc_unchecked(&net->rt_genid);
74045 }
74046
74047 #endif /* __NET_NET_NAMESPACE_H */
74048 diff --git a/include/net/netdma.h b/include/net/netdma.h
74049 index 8ba8ce2..99b7fff 100644
74050 --- a/include/net/netdma.h
74051 +++ b/include/net/netdma.h
74052 @@ -24,7 +24,7 @@
74053 #include <linux/dmaengine.h>
74054 #include <linux/skbuff.h>
74055
74056 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
74057 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
74058 struct sk_buff *skb, int offset, struct iovec *to,
74059 size_t len, struct dma_pinned_list *pinned_list);
74060
74061 diff --git a/include/net/netlink.h b/include/net/netlink.h
74062 index 9690b0f..87aded7 100644
74063 --- a/include/net/netlink.h
74064 +++ b/include/net/netlink.h
74065 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
74066 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
74067 {
74068 if (mark)
74069 - skb_trim(skb, (unsigned char *) mark - skb->data);
74070 + skb_trim(skb, (const unsigned char *) mark - skb->data);
74071 }
74072
74073 /**
74074 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
74075 index c9c0c53..53f24c3 100644
74076 --- a/include/net/netns/conntrack.h
74077 +++ b/include/net/netns/conntrack.h
74078 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
74079 struct nf_proto_net {
74080 #ifdef CONFIG_SYSCTL
74081 struct ctl_table_header *ctl_table_header;
74082 - struct ctl_table *ctl_table;
74083 + ctl_table_no_const *ctl_table;
74084 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
74085 struct ctl_table_header *ctl_compat_header;
74086 - struct ctl_table *ctl_compat_table;
74087 + ctl_table_no_const *ctl_compat_table;
74088 #endif
74089 #endif
74090 unsigned int users;
74091 @@ -58,7 +58,7 @@ struct nf_ip_net {
74092 struct nf_icmp_net icmpv6;
74093 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
74094 struct ctl_table_header *ctl_table_header;
74095 - struct ctl_table *ctl_table;
74096 + ctl_table_no_const *ctl_table;
74097 #endif
74098 };
74099
74100 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
74101 index 2ba9de8..47bd6c7 100644
74102 --- a/include/net/netns/ipv4.h
74103 +++ b/include/net/netns/ipv4.h
74104 @@ -67,7 +67,7 @@ struct netns_ipv4 {
74105 kgid_t sysctl_ping_group_range[2];
74106 long sysctl_tcp_mem[3];
74107
74108 - atomic_t dev_addr_genid;
74109 + atomic_unchecked_t dev_addr_genid;
74110
74111 #ifdef CONFIG_IP_MROUTE
74112 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
74113 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
74114 index 005e2c2..023d340 100644
74115 --- a/include/net/netns/ipv6.h
74116 +++ b/include/net/netns/ipv6.h
74117 @@ -71,7 +71,7 @@ struct netns_ipv6 {
74118 struct fib_rules_ops *mr6_rules_ops;
74119 #endif
74120 #endif
74121 - atomic_t dev_addr_genid;
74122 + atomic_unchecked_t dev_addr_genid;
74123 };
74124
74125 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
74126 diff --git a/include/net/protocol.h b/include/net/protocol.h
74127 index 047c047..b9dad15 100644
74128 --- a/include/net/protocol.h
74129 +++ b/include/net/protocol.h
74130 @@ -44,7 +44,7 @@ struct net_protocol {
74131 void (*err_handler)(struct sk_buff *skb, u32 info);
74132 unsigned int no_policy:1,
74133 netns_ok:1;
74134 -};
74135 +} __do_const;
74136
74137 #if IS_ENABLED(CONFIG_IPV6)
74138 struct inet6_protocol {
74139 @@ -57,7 +57,7 @@ struct inet6_protocol {
74140 u8 type, u8 code, int offset,
74141 __be32 info);
74142 unsigned int flags; /* INET6_PROTO_xxx */
74143 -};
74144 +} __do_const;
74145
74146 #define INET6_PROTO_NOPOLICY 0x1
74147 #define INET6_PROTO_FINAL 0x2
74148 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
74149 index 7026648..584cc8c 100644
74150 --- a/include/net/rtnetlink.h
74151 +++ b/include/net/rtnetlink.h
74152 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
74153 const struct net_device *dev);
74154 unsigned int (*get_num_tx_queues)(void);
74155 unsigned int (*get_num_rx_queues)(void);
74156 -};
74157 +} __do_const;
74158
74159 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
74160 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
74161 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
74162 index cd89510..d67810f 100644
74163 --- a/include/net/sctp/sctp.h
74164 +++ b/include/net/sctp/sctp.h
74165 @@ -330,9 +330,9 @@ do { \
74166
74167 #else /* SCTP_DEBUG */
74168
74169 -#define SCTP_DEBUG_PRINTK(whatever...)
74170 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
74171 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
74172 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
74173 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
74174 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
74175 #define SCTP_ENABLE_DEBUG
74176 #define SCTP_DISABLE_DEBUG
74177 #define SCTP_ASSERT(expr, str, func)
74178 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
74179 index 2a82d13..62a31c2 100644
74180 --- a/include/net/sctp/sm.h
74181 +++ b/include/net/sctp/sm.h
74182 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
74183 typedef struct {
74184 sctp_state_fn_t *fn;
74185 const char *name;
74186 -} sctp_sm_table_entry_t;
74187 +} __do_const sctp_sm_table_entry_t;
74188
74189 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
74190 * currently in use.
74191 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
74192 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
74193
74194 /* Extern declarations for major data structures. */
74195 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
74196 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
74197
74198
74199 /* Get the size of a DATA chunk payload. */
74200 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
74201 index 1bd4c41..9250b5b 100644
74202 --- a/include/net/sctp/structs.h
74203 +++ b/include/net/sctp/structs.h
74204 @@ -516,7 +516,7 @@ struct sctp_pf {
74205 struct sctp_association *asoc);
74206 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
74207 struct sctp_af *af;
74208 -};
74209 +} __do_const;
74210
74211
74212 /* Structure to track chunk fragments that have been acked, but peer
74213 diff --git a/include/net/sock.h b/include/net/sock.h
74214 index 66772cf..25bc45b 100644
74215 --- a/include/net/sock.h
74216 +++ b/include/net/sock.h
74217 @@ -325,7 +325,7 @@ struct sock {
74218 #ifdef CONFIG_RPS
74219 __u32 sk_rxhash;
74220 #endif
74221 - atomic_t sk_drops;
74222 + atomic_unchecked_t sk_drops;
74223 int sk_rcvbuf;
74224
74225 struct sk_filter __rcu *sk_filter;
74226 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
74227 }
74228
74229 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
74230 - char __user *from, char *to,
74231 + char __user *from, unsigned char *to,
74232 int copy, int offset)
74233 {
74234 if (skb->ip_summed == CHECKSUM_NONE) {
74235 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
74236 }
74237 }
74238
74239 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
74240 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
74241
74242 /**
74243 * sk_page_frag - return an appropriate page_frag
74244 diff --git a/include/net/tcp.h b/include/net/tcp.h
74245 index 5bba80f..8520a82 100644
74246 --- a/include/net/tcp.h
74247 +++ b/include/net/tcp.h
74248 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
74249 extern void tcp_xmit_retransmit_queue(struct sock *);
74250 extern void tcp_simple_retransmit(struct sock *);
74251 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
74252 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
74253 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
74254
74255 extern void tcp_send_probe0(struct sock *);
74256 extern void tcp_send_partial(struct sock *);
74257 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
74258 struct inet6_skb_parm h6;
74259 #endif
74260 } header; /* For incoming frames */
74261 - __u32 seq; /* Starting sequence number */
74262 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
74263 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
74264 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
74265 __u32 when; /* used to compute rtt's */
74266 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
74267
74268 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
74269
74270 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
74271 /* 1 byte hole */
74272 - __u32 ack_seq; /* Sequence number ACK'd */
74273 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
74274 };
74275
74276 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
74277 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
74278 index 94ce082..62b278d 100644
74279 --- a/include/net/xfrm.h
74280 +++ b/include/net/xfrm.h
74281 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
74282 struct net_device *dev,
74283 const struct flowi *fl);
74284 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
74285 -};
74286 +} __do_const;
74287
74288 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
74289 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
74290 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
74291 struct sk_buff *skb);
74292 int (*transport_finish)(struct sk_buff *skb,
74293 int async);
74294 -};
74295 +} __do_const;
74296
74297 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
74298 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
74299 @@ -424,7 +424,7 @@ struct xfrm_mode {
74300 struct module *owner;
74301 unsigned int encap;
74302 int flags;
74303 -};
74304 +} __do_const;
74305
74306 /* Flags for xfrm_mode. */
74307 enum {
74308 @@ -521,7 +521,7 @@ struct xfrm_policy {
74309 struct timer_list timer;
74310
74311 struct flow_cache_object flo;
74312 - atomic_t genid;
74313 + atomic_unchecked_t genid;
74314 u32 priority;
74315 u32 index;
74316 struct xfrm_mark mark;
74317 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
74318 index 1a046b1..ee0bef0 100644
74319 --- a/include/rdma/iw_cm.h
74320 +++ b/include/rdma/iw_cm.h
74321 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
74322 int backlog);
74323
74324 int (*destroy_listen)(struct iw_cm_id *cm_id);
74325 -};
74326 +} __no_const;
74327
74328 /**
74329 * iw_create_cm_id - Create an IW CM identifier.
74330 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
74331 index e1379b4..67eafbe 100644
74332 --- a/include/scsi/libfc.h
74333 +++ b/include/scsi/libfc.h
74334 @@ -762,6 +762,7 @@ struct libfc_function_template {
74335 */
74336 void (*disc_stop_final) (struct fc_lport *);
74337 };
74338 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
74339
74340 /**
74341 * struct fc_disc - Discovery context
74342 @@ -866,7 +867,7 @@ struct fc_lport {
74343 struct fc_vport *vport;
74344
74345 /* Operational Information */
74346 - struct libfc_function_template tt;
74347 + libfc_function_template_no_const tt;
74348 u8 link_up;
74349 u8 qfull;
74350 enum fc_lport_state state;
74351 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
74352 index cc64587..608f523 100644
74353 --- a/include/scsi/scsi_device.h
74354 +++ b/include/scsi/scsi_device.h
74355 @@ -171,9 +171,9 @@ struct scsi_device {
74356 unsigned int max_device_blocked; /* what device_blocked counts down from */
74357 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
74358
74359 - atomic_t iorequest_cnt;
74360 - atomic_t iodone_cnt;
74361 - atomic_t ioerr_cnt;
74362 + atomic_unchecked_t iorequest_cnt;
74363 + atomic_unchecked_t iodone_cnt;
74364 + atomic_unchecked_t ioerr_cnt;
74365
74366 struct device sdev_gendev,
74367 sdev_dev;
74368 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
74369 index b797e8f..8e2c3aa 100644
74370 --- a/include/scsi/scsi_transport_fc.h
74371 +++ b/include/scsi/scsi_transport_fc.h
74372 @@ -751,7 +751,8 @@ struct fc_function_template {
74373 unsigned long show_host_system_hostname:1;
74374
74375 unsigned long disable_target_scan:1;
74376 -};
74377 +} __do_const;
74378 +typedef struct fc_function_template __no_const fc_function_template_no_const;
74379
74380
74381 /**
74382 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
74383 index 9031a26..750d592 100644
74384 --- a/include/sound/compress_driver.h
74385 +++ b/include/sound/compress_driver.h
74386 @@ -128,7 +128,7 @@ struct snd_compr_ops {
74387 struct snd_compr_caps *caps);
74388 int (*get_codec_caps) (struct snd_compr_stream *stream,
74389 struct snd_compr_codec_caps *codec);
74390 -};
74391 +} __no_const;
74392
74393 /**
74394 * struct snd_compr: Compressed device
74395 diff --git a/include/sound/soc.h b/include/sound/soc.h
74396 index 85c1522..f44bad1 100644
74397 --- a/include/sound/soc.h
74398 +++ b/include/sound/soc.h
74399 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
74400 /* probe ordering - for components with runtime dependencies */
74401 int probe_order;
74402 int remove_order;
74403 -};
74404 +} __do_const;
74405
74406 /* SoC platform interface */
74407 struct snd_soc_platform_driver {
74408 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
74409 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
74410 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
74411 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
74412 -};
74413 +} __do_const;
74414
74415 struct snd_soc_platform {
74416 const char *name;
74417 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
74418 index 4ea4f98..a63629b 100644
74419 --- a/include/target/target_core_base.h
74420 +++ b/include/target/target_core_base.h
74421 @@ -653,7 +653,7 @@ struct se_device {
74422 spinlock_t stats_lock;
74423 /* Active commands on this virtual SE device */
74424 atomic_t simple_cmds;
74425 - atomic_t dev_ordered_id;
74426 + atomic_unchecked_t dev_ordered_id;
74427 atomic_t dev_ordered_sync;
74428 atomic_t dev_qf_count;
74429 int export_count;
74430 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
74431 new file mode 100644
74432 index 0000000..fb634b7
74433 --- /dev/null
74434 +++ b/include/trace/events/fs.h
74435 @@ -0,0 +1,53 @@
74436 +#undef TRACE_SYSTEM
74437 +#define TRACE_SYSTEM fs
74438 +
74439 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
74440 +#define _TRACE_FS_H
74441 +
74442 +#include <linux/fs.h>
74443 +#include <linux/tracepoint.h>
74444 +
74445 +TRACE_EVENT(do_sys_open,
74446 +
74447 + TP_PROTO(const char *filename, int flags, int mode),
74448 +
74449 + TP_ARGS(filename, flags, mode),
74450 +
74451 + TP_STRUCT__entry(
74452 + __string( filename, filename )
74453 + __field( int, flags )
74454 + __field( int, mode )
74455 + ),
74456 +
74457 + TP_fast_assign(
74458 + __assign_str(filename, filename);
74459 + __entry->flags = flags;
74460 + __entry->mode = mode;
74461 + ),
74462 +
74463 + TP_printk("\"%s\" %x %o",
74464 + __get_str(filename), __entry->flags, __entry->mode)
74465 +);
74466 +
74467 +TRACE_EVENT(open_exec,
74468 +
74469 + TP_PROTO(const char *filename),
74470 +
74471 + TP_ARGS(filename),
74472 +
74473 + TP_STRUCT__entry(
74474 + __string( filename, filename )
74475 + ),
74476 +
74477 + TP_fast_assign(
74478 + __assign_str(filename, filename);
74479 + ),
74480 +
74481 + TP_printk("\"%s\"",
74482 + __get_str(filename))
74483 +);
74484 +
74485 +#endif /* _TRACE_FS_H */
74486 +
74487 +/* This part must be outside protection */
74488 +#include <trace/define_trace.h>
74489 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
74490 index 1c09820..7f5ec79 100644
74491 --- a/include/trace/events/irq.h
74492 +++ b/include/trace/events/irq.h
74493 @@ -36,7 +36,7 @@ struct softirq_action;
74494 */
74495 TRACE_EVENT(irq_handler_entry,
74496
74497 - TP_PROTO(int irq, struct irqaction *action),
74498 + TP_PROTO(int irq, const struct irqaction *action),
74499
74500 TP_ARGS(irq, action),
74501
74502 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
74503 */
74504 TRACE_EVENT(irq_handler_exit,
74505
74506 - TP_PROTO(int irq, struct irqaction *action, int ret),
74507 + TP_PROTO(int irq, const struct irqaction *action, int ret),
74508
74509 TP_ARGS(irq, action, ret),
74510
74511 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
74512 index 7caf44c..23c6f27 100644
74513 --- a/include/uapi/linux/a.out.h
74514 +++ b/include/uapi/linux/a.out.h
74515 @@ -39,6 +39,14 @@ enum machine_type {
74516 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
74517 };
74518
74519 +/* Constants for the N_FLAGS field */
74520 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
74521 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
74522 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
74523 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
74524 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
74525 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
74526 +
74527 #if !defined (N_MAGIC)
74528 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
74529 #endif
74530 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
74531 index d876736..ccce5c0 100644
74532 --- a/include/uapi/linux/byteorder/little_endian.h
74533 +++ b/include/uapi/linux/byteorder/little_endian.h
74534 @@ -42,51 +42,51 @@
74535
74536 static inline __le64 __cpu_to_le64p(const __u64 *p)
74537 {
74538 - return (__force __le64)*p;
74539 + return (__force const __le64)*p;
74540 }
74541 -static inline __u64 __le64_to_cpup(const __le64 *p)
74542 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
74543 {
74544 - return (__force __u64)*p;
74545 + return (__force const __u64)*p;
74546 }
74547 static inline __le32 __cpu_to_le32p(const __u32 *p)
74548 {
74549 - return (__force __le32)*p;
74550 + return (__force const __le32)*p;
74551 }
74552 static inline __u32 __le32_to_cpup(const __le32 *p)
74553 {
74554 - return (__force __u32)*p;
74555 + return (__force const __u32)*p;
74556 }
74557 static inline __le16 __cpu_to_le16p(const __u16 *p)
74558 {
74559 - return (__force __le16)*p;
74560 + return (__force const __le16)*p;
74561 }
74562 static inline __u16 __le16_to_cpup(const __le16 *p)
74563 {
74564 - return (__force __u16)*p;
74565 + return (__force const __u16)*p;
74566 }
74567 static inline __be64 __cpu_to_be64p(const __u64 *p)
74568 {
74569 - return (__force __be64)__swab64p(p);
74570 + return (__force const __be64)__swab64p(p);
74571 }
74572 static inline __u64 __be64_to_cpup(const __be64 *p)
74573 {
74574 - return __swab64p((__u64 *)p);
74575 + return __swab64p((const __u64 *)p);
74576 }
74577 static inline __be32 __cpu_to_be32p(const __u32 *p)
74578 {
74579 - return (__force __be32)__swab32p(p);
74580 + return (__force const __be32)__swab32p(p);
74581 }
74582 -static inline __u32 __be32_to_cpup(const __be32 *p)
74583 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
74584 {
74585 - return __swab32p((__u32 *)p);
74586 + return __swab32p((const __u32 *)p);
74587 }
74588 static inline __be16 __cpu_to_be16p(const __u16 *p)
74589 {
74590 - return (__force __be16)__swab16p(p);
74591 + return (__force const __be16)__swab16p(p);
74592 }
74593 static inline __u16 __be16_to_cpup(const __be16 *p)
74594 {
74595 - return __swab16p((__u16 *)p);
74596 + return __swab16p((const __u16 *)p);
74597 }
74598 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
74599 #define __le64_to_cpus(x) do { (void)(x); } while (0)
74600 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
74601 index ef6103b..d4e65dd 100644
74602 --- a/include/uapi/linux/elf.h
74603 +++ b/include/uapi/linux/elf.h
74604 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
74605 #define PT_GNU_EH_FRAME 0x6474e550
74606
74607 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
74608 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
74609 +
74610 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
74611 +
74612 +/* Constants for the e_flags field */
74613 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
74614 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
74615 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
74616 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
74617 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
74618 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
74619
74620 /*
74621 * Extended Numbering
74622 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
74623 #define DT_DEBUG 21
74624 #define DT_TEXTREL 22
74625 #define DT_JMPREL 23
74626 +#define DT_FLAGS 30
74627 + #define DF_TEXTREL 0x00000004
74628 #define DT_ENCODING 32
74629 #define OLD_DT_LOOS 0x60000000
74630 #define DT_LOOS 0x6000000d
74631 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
74632 #define PF_W 0x2
74633 #define PF_X 0x1
74634
74635 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
74636 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
74637 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
74638 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
74639 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
74640 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
74641 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
74642 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
74643 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
74644 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
74645 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
74646 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
74647 +
74648 typedef struct elf32_phdr{
74649 Elf32_Word p_type;
74650 Elf32_Off p_offset;
74651 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
74652 #define EI_OSABI 7
74653 #define EI_PAD 8
74654
74655 +#define EI_PAX 14
74656 +
74657 #define ELFMAG0 0x7f /* EI_MAG */
74658 #define ELFMAG1 'E'
74659 #define ELFMAG2 'L'
74660 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
74661 index aa169c4..6a2771d 100644
74662 --- a/include/uapi/linux/personality.h
74663 +++ b/include/uapi/linux/personality.h
74664 @@ -30,6 +30,7 @@ enum {
74665 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
74666 ADDR_NO_RANDOMIZE | \
74667 ADDR_COMPAT_LAYOUT | \
74668 + ADDR_LIMIT_3GB | \
74669 MMAP_PAGE_ZERO)
74670
74671 /*
74672 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
74673 index 7530e74..e714828 100644
74674 --- a/include/uapi/linux/screen_info.h
74675 +++ b/include/uapi/linux/screen_info.h
74676 @@ -43,7 +43,8 @@ struct screen_info {
74677 __u16 pages; /* 0x32 */
74678 __u16 vesa_attributes; /* 0x34 */
74679 __u32 capabilities; /* 0x36 */
74680 - __u8 _reserved[6]; /* 0x3a */
74681 + __u16 vesapm_size; /* 0x3a */
74682 + __u8 _reserved[4]; /* 0x3c */
74683 } __attribute__((packed));
74684
74685 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
74686 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
74687 index 0e011eb..82681b1 100644
74688 --- a/include/uapi/linux/swab.h
74689 +++ b/include/uapi/linux/swab.h
74690 @@ -43,7 +43,7 @@
74691 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
74692 */
74693
74694 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
74695 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
74696 {
74697 #ifdef __HAVE_BUILTIN_BSWAP16__
74698 return __builtin_bswap16(val);
74699 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
74700 #endif
74701 }
74702
74703 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
74704 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
74705 {
74706 #ifdef __HAVE_BUILTIN_BSWAP32__
74707 return __builtin_bswap32(val);
74708 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
74709 #endif
74710 }
74711
74712 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
74713 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
74714 {
74715 #ifdef __HAVE_BUILTIN_BSWAP64__
74716 return __builtin_bswap64(val);
74717 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
74718 index 6d67213..8dab561 100644
74719 --- a/include/uapi/linux/sysctl.h
74720 +++ b/include/uapi/linux/sysctl.h
74721 @@ -155,7 +155,11 @@ enum
74722 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
74723 };
74724
74725 -
74726 +#ifdef CONFIG_PAX_SOFTMODE
74727 +enum {
74728 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
74729 +};
74730 +#endif
74731
74732 /* CTL_VM names: */
74733 enum
74734 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
74735 index e4629b9..6958086 100644
74736 --- a/include/uapi/linux/xattr.h
74737 +++ b/include/uapi/linux/xattr.h
74738 @@ -63,5 +63,9 @@
74739 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
74740 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
74741
74742 +/* User namespace */
74743 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
74744 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
74745 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
74746
74747 #endif /* _UAPI_LINUX_XATTR_H */
74748 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
74749 index f9466fa..f4e2b81 100644
74750 --- a/include/video/udlfb.h
74751 +++ b/include/video/udlfb.h
74752 @@ -53,10 +53,10 @@ struct dlfb_data {
74753 u32 pseudo_palette[256];
74754 int blank_mode; /*one of FB_BLANK_ */
74755 /* blit-only rendering path metrics, exposed through sysfs */
74756 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
74757 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
74758 - atomic_t bytes_sent; /* to usb, after compression including overhead */
74759 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
74760 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
74761 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
74762 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
74763 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
74764 };
74765
74766 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
74767 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
74768 index 1a91850..28573f8 100644
74769 --- a/include/video/uvesafb.h
74770 +++ b/include/video/uvesafb.h
74771 @@ -122,6 +122,7 @@ struct uvesafb_par {
74772 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
74773 u8 pmi_setpal; /* PMI for palette changes */
74774 u16 *pmi_base; /* protected mode interface location */
74775 + u8 *pmi_code; /* protected mode code location */
74776 void *pmi_start;
74777 void *pmi_pal;
74778 u8 *vbe_state_orig; /*
74779 diff --git a/init/Kconfig b/init/Kconfig
74780 index 2d9b831..ae4c8ac 100644
74781 --- a/init/Kconfig
74782 +++ b/init/Kconfig
74783 @@ -1029,6 +1029,7 @@ endif # CGROUPS
74784
74785 config CHECKPOINT_RESTORE
74786 bool "Checkpoint/restore support" if EXPERT
74787 + depends on !GRKERNSEC
74788 default n
74789 help
74790 Enables additional kernel features in a sake of checkpoint/restore.
74791 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
74792
74793 config COMPAT_BRK
74794 bool "Disable heap randomization"
74795 - default y
74796 + default n
74797 help
74798 Randomizing heap placement makes heap exploits harder, but it
74799 also breaks ancient binaries (including anything libc5 based).
74800 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
74801 config STOP_MACHINE
74802 bool
74803 default y
74804 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
74805 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
74806 help
74807 Need stop_machine() primitive.
74808
74809 diff --git a/init/Makefile b/init/Makefile
74810 index 7bc47ee..6da2dc7 100644
74811 --- a/init/Makefile
74812 +++ b/init/Makefile
74813 @@ -2,6 +2,9 @@
74814 # Makefile for the linux kernel.
74815 #
74816
74817 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
74818 +asflags-y := $(GCC_PLUGINS_AFLAGS)
74819 +
74820 obj-y := main.o version.o mounts.o
74821 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
74822 obj-y += noinitramfs.o
74823 diff --git a/init/do_mounts.c b/init/do_mounts.c
74824 index a2b49f2..03a0e17c 100644
74825 --- a/init/do_mounts.c
74826 +++ b/init/do_mounts.c
74827 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
74828 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
74829 {
74830 struct super_block *s;
74831 - int err = sys_mount(name, "/root", fs, flags, data);
74832 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
74833 if (err)
74834 return err;
74835
74836 - sys_chdir("/root");
74837 + sys_chdir((const char __force_user *)"/root");
74838 s = current->fs->pwd.dentry->d_sb;
74839 ROOT_DEV = s->s_dev;
74840 printk(KERN_INFO
74841 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
74842 va_start(args, fmt);
74843 vsprintf(buf, fmt, args);
74844 va_end(args);
74845 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
74846 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
74847 if (fd >= 0) {
74848 sys_ioctl(fd, FDEJECT, 0);
74849 sys_close(fd);
74850 }
74851 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
74852 - fd = sys_open("/dev/console", O_RDWR, 0);
74853 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
74854 if (fd >= 0) {
74855 sys_ioctl(fd, TCGETS, (long)&termios);
74856 termios.c_lflag &= ~ICANON;
74857 sys_ioctl(fd, TCSETSF, (long)&termios);
74858 - sys_read(fd, &c, 1);
74859 + sys_read(fd, (char __user *)&c, 1);
74860 termios.c_lflag |= ICANON;
74861 sys_ioctl(fd, TCSETSF, (long)&termios);
74862 sys_close(fd);
74863 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
74864 mount_root();
74865 out:
74866 devtmpfs_mount("dev");
74867 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74868 - sys_chroot(".");
74869 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74870 + sys_chroot((const char __force_user *)".");
74871 }
74872 diff --git a/init/do_mounts.h b/init/do_mounts.h
74873 index f5b978a..69dbfe8 100644
74874 --- a/init/do_mounts.h
74875 +++ b/init/do_mounts.h
74876 @@ -15,15 +15,15 @@ extern int root_mountflags;
74877
74878 static inline int create_dev(char *name, dev_t dev)
74879 {
74880 - sys_unlink(name);
74881 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
74882 + sys_unlink((char __force_user *)name);
74883 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
74884 }
74885
74886 #if BITS_PER_LONG == 32
74887 static inline u32 bstat(char *name)
74888 {
74889 struct stat64 stat;
74890 - if (sys_stat64(name, &stat) != 0)
74891 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
74892 return 0;
74893 if (!S_ISBLK(stat.st_mode))
74894 return 0;
74895 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
74896 static inline u32 bstat(char *name)
74897 {
74898 struct stat stat;
74899 - if (sys_newstat(name, &stat) != 0)
74900 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
74901 return 0;
74902 if (!S_ISBLK(stat.st_mode))
74903 return 0;
74904 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
74905 index 3e0878e..8a9d7a0 100644
74906 --- a/init/do_mounts_initrd.c
74907 +++ b/init/do_mounts_initrd.c
74908 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
74909 {
74910 sys_unshare(CLONE_FS | CLONE_FILES);
74911 /* stdin/stdout/stderr for /linuxrc */
74912 - sys_open("/dev/console", O_RDWR, 0);
74913 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
74914 sys_dup(0);
74915 sys_dup(0);
74916 /* move initrd over / and chdir/chroot in initrd root */
74917 - sys_chdir("/root");
74918 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74919 - sys_chroot(".");
74920 + sys_chdir((const char __force_user *)"/root");
74921 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74922 + sys_chroot((const char __force_user *)".");
74923 sys_setsid();
74924 return 0;
74925 }
74926 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
74927 create_dev("/dev/root.old", Root_RAM0);
74928 /* mount initrd on rootfs' /root */
74929 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
74930 - sys_mkdir("/old", 0700);
74931 - sys_chdir("/old");
74932 + sys_mkdir((const char __force_user *)"/old", 0700);
74933 + sys_chdir((const char __force_user *)"/old");
74934
74935 /* try loading default modules from initrd */
74936 load_default_modules();
74937 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
74938 current->flags &= ~PF_FREEZER_SKIP;
74939
74940 /* move initrd to rootfs' /old */
74941 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
74942 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
74943 /* switch root and cwd back to / of rootfs */
74944 - sys_chroot("..");
74945 + sys_chroot((const char __force_user *)"..");
74946
74947 if (new_decode_dev(real_root_dev) == Root_RAM0) {
74948 - sys_chdir("/old");
74949 + sys_chdir((const char __force_user *)"/old");
74950 return;
74951 }
74952
74953 - sys_chdir("/");
74954 + sys_chdir((const char __force_user *)"/");
74955 ROOT_DEV = new_decode_dev(real_root_dev);
74956 mount_root();
74957
74958 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
74959 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
74960 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
74961 if (!error)
74962 printk("okay\n");
74963 else {
74964 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
74965 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
74966 if (error == -ENOENT)
74967 printk("/initrd does not exist. Ignored.\n");
74968 else
74969 printk("failed\n");
74970 printk(KERN_NOTICE "Unmounting old root\n");
74971 - sys_umount("/old", MNT_DETACH);
74972 + sys_umount((char __force_user *)"/old", MNT_DETACH);
74973 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
74974 if (fd < 0) {
74975 error = fd;
74976 @@ -127,11 +127,11 @@ int __init initrd_load(void)
74977 * mounted in the normal path.
74978 */
74979 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
74980 - sys_unlink("/initrd.image");
74981 + sys_unlink((const char __force_user *)"/initrd.image");
74982 handle_initrd();
74983 return 1;
74984 }
74985 }
74986 - sys_unlink("/initrd.image");
74987 + sys_unlink((const char __force_user *)"/initrd.image");
74988 return 0;
74989 }
74990 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
74991 index 8cb6db5..d729f50 100644
74992 --- a/init/do_mounts_md.c
74993 +++ b/init/do_mounts_md.c
74994 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
74995 partitioned ? "_d" : "", minor,
74996 md_setup_args[ent].device_names);
74997
74998 - fd = sys_open(name, 0, 0);
74999 + fd = sys_open((char __force_user *)name, 0, 0);
75000 if (fd < 0) {
75001 printk(KERN_ERR "md: open failed - cannot start "
75002 "array %s\n", name);
75003 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
75004 * array without it
75005 */
75006 sys_close(fd);
75007 - fd = sys_open(name, 0, 0);
75008 + fd = sys_open((char __force_user *)name, 0, 0);
75009 sys_ioctl(fd, BLKRRPART, 0);
75010 }
75011 sys_close(fd);
75012 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
75013
75014 wait_for_device_probe();
75015
75016 - fd = sys_open("/dev/md0", 0, 0);
75017 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
75018 if (fd >= 0) {
75019 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
75020 sys_close(fd);
75021 diff --git a/init/init_task.c b/init/init_task.c
75022 index ba0a7f36..2bcf1d5 100644
75023 --- a/init/init_task.c
75024 +++ b/init/init_task.c
75025 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
75026 * Initial thread structure. Alignment of this is handled by a special
75027 * linker map entry.
75028 */
75029 +#ifdef CONFIG_X86
75030 +union thread_union init_thread_union __init_task_data;
75031 +#else
75032 union thread_union init_thread_union __init_task_data =
75033 { INIT_THREAD_INFO(init_task) };
75034 +#endif
75035 diff --git a/init/initramfs.c b/init/initramfs.c
75036 index a67ef9d..2d17ed9 100644
75037 --- a/init/initramfs.c
75038 +++ b/init/initramfs.c
75039 @@ -84,7 +84,7 @@ static void __init free_hash(void)
75040 }
75041 }
75042
75043 -static long __init do_utime(char *filename, time_t mtime)
75044 +static long __init do_utime(char __force_user *filename, time_t mtime)
75045 {
75046 struct timespec t[2];
75047
75048 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
75049 struct dir_entry *de, *tmp;
75050 list_for_each_entry_safe(de, tmp, &dir_list, list) {
75051 list_del(&de->list);
75052 - do_utime(de->name, de->mtime);
75053 + do_utime((char __force_user *)de->name, de->mtime);
75054 kfree(de->name);
75055 kfree(de);
75056 }
75057 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
75058 if (nlink >= 2) {
75059 char *old = find_link(major, minor, ino, mode, collected);
75060 if (old)
75061 - return (sys_link(old, collected) < 0) ? -1 : 1;
75062 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
75063 }
75064 return 0;
75065 }
75066 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
75067 {
75068 struct stat st;
75069
75070 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
75071 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
75072 if (S_ISDIR(st.st_mode))
75073 - sys_rmdir(path);
75074 + sys_rmdir((char __force_user *)path);
75075 else
75076 - sys_unlink(path);
75077 + sys_unlink((char __force_user *)path);
75078 }
75079 }
75080
75081 @@ -315,7 +315,7 @@ static int __init do_name(void)
75082 int openflags = O_WRONLY|O_CREAT;
75083 if (ml != 1)
75084 openflags |= O_TRUNC;
75085 - wfd = sys_open(collected, openflags, mode);
75086 + wfd = sys_open((char __force_user *)collected, openflags, mode);
75087
75088 if (wfd >= 0) {
75089 sys_fchown(wfd, uid, gid);
75090 @@ -327,17 +327,17 @@ static int __init do_name(void)
75091 }
75092 }
75093 } else if (S_ISDIR(mode)) {
75094 - sys_mkdir(collected, mode);
75095 - sys_chown(collected, uid, gid);
75096 - sys_chmod(collected, mode);
75097 + sys_mkdir((char __force_user *)collected, mode);
75098 + sys_chown((char __force_user *)collected, uid, gid);
75099 + sys_chmod((char __force_user *)collected, mode);
75100 dir_add(collected, mtime);
75101 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
75102 S_ISFIFO(mode) || S_ISSOCK(mode)) {
75103 if (maybe_link() == 0) {
75104 - sys_mknod(collected, mode, rdev);
75105 - sys_chown(collected, uid, gid);
75106 - sys_chmod(collected, mode);
75107 - do_utime(collected, mtime);
75108 + sys_mknod((char __force_user *)collected, mode, rdev);
75109 + sys_chown((char __force_user *)collected, uid, gid);
75110 + sys_chmod((char __force_user *)collected, mode);
75111 + do_utime((char __force_user *)collected, mtime);
75112 }
75113 }
75114 return 0;
75115 @@ -346,15 +346,15 @@ static int __init do_name(void)
75116 static int __init do_copy(void)
75117 {
75118 if (count >= body_len) {
75119 - sys_write(wfd, victim, body_len);
75120 + sys_write(wfd, (char __force_user *)victim, body_len);
75121 sys_close(wfd);
75122 - do_utime(vcollected, mtime);
75123 + do_utime((char __force_user *)vcollected, mtime);
75124 kfree(vcollected);
75125 eat(body_len);
75126 state = SkipIt;
75127 return 0;
75128 } else {
75129 - sys_write(wfd, victim, count);
75130 + sys_write(wfd, (char __force_user *)victim, count);
75131 body_len -= count;
75132 eat(count);
75133 return 1;
75134 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
75135 {
75136 collected[N_ALIGN(name_len) + body_len] = '\0';
75137 clean_path(collected, 0);
75138 - sys_symlink(collected + N_ALIGN(name_len), collected);
75139 - sys_lchown(collected, uid, gid);
75140 - do_utime(collected, mtime);
75141 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
75142 + sys_lchown((char __force_user *)collected, uid, gid);
75143 + do_utime((char __force_user *)collected, mtime);
75144 state = SkipIt;
75145 next_state = Reset;
75146 return 0;
75147 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
75148 {
75149 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
75150 if (err)
75151 - panic(err); /* Failed to decompress INTERNAL initramfs */
75152 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
75153 if (initrd_start) {
75154 #ifdef CONFIG_BLK_DEV_RAM
75155 int fd;
75156 diff --git a/init/main.c b/init/main.c
75157 index 9484f4b..4c01430 100644
75158 --- a/init/main.c
75159 +++ b/init/main.c
75160 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
75161 extern void tc_init(void);
75162 #endif
75163
75164 +extern void grsecurity_init(void);
75165 +
75166 /*
75167 * Debug helper: via this flag we know that we are in 'early bootup code'
75168 * where only the boot processor is running with IRQ disabled. This means
75169 @@ -153,6 +155,64 @@ static int __init set_reset_devices(char *str)
75170
75171 __setup("reset_devices", set_reset_devices);
75172
75173 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
75174 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
75175 +static int __init setup_grsec_proc_gid(char *str)
75176 +{
75177 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
75178 + return 1;
75179 +}
75180 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
75181 +#endif
75182 +
75183 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
75184 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
75185 +EXPORT_SYMBOL(pax_user_shadow_base);
75186 +extern char pax_enter_kernel_user[];
75187 +extern char pax_exit_kernel_user[];
75188 +extern pgdval_t clone_pgd_mask;
75189 +#endif
75190 +
75191 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
75192 +static int __init setup_pax_nouderef(char *str)
75193 +{
75194 +#ifdef CONFIG_X86_32
75195 + unsigned int cpu;
75196 + struct desc_struct *gdt;
75197 +
75198 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
75199 + gdt = get_cpu_gdt_table(cpu);
75200 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
75201 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
75202 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
75203 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
75204 + }
75205 + loadsegment(ds, __KERNEL_DS);
75206 + loadsegment(es, __KERNEL_DS);
75207 + loadsegment(ss, __KERNEL_DS);
75208 +#else
75209 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
75210 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
75211 + clone_pgd_mask = ~(pgdval_t)0UL;
75212 + pax_user_shadow_base = 0UL;
75213 +#endif
75214 +
75215 + return 0;
75216 +}
75217 +early_param("pax_nouderef", setup_pax_nouderef);
75218 +#endif
75219 +
75220 +#ifdef CONFIG_PAX_SOFTMODE
75221 +int pax_softmode;
75222 +
75223 +static int __init setup_pax_softmode(char *str)
75224 +{
75225 + get_option(&str, &pax_softmode);
75226 + return 1;
75227 +}
75228 +__setup("pax_softmode=", setup_pax_softmode);
75229 +#endif
75230 +
75231 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
75232 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
75233 static const char *panic_later, *panic_param;
75234 @@ -655,8 +715,6 @@ static void __init do_ctors(void)
75235 bool initcall_debug;
75236 core_param(initcall_debug, initcall_debug, bool, 0644);
75237
75238 -static char msgbuf[64];
75239 -
75240 static int __init_or_module do_one_initcall_debug(initcall_t fn)
75241 {
75242 ktime_t calltime, delta, rettime;
75243 @@ -679,23 +737,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
75244 {
75245 int count = preempt_count();
75246 int ret;
75247 + const char *msg1 = "", *msg2 = "";
75248
75249 if (initcall_debug)
75250 ret = do_one_initcall_debug(fn);
75251 else
75252 ret = fn();
75253
75254 - msgbuf[0] = 0;
75255 -
75256 if (preempt_count() != count) {
75257 - sprintf(msgbuf, "preemption imbalance ");
75258 + msg1 = " preemption imbalance";
75259 preempt_count() = count;
75260 }
75261 if (irqs_disabled()) {
75262 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
75263 + msg2 = " disabled interrupts";
75264 local_irq_enable();
75265 }
75266 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
75267 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
75268
75269 return ret;
75270 }
75271 @@ -748,8 +805,14 @@ static void __init do_initcall_level(int level)
75272 level, level,
75273 &repair_env_string);
75274
75275 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
75276 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
75277 do_one_initcall(*fn);
75278 +
75279 +#ifdef LATENT_ENTROPY_PLUGIN
75280 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
75281 +#endif
75282 +
75283 + }
75284 }
75285
75286 static void __init do_initcalls(void)
75287 @@ -783,8 +846,14 @@ static void __init do_pre_smp_initcalls(void)
75288 {
75289 initcall_t *fn;
75290
75291 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
75292 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
75293 do_one_initcall(*fn);
75294 +
75295 +#ifdef LATENT_ENTROPY_PLUGIN
75296 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
75297 +#endif
75298 +
75299 + }
75300 }
75301
75302 /*
75303 @@ -802,8 +871,8 @@ static int run_init_process(const char *init_filename)
75304 {
75305 argv_init[0] = init_filename;
75306 return do_execve(init_filename,
75307 - (const char __user *const __user *)argv_init,
75308 - (const char __user *const __user *)envp_init);
75309 + (const char __user *const __force_user *)argv_init,
75310 + (const char __user *const __force_user *)envp_init);
75311 }
75312
75313 static noinline void __init kernel_init_freeable(void);
75314 @@ -880,7 +949,7 @@ static noinline void __init kernel_init_freeable(void)
75315 do_basic_setup();
75316
75317 /* Open the /dev/console on the rootfs, this should never fail */
75318 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
75319 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
75320 pr_err("Warning: unable to open an initial console.\n");
75321
75322 (void) sys_dup(0);
75323 @@ -893,11 +962,13 @@ static noinline void __init kernel_init_freeable(void)
75324 if (!ramdisk_execute_command)
75325 ramdisk_execute_command = "/init";
75326
75327 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
75328 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
75329 ramdisk_execute_command = NULL;
75330 prepare_namespace();
75331 }
75332
75333 + grsecurity_init();
75334 +
75335 /*
75336 * Ok, we have completed the initial bootup, and
75337 * we're essentially up and running. Get rid of the
75338 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
75339 index 130dfec..cc88451 100644
75340 --- a/ipc/ipc_sysctl.c
75341 +++ b/ipc/ipc_sysctl.c
75342 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
75343 static int proc_ipc_dointvec(ctl_table *table, int write,
75344 void __user *buffer, size_t *lenp, loff_t *ppos)
75345 {
75346 - struct ctl_table ipc_table;
75347 + ctl_table_no_const ipc_table;
75348
75349 memcpy(&ipc_table, table, sizeof(ipc_table));
75350 ipc_table.data = get_ipc(table);
75351 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
75352 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
75353 void __user *buffer, size_t *lenp, loff_t *ppos)
75354 {
75355 - struct ctl_table ipc_table;
75356 + ctl_table_no_const ipc_table;
75357
75358 memcpy(&ipc_table, table, sizeof(ipc_table));
75359 ipc_table.data = get_ipc(table);
75360 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
75361 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
75362 void __user *buffer, size_t *lenp, loff_t *ppos)
75363 {
75364 - struct ctl_table ipc_table;
75365 + ctl_table_no_const ipc_table;
75366 size_t lenp_bef = *lenp;
75367 int rc;
75368
75369 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
75370 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
75371 void __user *buffer, size_t *lenp, loff_t *ppos)
75372 {
75373 - struct ctl_table ipc_table;
75374 + ctl_table_no_const ipc_table;
75375 memcpy(&ipc_table, table, sizeof(ipc_table));
75376 ipc_table.data = get_ipc(table);
75377
75378 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
75379 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
75380 void __user *buffer, size_t *lenp, loff_t *ppos)
75381 {
75382 - struct ctl_table ipc_table;
75383 + ctl_table_no_const ipc_table;
75384 size_t lenp_bef = *lenp;
75385 int oldval;
75386 int rc;
75387 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
75388 index 383d638..943fdbb 100644
75389 --- a/ipc/mq_sysctl.c
75390 +++ b/ipc/mq_sysctl.c
75391 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
75392 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
75393 void __user *buffer, size_t *lenp, loff_t *ppos)
75394 {
75395 - struct ctl_table mq_table;
75396 + ctl_table_no_const mq_table;
75397 memcpy(&mq_table, table, sizeof(mq_table));
75398 mq_table.data = get_mq(table);
75399
75400 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
75401 index e4e47f6..a85e0ad 100644
75402 --- a/ipc/mqueue.c
75403 +++ b/ipc/mqueue.c
75404 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
75405 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
75406 info->attr.mq_msgsize);
75407
75408 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
75409 spin_lock(&mq_lock);
75410 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
75411 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
75412 diff --git a/ipc/msg.c b/ipc/msg.c
75413 index d0c6d96..69a893c 100644
75414 --- a/ipc/msg.c
75415 +++ b/ipc/msg.c
75416 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
75417 return security_msg_queue_associate(msq, msgflg);
75418 }
75419
75420 +static struct ipc_ops msg_ops = {
75421 + .getnew = newque,
75422 + .associate = msg_security,
75423 + .more_checks = NULL
75424 +};
75425 +
75426 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
75427 {
75428 struct ipc_namespace *ns;
75429 - struct ipc_ops msg_ops;
75430 struct ipc_params msg_params;
75431
75432 ns = current->nsproxy->ipc_ns;
75433
75434 - msg_ops.getnew = newque;
75435 - msg_ops.associate = msg_security;
75436 - msg_ops.more_checks = NULL;
75437 -
75438 msg_params.key = key;
75439 msg_params.flg = msgflg;
75440
75441 diff --git a/ipc/sem.c b/ipc/sem.c
75442 index 70480a3..f4e8262 100644
75443 --- a/ipc/sem.c
75444 +++ b/ipc/sem.c
75445 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
75446 return 0;
75447 }
75448
75449 +static struct ipc_ops sem_ops = {
75450 + .getnew = newary,
75451 + .associate = sem_security,
75452 + .more_checks = sem_more_checks
75453 +};
75454 +
75455 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
75456 {
75457 struct ipc_namespace *ns;
75458 - struct ipc_ops sem_ops;
75459 struct ipc_params sem_params;
75460
75461 ns = current->nsproxy->ipc_ns;
75462 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
75463 if (nsems < 0 || nsems > ns->sc_semmsl)
75464 return -EINVAL;
75465
75466 - sem_ops.getnew = newary;
75467 - sem_ops.associate = sem_security;
75468 - sem_ops.more_checks = sem_more_checks;
75469 -
75470 sem_params.key = key;
75471 sem_params.flg = semflg;
75472 sem_params.u.nsems = nsems;
75473 diff --git a/ipc/shm.c b/ipc/shm.c
75474 index 7e199fa..180a1ca 100644
75475 --- a/ipc/shm.c
75476 +++ b/ipc/shm.c
75477 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
75478 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
75479 #endif
75480
75481 +#ifdef CONFIG_GRKERNSEC
75482 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
75483 + const time_t shm_createtime, const kuid_t cuid,
75484 + const int shmid);
75485 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
75486 + const time_t shm_createtime);
75487 +#endif
75488 +
75489 void shm_init_ns(struct ipc_namespace *ns)
75490 {
75491 ns->shm_ctlmax = SHMMAX;
75492 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
75493 shp->shm_lprid = 0;
75494 shp->shm_atim = shp->shm_dtim = 0;
75495 shp->shm_ctim = get_seconds();
75496 +#ifdef CONFIG_GRKERNSEC
75497 + {
75498 + struct timespec timeval;
75499 + do_posix_clock_monotonic_gettime(&timeval);
75500 +
75501 + shp->shm_createtime = timeval.tv_sec;
75502 + }
75503 +#endif
75504 shp->shm_segsz = size;
75505 shp->shm_nattch = 0;
75506 shp->shm_file = file;
75507 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
75508 return 0;
75509 }
75510
75511 +static struct ipc_ops shm_ops = {
75512 + .getnew = newseg,
75513 + .associate = shm_security,
75514 + .more_checks = shm_more_checks
75515 +};
75516 +
75517 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
75518 {
75519 struct ipc_namespace *ns;
75520 - struct ipc_ops shm_ops;
75521 struct ipc_params shm_params;
75522
75523 ns = current->nsproxy->ipc_ns;
75524
75525 - shm_ops.getnew = newseg;
75526 - shm_ops.associate = shm_security;
75527 - shm_ops.more_checks = shm_more_checks;
75528 -
75529 shm_params.key = key;
75530 shm_params.flg = shmflg;
75531 shm_params.u.size = size;
75532 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
75533 f_mode = FMODE_READ | FMODE_WRITE;
75534 }
75535 if (shmflg & SHM_EXEC) {
75536 +
75537 +#ifdef CONFIG_PAX_MPROTECT
75538 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
75539 + goto out;
75540 +#endif
75541 +
75542 prot |= PROT_EXEC;
75543 acc_mode |= S_IXUGO;
75544 }
75545 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
75546 if (err)
75547 goto out_unlock;
75548
75549 +#ifdef CONFIG_GRKERNSEC
75550 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
75551 + shp->shm_perm.cuid, shmid) ||
75552 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
75553 + err = -EACCES;
75554 + goto out_unlock;
75555 + }
75556 +#endif
75557 +
75558 path = shp->shm_file->f_path;
75559 path_get(&path);
75560 shp->shm_nattch++;
75561 +#ifdef CONFIG_GRKERNSEC
75562 + shp->shm_lapid = current->pid;
75563 +#endif
75564 size = i_size_read(path.dentry->d_inode);
75565 shm_unlock(shp);
75566
75567 diff --git a/kernel/acct.c b/kernel/acct.c
75568 index 8d6e145..33e0b1e 100644
75569 --- a/kernel/acct.c
75570 +++ b/kernel/acct.c
75571 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
75572 */
75573 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
75574 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
75575 - file->f_op->write(file, (char *)&ac,
75576 + file->f_op->write(file, (char __force_user *)&ac,
75577 sizeof(acct_t), &file->f_pos);
75578 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
75579 set_fs(fs);
75580 diff --git a/kernel/audit.c b/kernel/audit.c
75581 index 91e53d0..d9e3ec4 100644
75582 --- a/kernel/audit.c
75583 +++ b/kernel/audit.c
75584 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
75585 3) suppressed due to audit_rate_limit
75586 4) suppressed due to audit_backlog_limit
75587 */
75588 -static atomic_t audit_lost = ATOMIC_INIT(0);
75589 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
75590
75591 /* The netlink socket. */
75592 static struct sock *audit_sock;
75593 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
75594 unsigned long now;
75595 int print;
75596
75597 - atomic_inc(&audit_lost);
75598 + atomic_inc_unchecked(&audit_lost);
75599
75600 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
75601
75602 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
75603 printk(KERN_WARNING
75604 "audit: audit_lost=%d audit_rate_limit=%d "
75605 "audit_backlog_limit=%d\n",
75606 - atomic_read(&audit_lost),
75607 + atomic_read_unchecked(&audit_lost),
75608 audit_rate_limit,
75609 audit_backlog_limit);
75610 audit_panic(message);
75611 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
75612 status_set.pid = audit_pid;
75613 status_set.rate_limit = audit_rate_limit;
75614 status_set.backlog_limit = audit_backlog_limit;
75615 - status_set.lost = atomic_read(&audit_lost);
75616 + status_set.lost = atomic_read_unchecked(&audit_lost);
75617 status_set.backlog = skb_queue_len(&audit_skb_queue);
75618 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
75619 &status_set, sizeof(status_set));
75620 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
75621 index 6bd4a90..0ee9eff 100644
75622 --- a/kernel/auditfilter.c
75623 +++ b/kernel/auditfilter.c
75624 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
75625 f->lsm_rule = NULL;
75626
75627 /* Support legacy tests for a valid loginuid */
75628 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
75629 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
75630 f->type = AUDIT_LOGINUID_SET;
75631 f->val = 0;
75632 }
75633 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
75634 index 3c8a601..3a416f6 100644
75635 --- a/kernel/auditsc.c
75636 +++ b/kernel/auditsc.c
75637 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
75638 }
75639
75640 /* global counter which is incremented every time something logs in */
75641 -static atomic_t session_id = ATOMIC_INIT(0);
75642 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
75643
75644 /**
75645 * audit_set_loginuid - set current task's audit_context loginuid
75646 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
75647 return -EPERM;
75648 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
75649
75650 - sessionid = atomic_inc_return(&session_id);
75651 + sessionid = atomic_inc_return_unchecked(&session_id);
75652 if (context && context->in_syscall) {
75653 struct audit_buffer *ab;
75654
75655 diff --git a/kernel/capability.c b/kernel/capability.c
75656 index f6c2ce5..982c0f9 100644
75657 --- a/kernel/capability.c
75658 +++ b/kernel/capability.c
75659 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
75660 * before modification is attempted and the application
75661 * fails.
75662 */
75663 + if (tocopy > ARRAY_SIZE(kdata))
75664 + return -EFAULT;
75665 +
75666 if (copy_to_user(dataptr, kdata, tocopy
75667 * sizeof(struct __user_cap_data_struct))) {
75668 return -EFAULT;
75669 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
75670 int ret;
75671
75672 rcu_read_lock();
75673 - ret = security_capable(__task_cred(t), ns, cap);
75674 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
75675 + gr_task_is_capable(t, __task_cred(t), cap);
75676 rcu_read_unlock();
75677
75678 - return (ret == 0);
75679 + return ret;
75680 }
75681
75682 /**
75683 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
75684 int ret;
75685
75686 rcu_read_lock();
75687 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
75688 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
75689 rcu_read_unlock();
75690
75691 - return (ret == 0);
75692 + return ret;
75693 }
75694
75695 /**
75696 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
75697 BUG();
75698 }
75699
75700 - if (security_capable(current_cred(), ns, cap) == 0) {
75701 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
75702 current->flags |= PF_SUPERPRIV;
75703 return true;
75704 }
75705 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
75706 }
75707 EXPORT_SYMBOL(ns_capable);
75708
75709 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
75710 +{
75711 + if (unlikely(!cap_valid(cap))) {
75712 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
75713 + BUG();
75714 + }
75715 +
75716 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
75717 + current->flags |= PF_SUPERPRIV;
75718 + return true;
75719 + }
75720 + return false;
75721 +}
75722 +EXPORT_SYMBOL(ns_capable_nolog);
75723 +
75724 /**
75725 * file_ns_capable - Determine if the file's opener had a capability in effect
75726 * @file: The file we want to check
75727 @@ -432,6 +451,12 @@ bool capable(int cap)
75728 }
75729 EXPORT_SYMBOL(capable);
75730
75731 +bool capable_nolog(int cap)
75732 +{
75733 + return ns_capable_nolog(&init_user_ns, cap);
75734 +}
75735 +EXPORT_SYMBOL(capable_nolog);
75736 +
75737 /**
75738 * nsown_capable - Check superior capability to one's own user_ns
75739 * @cap: The capability in question
75740 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
75741
75742 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
75743 }
75744 +
75745 +bool inode_capable_nolog(const struct inode *inode, int cap)
75746 +{
75747 + struct user_namespace *ns = current_user_ns();
75748 +
75749 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
75750 +}
75751 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
75752 index c6e77ef..af531a0 100644
75753 --- a/kernel/cgroup.c
75754 +++ b/kernel/cgroup.c
75755 @@ -5391,7 +5391,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
75756 struct css_set *cg = link->cg;
75757 struct task_struct *task;
75758 int count = 0;
75759 - seq_printf(seq, "css_set %p\n", cg);
75760 + seq_printf(seq, "css_set %pK\n", cg);
75761 list_for_each_entry(task, &cg->tasks, cg_list) {
75762 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
75763 seq_puts(seq, " ...\n");
75764 diff --git a/kernel/compat.c b/kernel/compat.c
75765 index 0a09e48..f44f3f0 100644
75766 --- a/kernel/compat.c
75767 +++ b/kernel/compat.c
75768 @@ -13,6 +13,7 @@
75769
75770 #include <linux/linkage.h>
75771 #include <linux/compat.h>
75772 +#include <linux/module.h>
75773 #include <linux/errno.h>
75774 #include <linux/time.h>
75775 #include <linux/signal.h>
75776 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
75777 mm_segment_t oldfs;
75778 long ret;
75779
75780 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
75781 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
75782 oldfs = get_fs();
75783 set_fs(KERNEL_DS);
75784 ret = hrtimer_nanosleep_restart(restart);
75785 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
75786 oldfs = get_fs();
75787 set_fs(KERNEL_DS);
75788 ret = hrtimer_nanosleep(&tu,
75789 - rmtp ? (struct timespec __user *)&rmt : NULL,
75790 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
75791 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
75792 set_fs(oldfs);
75793
75794 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
75795 mm_segment_t old_fs = get_fs();
75796
75797 set_fs(KERNEL_DS);
75798 - ret = sys_sigpending((old_sigset_t __user *) &s);
75799 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
75800 set_fs(old_fs);
75801 if (ret == 0)
75802 ret = put_user(s, set);
75803 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
75804 mm_segment_t old_fs = get_fs();
75805
75806 set_fs(KERNEL_DS);
75807 - ret = sys_old_getrlimit(resource, &r);
75808 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
75809 set_fs(old_fs);
75810
75811 if (!ret) {
75812 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
75813 set_fs (KERNEL_DS);
75814 ret = sys_wait4(pid,
75815 (stat_addr ?
75816 - (unsigned int __user *) &status : NULL),
75817 - options, (struct rusage __user *) &r);
75818 + (unsigned int __force_user *) &status : NULL),
75819 + options, (struct rusage __force_user *) &r);
75820 set_fs (old_fs);
75821
75822 if (ret > 0) {
75823 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
75824 memset(&info, 0, sizeof(info));
75825
75826 set_fs(KERNEL_DS);
75827 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
75828 - uru ? (struct rusage __user *)&ru : NULL);
75829 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
75830 + uru ? (struct rusage __force_user *)&ru : NULL);
75831 set_fs(old_fs);
75832
75833 if ((ret < 0) || (info.si_signo == 0))
75834 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
75835 oldfs = get_fs();
75836 set_fs(KERNEL_DS);
75837 err = sys_timer_settime(timer_id, flags,
75838 - (struct itimerspec __user *) &newts,
75839 - (struct itimerspec __user *) &oldts);
75840 + (struct itimerspec __force_user *) &newts,
75841 + (struct itimerspec __force_user *) &oldts);
75842 set_fs(oldfs);
75843 if (!err && old && put_compat_itimerspec(old, &oldts))
75844 return -EFAULT;
75845 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
75846 oldfs = get_fs();
75847 set_fs(KERNEL_DS);
75848 err = sys_timer_gettime(timer_id,
75849 - (struct itimerspec __user *) &ts);
75850 + (struct itimerspec __force_user *) &ts);
75851 set_fs(oldfs);
75852 if (!err && put_compat_itimerspec(setting, &ts))
75853 return -EFAULT;
75854 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
75855 oldfs = get_fs();
75856 set_fs(KERNEL_DS);
75857 err = sys_clock_settime(which_clock,
75858 - (struct timespec __user *) &ts);
75859 + (struct timespec __force_user *) &ts);
75860 set_fs(oldfs);
75861 return err;
75862 }
75863 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
75864 oldfs = get_fs();
75865 set_fs(KERNEL_DS);
75866 err = sys_clock_gettime(which_clock,
75867 - (struct timespec __user *) &ts);
75868 + (struct timespec __force_user *) &ts);
75869 set_fs(oldfs);
75870 if (!err && put_compat_timespec(&ts, tp))
75871 return -EFAULT;
75872 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
75873
75874 oldfs = get_fs();
75875 set_fs(KERNEL_DS);
75876 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
75877 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
75878 set_fs(oldfs);
75879
75880 err = compat_put_timex(utp, &txc);
75881 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
75882 oldfs = get_fs();
75883 set_fs(KERNEL_DS);
75884 err = sys_clock_getres(which_clock,
75885 - (struct timespec __user *) &ts);
75886 + (struct timespec __force_user *) &ts);
75887 set_fs(oldfs);
75888 if (!err && tp && put_compat_timespec(&ts, tp))
75889 return -EFAULT;
75890 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
75891 long err;
75892 mm_segment_t oldfs;
75893 struct timespec tu;
75894 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
75895 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
75896
75897 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
75898 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
75899 oldfs = get_fs();
75900 set_fs(KERNEL_DS);
75901 err = clock_nanosleep_restart(restart);
75902 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
75903 oldfs = get_fs();
75904 set_fs(KERNEL_DS);
75905 err = sys_clock_nanosleep(which_clock, flags,
75906 - (struct timespec __user *) &in,
75907 - (struct timespec __user *) &out);
75908 + (struct timespec __force_user *) &in,
75909 + (struct timespec __force_user *) &out);
75910 set_fs(oldfs);
75911
75912 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
75913 diff --git a/kernel/configs.c b/kernel/configs.c
75914 index c18b1f1..b9a0132 100644
75915 --- a/kernel/configs.c
75916 +++ b/kernel/configs.c
75917 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
75918 struct proc_dir_entry *entry;
75919
75920 /* create the current config file */
75921 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
75922 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
75923 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
75924 + &ikconfig_file_ops);
75925 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75926 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
75927 + &ikconfig_file_ops);
75928 +#endif
75929 +#else
75930 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
75931 &ikconfig_file_ops);
75932 +#endif
75933 +
75934 if (!entry)
75935 return -ENOMEM;
75936
75937 diff --git a/kernel/cred.c b/kernel/cred.c
75938 index e0573a4..3874e41 100644
75939 --- a/kernel/cred.c
75940 +++ b/kernel/cred.c
75941 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
75942 validate_creds(cred);
75943 alter_cred_subscribers(cred, -1);
75944 put_cred(cred);
75945 +
75946 +#ifdef CONFIG_GRKERNSEC_SETXID
75947 + cred = (struct cred *) tsk->delayed_cred;
75948 + if (cred != NULL) {
75949 + tsk->delayed_cred = NULL;
75950 + validate_creds(cred);
75951 + alter_cred_subscribers(cred, -1);
75952 + put_cred(cred);
75953 + }
75954 +#endif
75955 }
75956
75957 /**
75958 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
75959 * Always returns 0 thus allowing this function to be tail-called at the end
75960 * of, say, sys_setgid().
75961 */
75962 -int commit_creds(struct cred *new)
75963 +static int __commit_creds(struct cred *new)
75964 {
75965 struct task_struct *task = current;
75966 const struct cred *old = task->real_cred;
75967 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
75968
75969 get_cred(new); /* we will require a ref for the subj creds too */
75970
75971 + gr_set_role_label(task, new->uid, new->gid);
75972 +
75973 /* dumpability changes */
75974 if (!uid_eq(old->euid, new->euid) ||
75975 !gid_eq(old->egid, new->egid) ||
75976 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
75977 put_cred(old);
75978 return 0;
75979 }
75980 +#ifdef CONFIG_GRKERNSEC_SETXID
75981 +extern int set_user(struct cred *new);
75982 +
75983 +void gr_delayed_cred_worker(void)
75984 +{
75985 + const struct cred *new = current->delayed_cred;
75986 + struct cred *ncred;
75987 +
75988 + current->delayed_cred = NULL;
75989 +
75990 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
75991 + // from doing get_cred on it when queueing this
75992 + put_cred(new);
75993 + return;
75994 + } else if (new == NULL)
75995 + return;
75996 +
75997 + ncred = prepare_creds();
75998 + if (!ncred)
75999 + goto die;
76000 + // uids
76001 + ncred->uid = new->uid;
76002 + ncred->euid = new->euid;
76003 + ncred->suid = new->suid;
76004 + ncred->fsuid = new->fsuid;
76005 + // gids
76006 + ncred->gid = new->gid;
76007 + ncred->egid = new->egid;
76008 + ncred->sgid = new->sgid;
76009 + ncred->fsgid = new->fsgid;
76010 + // groups
76011 + if (set_groups(ncred, new->group_info) < 0) {
76012 + abort_creds(ncred);
76013 + goto die;
76014 + }
76015 + // caps
76016 + ncred->securebits = new->securebits;
76017 + ncred->cap_inheritable = new->cap_inheritable;
76018 + ncred->cap_permitted = new->cap_permitted;
76019 + ncred->cap_effective = new->cap_effective;
76020 + ncred->cap_bset = new->cap_bset;
76021 +
76022 + if (set_user(ncred)) {
76023 + abort_creds(ncred);
76024 + goto die;
76025 + }
76026 +
76027 + // from doing get_cred on it when queueing this
76028 + put_cred(new);
76029 +
76030 + __commit_creds(ncred);
76031 + return;
76032 +die:
76033 + // from doing get_cred on it when queueing this
76034 + put_cred(new);
76035 + do_group_exit(SIGKILL);
76036 +}
76037 +#endif
76038 +
76039 +int commit_creds(struct cred *new)
76040 +{
76041 +#ifdef CONFIG_GRKERNSEC_SETXID
76042 + int ret;
76043 + int schedule_it = 0;
76044 + struct task_struct *t;
76045 +
76046 + /* we won't get called with tasklist_lock held for writing
76047 + and interrupts disabled as the cred struct in that case is
76048 + init_cred
76049 + */
76050 + if (grsec_enable_setxid && !current_is_single_threaded() &&
76051 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
76052 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
76053 + schedule_it = 1;
76054 + }
76055 + ret = __commit_creds(new);
76056 + if (schedule_it) {
76057 + rcu_read_lock();
76058 + read_lock(&tasklist_lock);
76059 + for (t = next_thread(current); t != current;
76060 + t = next_thread(t)) {
76061 + if (t->delayed_cred == NULL) {
76062 + t->delayed_cred = get_cred(new);
76063 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
76064 + set_tsk_need_resched(t);
76065 + }
76066 + }
76067 + read_unlock(&tasklist_lock);
76068 + rcu_read_unlock();
76069 + }
76070 + return ret;
76071 +#else
76072 + return __commit_creds(new);
76073 +#endif
76074 +}
76075 +
76076 EXPORT_SYMBOL(commit_creds);
76077
76078 /**
76079 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
76080 index 0506d44..2c20034 100644
76081 --- a/kernel/debug/debug_core.c
76082 +++ b/kernel/debug/debug_core.c
76083 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
76084 */
76085 static atomic_t masters_in_kgdb;
76086 static atomic_t slaves_in_kgdb;
76087 -static atomic_t kgdb_break_tasklet_var;
76088 +static atomic_unchecked_t kgdb_break_tasklet_var;
76089 atomic_t kgdb_setting_breakpoint;
76090
76091 struct task_struct *kgdb_usethread;
76092 @@ -133,7 +133,7 @@ int kgdb_single_step;
76093 static pid_t kgdb_sstep_pid;
76094
76095 /* to keep track of the CPU which is doing the single stepping*/
76096 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
76097 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
76098
76099 /*
76100 * If you are debugging a problem where roundup (the collection of
76101 @@ -541,7 +541,7 @@ return_normal:
76102 * kernel will only try for the value of sstep_tries before
76103 * giving up and continuing on.
76104 */
76105 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
76106 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
76107 (kgdb_info[cpu].task &&
76108 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
76109 atomic_set(&kgdb_active, -1);
76110 @@ -635,8 +635,8 @@ cpu_master_loop:
76111 }
76112
76113 kgdb_restore:
76114 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
76115 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
76116 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
76117 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
76118 if (kgdb_info[sstep_cpu].task)
76119 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
76120 else
76121 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
76122 static void kgdb_tasklet_bpt(unsigned long ing)
76123 {
76124 kgdb_breakpoint();
76125 - atomic_set(&kgdb_break_tasklet_var, 0);
76126 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
76127 }
76128
76129 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
76130
76131 void kgdb_schedule_breakpoint(void)
76132 {
76133 - if (atomic_read(&kgdb_break_tasklet_var) ||
76134 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
76135 atomic_read(&kgdb_active) != -1 ||
76136 atomic_read(&kgdb_setting_breakpoint))
76137 return;
76138 - atomic_inc(&kgdb_break_tasklet_var);
76139 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
76140 tasklet_schedule(&kgdb_tasklet_breakpoint);
76141 }
76142 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
76143 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
76144 index 00eb8f7..d7e3244 100644
76145 --- a/kernel/debug/kdb/kdb_main.c
76146 +++ b/kernel/debug/kdb/kdb_main.c
76147 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
76148 continue;
76149
76150 kdb_printf("%-20s%8u 0x%p ", mod->name,
76151 - mod->core_size, (void *)mod);
76152 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
76153 #ifdef CONFIG_MODULE_UNLOAD
76154 kdb_printf("%4ld ", module_refcount(mod));
76155 #endif
76156 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
76157 kdb_printf(" (Loading)");
76158 else
76159 kdb_printf(" (Live)");
76160 - kdb_printf(" 0x%p", mod->module_core);
76161 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
76162
76163 #ifdef CONFIG_MODULE_UNLOAD
76164 {
76165 diff --git a/kernel/events/core.c b/kernel/events/core.c
76166 index e76e495..cbfe63a 100644
76167 --- a/kernel/events/core.c
76168 +++ b/kernel/events/core.c
76169 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
76170 * 0 - disallow raw tracepoint access for unpriv
76171 * 1 - disallow cpu events for unpriv
76172 * 2 - disallow kernel profiling for unpriv
76173 + * 3 - disallow all unpriv perf event use
76174 */
76175 -int sysctl_perf_event_paranoid __read_mostly = 1;
76176 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
76177 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
76178 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
76179 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
76180 +#else
76181 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
76182 +#endif
76183
76184 /* Minimum for 512 kiB + 1 user control page */
76185 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
76186 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
76187 return 0;
76188 }
76189
76190 -static atomic64_t perf_event_id;
76191 +static atomic64_unchecked_t perf_event_id;
76192
76193 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
76194 enum event_type_t event_type);
76195 @@ -2747,7 +2754,7 @@ static void __perf_event_read(void *info)
76196
76197 static inline u64 perf_event_count(struct perf_event *event)
76198 {
76199 - return local64_read(&event->count) + atomic64_read(&event->child_count);
76200 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
76201 }
76202
76203 static u64 perf_event_read(struct perf_event *event)
76204 @@ -3093,9 +3100,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
76205 mutex_lock(&event->child_mutex);
76206 total += perf_event_read(event);
76207 *enabled += event->total_time_enabled +
76208 - atomic64_read(&event->child_total_time_enabled);
76209 + atomic64_read_unchecked(&event->child_total_time_enabled);
76210 *running += event->total_time_running +
76211 - atomic64_read(&event->child_total_time_running);
76212 + atomic64_read_unchecked(&event->child_total_time_running);
76213
76214 list_for_each_entry(child, &event->child_list, child_list) {
76215 total += perf_event_read(child);
76216 @@ -3481,10 +3488,10 @@ void perf_event_update_userpage(struct perf_event *event)
76217 userpg->offset -= local64_read(&event->hw.prev_count);
76218
76219 userpg->time_enabled = enabled +
76220 - atomic64_read(&event->child_total_time_enabled);
76221 + atomic64_read_unchecked(&event->child_total_time_enabled);
76222
76223 userpg->time_running = running +
76224 - atomic64_read(&event->child_total_time_running);
76225 + atomic64_read_unchecked(&event->child_total_time_running);
76226
76227 arch_perf_update_userpage(userpg, now);
76228
76229 @@ -4034,7 +4041,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
76230
76231 /* Data. */
76232 sp = perf_user_stack_pointer(regs);
76233 - rem = __output_copy_user(handle, (void *) sp, dump_size);
76234 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
76235 dyn_size = dump_size - rem;
76236
76237 perf_output_skip(handle, rem);
76238 @@ -4122,11 +4129,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
76239 values[n++] = perf_event_count(event);
76240 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
76241 values[n++] = enabled +
76242 - atomic64_read(&event->child_total_time_enabled);
76243 + atomic64_read_unchecked(&event->child_total_time_enabled);
76244 }
76245 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
76246 values[n++] = running +
76247 - atomic64_read(&event->child_total_time_running);
76248 + atomic64_read_unchecked(&event->child_total_time_running);
76249 }
76250 if (read_format & PERF_FORMAT_ID)
76251 values[n++] = primary_event_id(event);
76252 @@ -4835,12 +4842,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
76253 * need to add enough zero bytes after the string to handle
76254 * the 64bit alignment we do later.
76255 */
76256 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
76257 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
76258 if (!buf) {
76259 name = strncpy(tmp, "//enomem", sizeof(tmp));
76260 goto got_name;
76261 }
76262 - name = d_path(&file->f_path, buf, PATH_MAX);
76263 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
76264 if (IS_ERR(name)) {
76265 name = strncpy(tmp, "//toolong", sizeof(tmp));
76266 goto got_name;
76267 @@ -6262,7 +6269,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
76268 event->parent = parent_event;
76269
76270 event->ns = get_pid_ns(task_active_pid_ns(current));
76271 - event->id = atomic64_inc_return(&perf_event_id);
76272 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
76273
76274 event->state = PERF_EVENT_STATE_INACTIVE;
76275
76276 @@ -6572,6 +6579,11 @@ SYSCALL_DEFINE5(perf_event_open,
76277 if (flags & ~PERF_FLAG_ALL)
76278 return -EINVAL;
76279
76280 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
76281 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
76282 + return -EACCES;
76283 +#endif
76284 +
76285 err = perf_copy_attr(attr_uptr, &attr);
76286 if (err)
76287 return err;
76288 @@ -6904,10 +6916,10 @@ static void sync_child_event(struct perf_event *child_event,
76289 /*
76290 * Add back the child's count to the parent's count:
76291 */
76292 - atomic64_add(child_val, &parent_event->child_count);
76293 - atomic64_add(child_event->total_time_enabled,
76294 + atomic64_add_unchecked(child_val, &parent_event->child_count);
76295 + atomic64_add_unchecked(child_event->total_time_enabled,
76296 &parent_event->child_total_time_enabled);
76297 - atomic64_add(child_event->total_time_running,
76298 + atomic64_add_unchecked(child_event->total_time_running,
76299 &parent_event->child_total_time_running);
76300
76301 /*
76302 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
76303 index ca65997..cc8cee4 100644
76304 --- a/kernel/events/internal.h
76305 +++ b/kernel/events/internal.h
76306 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
76307 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
76308 }
76309
76310 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
76311 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
76312 static inline unsigned int \
76313 func_name(struct perf_output_handle *handle, \
76314 - const void *buf, unsigned int len) \
76315 + const void user *buf, unsigned int len) \
76316 { \
76317 unsigned long size, written; \
76318 \
76319 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
76320 return n;
76321 }
76322
76323 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
76324 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
76325
76326 #define MEMCPY_SKIP(dst, src, n) (n)
76327
76328 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
76329 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
76330
76331 #ifndef arch_perf_out_copy_user
76332 #define arch_perf_out_copy_user __copy_from_user_inatomic
76333 #endif
76334
76335 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
76336 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
76337
76338 /* Callchain handling */
76339 extern struct perf_callchain_entry *
76340 diff --git a/kernel/exit.c b/kernel/exit.c
76341 index 7bb73f9..d7978ed 100644
76342 --- a/kernel/exit.c
76343 +++ b/kernel/exit.c
76344 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
76345 struct task_struct *leader;
76346 int zap_leader;
76347 repeat:
76348 +#ifdef CONFIG_NET
76349 + gr_del_task_from_ip_table(p);
76350 +#endif
76351 +
76352 /* don't need to get the RCU readlock here - the process is dead and
76353 * can't be modifying its own credentials. But shut RCU-lockdep up */
76354 rcu_read_lock();
76355 @@ -340,7 +344,7 @@ int allow_signal(int sig)
76356 * know it'll be handled, so that they don't get converted to
76357 * SIGKILL or just silently dropped.
76358 */
76359 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
76360 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
76361 recalc_sigpending();
76362 spin_unlock_irq(&current->sighand->siglock);
76363 return 0;
76364 @@ -709,6 +713,8 @@ void do_exit(long code)
76365 struct task_struct *tsk = current;
76366 int group_dead;
76367
76368 + set_fs(USER_DS);
76369 +
76370 profile_task_exit(tsk);
76371
76372 WARN_ON(blk_needs_flush_plug(tsk));
76373 @@ -725,7 +731,6 @@ void do_exit(long code)
76374 * mm_release()->clear_child_tid() from writing to a user-controlled
76375 * kernel address.
76376 */
76377 - set_fs(USER_DS);
76378
76379 ptrace_event(PTRACE_EVENT_EXIT, code);
76380
76381 @@ -784,6 +789,9 @@ void do_exit(long code)
76382 tsk->exit_code = code;
76383 taskstats_exit(tsk, group_dead);
76384
76385 + gr_acl_handle_psacct(tsk, code);
76386 + gr_acl_handle_exit();
76387 +
76388 exit_mm(tsk);
76389
76390 if (group_dead)
76391 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
76392 * Take down every thread in the group. This is called by fatal signals
76393 * as well as by sys_exit_group (below).
76394 */
76395 -void
76396 +__noreturn void
76397 do_group_exit(int exit_code)
76398 {
76399 struct signal_struct *sig = current->signal;
76400 diff --git a/kernel/fork.c b/kernel/fork.c
76401 index 987b28a..e0102b2 100644
76402 --- a/kernel/fork.c
76403 +++ b/kernel/fork.c
76404 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
76405 *stackend = STACK_END_MAGIC; /* for overflow detection */
76406
76407 #ifdef CONFIG_CC_STACKPROTECTOR
76408 - tsk->stack_canary = get_random_int();
76409 + tsk->stack_canary = pax_get_random_long();
76410 #endif
76411
76412 /*
76413 @@ -345,13 +345,81 @@ free_tsk:
76414 }
76415
76416 #ifdef CONFIG_MMU
76417 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
76418 +{
76419 + struct vm_area_struct *tmp;
76420 + unsigned long charge;
76421 + struct mempolicy *pol;
76422 + struct file *file;
76423 +
76424 + charge = 0;
76425 + if (mpnt->vm_flags & VM_ACCOUNT) {
76426 + unsigned long len = vma_pages(mpnt);
76427 +
76428 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
76429 + goto fail_nomem;
76430 + charge = len;
76431 + }
76432 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
76433 + if (!tmp)
76434 + goto fail_nomem;
76435 + *tmp = *mpnt;
76436 + tmp->vm_mm = mm;
76437 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
76438 + pol = mpol_dup(vma_policy(mpnt));
76439 + if (IS_ERR(pol))
76440 + goto fail_nomem_policy;
76441 + vma_set_policy(tmp, pol);
76442 + if (anon_vma_fork(tmp, mpnt))
76443 + goto fail_nomem_anon_vma_fork;
76444 + tmp->vm_flags &= ~VM_LOCKED;
76445 + tmp->vm_next = tmp->vm_prev = NULL;
76446 + tmp->vm_mirror = NULL;
76447 + file = tmp->vm_file;
76448 + if (file) {
76449 + struct inode *inode = file_inode(file);
76450 + struct address_space *mapping = file->f_mapping;
76451 +
76452 + get_file(file);
76453 + if (tmp->vm_flags & VM_DENYWRITE)
76454 + atomic_dec(&inode->i_writecount);
76455 + mutex_lock(&mapping->i_mmap_mutex);
76456 + if (tmp->vm_flags & VM_SHARED)
76457 + mapping->i_mmap_writable++;
76458 + flush_dcache_mmap_lock(mapping);
76459 + /* insert tmp into the share list, just after mpnt */
76460 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
76461 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
76462 + else
76463 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
76464 + flush_dcache_mmap_unlock(mapping);
76465 + mutex_unlock(&mapping->i_mmap_mutex);
76466 + }
76467 +
76468 + /*
76469 + * Clear hugetlb-related page reserves for children. This only
76470 + * affects MAP_PRIVATE mappings. Faults generated by the child
76471 + * are not guaranteed to succeed, even if read-only
76472 + */
76473 + if (is_vm_hugetlb_page(tmp))
76474 + reset_vma_resv_huge_pages(tmp);
76475 +
76476 + return tmp;
76477 +
76478 +fail_nomem_anon_vma_fork:
76479 + mpol_put(pol);
76480 +fail_nomem_policy:
76481 + kmem_cache_free(vm_area_cachep, tmp);
76482 +fail_nomem:
76483 + vm_unacct_memory(charge);
76484 + return NULL;
76485 +}
76486 +
76487 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
76488 {
76489 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
76490 struct rb_node **rb_link, *rb_parent;
76491 int retval;
76492 - unsigned long charge;
76493 - struct mempolicy *pol;
76494
76495 uprobe_start_dup_mmap();
76496 down_write(&oldmm->mmap_sem);
76497 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
76498 mm->locked_vm = 0;
76499 mm->mmap = NULL;
76500 mm->mmap_cache = NULL;
76501 - mm->free_area_cache = oldmm->mmap_base;
76502 - mm->cached_hole_size = ~0UL;
76503 + mm->free_area_cache = oldmm->free_area_cache;
76504 + mm->cached_hole_size = oldmm->cached_hole_size;
76505 mm->map_count = 0;
76506 cpumask_clear(mm_cpumask(mm));
76507 mm->mm_rb = RB_ROOT;
76508 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
76509
76510 prev = NULL;
76511 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
76512 - struct file *file;
76513 -
76514 if (mpnt->vm_flags & VM_DONTCOPY) {
76515 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
76516 -vma_pages(mpnt));
76517 continue;
76518 }
76519 - charge = 0;
76520 - if (mpnt->vm_flags & VM_ACCOUNT) {
76521 - unsigned long len = vma_pages(mpnt);
76522 -
76523 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
76524 - goto fail_nomem;
76525 - charge = len;
76526 - }
76527 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
76528 - if (!tmp)
76529 - goto fail_nomem;
76530 - *tmp = *mpnt;
76531 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
76532 - pol = mpol_dup(vma_policy(mpnt));
76533 - retval = PTR_ERR(pol);
76534 - if (IS_ERR(pol))
76535 - goto fail_nomem_policy;
76536 - vma_set_policy(tmp, pol);
76537 - tmp->vm_mm = mm;
76538 - if (anon_vma_fork(tmp, mpnt))
76539 - goto fail_nomem_anon_vma_fork;
76540 - tmp->vm_flags &= ~VM_LOCKED;
76541 - tmp->vm_next = tmp->vm_prev = NULL;
76542 - file = tmp->vm_file;
76543 - if (file) {
76544 - struct inode *inode = file_inode(file);
76545 - struct address_space *mapping = file->f_mapping;
76546 -
76547 - get_file(file);
76548 - if (tmp->vm_flags & VM_DENYWRITE)
76549 - atomic_dec(&inode->i_writecount);
76550 - mutex_lock(&mapping->i_mmap_mutex);
76551 - if (tmp->vm_flags & VM_SHARED)
76552 - mapping->i_mmap_writable++;
76553 - flush_dcache_mmap_lock(mapping);
76554 - /* insert tmp into the share list, just after mpnt */
76555 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
76556 - vma_nonlinear_insert(tmp,
76557 - &mapping->i_mmap_nonlinear);
76558 - else
76559 - vma_interval_tree_insert_after(tmp, mpnt,
76560 - &mapping->i_mmap);
76561 - flush_dcache_mmap_unlock(mapping);
76562 - mutex_unlock(&mapping->i_mmap_mutex);
76563 + tmp = dup_vma(mm, oldmm, mpnt);
76564 + if (!tmp) {
76565 + retval = -ENOMEM;
76566 + goto out;
76567 }
76568
76569 /*
76570 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
76571 if (retval)
76572 goto out;
76573 }
76574 +
76575 +#ifdef CONFIG_PAX_SEGMEXEC
76576 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
76577 + struct vm_area_struct *mpnt_m;
76578 +
76579 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
76580 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
76581 +
76582 + if (!mpnt->vm_mirror)
76583 + continue;
76584 +
76585 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
76586 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
76587 + mpnt->vm_mirror = mpnt_m;
76588 + } else {
76589 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
76590 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
76591 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
76592 + mpnt->vm_mirror->vm_mirror = mpnt;
76593 + }
76594 + }
76595 + BUG_ON(mpnt_m);
76596 + }
76597 +#endif
76598 +
76599 /* a new mm has just been created */
76600 arch_dup_mmap(oldmm, mm);
76601 retval = 0;
76602 @@ -473,14 +524,6 @@ out:
76603 up_write(&oldmm->mmap_sem);
76604 uprobe_end_dup_mmap();
76605 return retval;
76606 -fail_nomem_anon_vma_fork:
76607 - mpol_put(pol);
76608 -fail_nomem_policy:
76609 - kmem_cache_free(vm_area_cachep, tmp);
76610 -fail_nomem:
76611 - retval = -ENOMEM;
76612 - vm_unacct_memory(charge);
76613 - goto out;
76614 }
76615
76616 static inline int mm_alloc_pgd(struct mm_struct *mm)
76617 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
76618 return ERR_PTR(err);
76619
76620 mm = get_task_mm(task);
76621 - if (mm && mm != current->mm &&
76622 - !ptrace_may_access(task, mode)) {
76623 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
76624 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
76625 mmput(mm);
76626 mm = ERR_PTR(-EACCES);
76627 }
76628 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
76629 spin_unlock(&fs->lock);
76630 return -EAGAIN;
76631 }
76632 - fs->users++;
76633 + atomic_inc(&fs->users);
76634 spin_unlock(&fs->lock);
76635 return 0;
76636 }
76637 tsk->fs = copy_fs_struct(fs);
76638 if (!tsk->fs)
76639 return -ENOMEM;
76640 + /* Carry through gr_chroot_dentry and is_chrooted instead
76641 + of recomputing it here. Already copied when the task struct
76642 + is duplicated. This allows pivot_root to not be treated as
76643 + a chroot
76644 + */
76645 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
76646 +
76647 return 0;
76648 }
76649
76650 @@ -1197,10 +1247,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
76651 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
76652 #endif
76653 retval = -EAGAIN;
76654 +
76655 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
76656 +
76657 if (atomic_read(&p->real_cred->user->processes) >=
76658 task_rlimit(p, RLIMIT_NPROC)) {
76659 - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
76660 - p->real_cred->user != INIT_USER)
76661 + if (p->real_cred->user != INIT_USER &&
76662 + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
76663 goto bad_fork_free;
76664 }
76665 current->flags &= ~PF_NPROC_EXCEEDED;
76666 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
76667 goto bad_fork_free_pid;
76668 }
76669
76670 + /* synchronizes with gr_set_acls()
76671 + we need to call this past the point of no return for fork()
76672 + */
76673 + gr_copy_label(p);
76674 +
76675 if (clone_flags & CLONE_THREAD) {
76676 current->signal->nr_threads++;
76677 atomic_inc(&current->signal->live);
76678 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
76679 bad_fork_free:
76680 free_task(p);
76681 fork_out:
76682 + gr_log_forkfail(retval);
76683 +
76684 return ERR_PTR(retval);
76685 }
76686
76687 @@ -1579,6 +1639,23 @@ long do_fork(unsigned long clone_flags,
76688 return -EINVAL;
76689 }
76690
76691 +#ifdef CONFIG_GRKERNSEC
76692 + if (clone_flags & CLONE_NEWUSER) {
76693 + /*
76694 + * This doesn't really inspire confidence:
76695 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
76696 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
76697 + * Increases kernel attack surface in areas developers
76698 + * previously cared little about ("low importance due
76699 + * to requiring "root" capability")
76700 + * To be removed when this code receives *proper* review
76701 + */
76702 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
76703 + !capable(CAP_SETGID))
76704 + return -EPERM;
76705 + }
76706 +#endif
76707 +
76708 /*
76709 * Determine whether and which event to report to ptracer. When
76710 * called from kernel_thread or CLONE_UNTRACED is explicitly
76711 @@ -1613,6 +1690,8 @@ long do_fork(unsigned long clone_flags,
76712 if (clone_flags & CLONE_PARENT_SETTID)
76713 put_user(nr, parent_tidptr);
76714
76715 + gr_handle_brute_check();
76716 +
76717 if (clone_flags & CLONE_VFORK) {
76718 p->vfork_done = &vfork;
76719 init_completion(&vfork);
76720 @@ -1723,7 +1802,7 @@ void __init proc_caches_init(void)
76721 mm_cachep = kmem_cache_create("mm_struct",
76722 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
76723 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
76724 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
76725 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
76726 mmap_init();
76727 nsproxy_cache_init();
76728 }
76729 @@ -1763,7 +1842,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
76730 return 0;
76731
76732 /* don't need lock here; in the worst case we'll do useless copy */
76733 - if (fs->users == 1)
76734 + if (atomic_read(&fs->users) == 1)
76735 return 0;
76736
76737 *new_fsp = copy_fs_struct(fs);
76738 @@ -1875,7 +1954,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
76739 fs = current->fs;
76740 spin_lock(&fs->lock);
76741 current->fs = new_fs;
76742 - if (--fs->users)
76743 + gr_set_chroot_entries(current, &current->fs->root);
76744 + if (atomic_dec_return(&fs->users))
76745 new_fs = NULL;
76746 else
76747 new_fs = fs;
76748 diff --git a/kernel/futex.c b/kernel/futex.c
76749 index 49dacfb..5c6b450 100644
76750 --- a/kernel/futex.c
76751 +++ b/kernel/futex.c
76752 @@ -54,6 +54,7 @@
76753 #include <linux/mount.h>
76754 #include <linux/pagemap.h>
76755 #include <linux/syscalls.h>
76756 +#include <linux/ptrace.h>
76757 #include <linux/signal.h>
76758 #include <linux/export.h>
76759 #include <linux/magic.h>
76760 @@ -242,6 +243,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
76761 struct page *page, *page_head;
76762 int err, ro = 0;
76763
76764 +#ifdef CONFIG_PAX_SEGMEXEC
76765 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
76766 + return -EFAULT;
76767 +#endif
76768 +
76769 /*
76770 * The futex address must be "naturally" aligned.
76771 */
76772 @@ -2733,6 +2739,7 @@ static int __init futex_init(void)
76773 {
76774 u32 curval;
76775 int i;
76776 + mm_segment_t oldfs;
76777
76778 /*
76779 * This will fail and we want it. Some arch implementations do
76780 @@ -2744,8 +2751,11 @@ static int __init futex_init(void)
76781 * implementation, the non-functional ones will return
76782 * -ENOSYS.
76783 */
76784 + oldfs = get_fs();
76785 + set_fs(USER_DS);
76786 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
76787 futex_cmpxchg_enabled = 1;
76788 + set_fs(oldfs);
76789
76790 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
76791 plist_head_init(&futex_queues[i].chain);
76792 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
76793 index f9f44fd..29885e4 100644
76794 --- a/kernel/futex_compat.c
76795 +++ b/kernel/futex_compat.c
76796 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
76797 return 0;
76798 }
76799
76800 -static void __user *futex_uaddr(struct robust_list __user *entry,
76801 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
76802 compat_long_t futex_offset)
76803 {
76804 compat_uptr_t base = ptr_to_compat(entry);
76805 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
76806 index 9b22d03..6295b62 100644
76807 --- a/kernel/gcov/base.c
76808 +++ b/kernel/gcov/base.c
76809 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
76810 }
76811
76812 #ifdef CONFIG_MODULES
76813 -static inline int within(void *addr, void *start, unsigned long size)
76814 -{
76815 - return ((addr >= start) && (addr < start + size));
76816 -}
76817 -
76818 /* Update list and generate events when modules are unloaded. */
76819 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76820 void *data)
76821 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76822 prev = NULL;
76823 /* Remove entries located in module from linked list. */
76824 for (info = gcov_info_head; info; info = info->next) {
76825 - if (within(info, mod->module_core, mod->core_size)) {
76826 + if (within_module_core_rw((unsigned long)info, mod)) {
76827 if (prev)
76828 prev->next = info->next;
76829 else
76830 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
76831 index 2288fbd..0f3941f 100644
76832 --- a/kernel/hrtimer.c
76833 +++ b/kernel/hrtimer.c
76834 @@ -1435,7 +1435,7 @@ void hrtimer_peek_ahead_timers(void)
76835 local_irq_restore(flags);
76836 }
76837
76838 -static void run_hrtimer_softirq(struct softirq_action *h)
76839 +static void run_hrtimer_softirq(void)
76840 {
76841 hrtimer_peek_ahead_timers();
76842 }
76843 @@ -1770,7 +1770,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
76844 return NOTIFY_OK;
76845 }
76846
76847 -static struct notifier_block __cpuinitdata hrtimers_nb = {
76848 +static struct notifier_block hrtimers_nb = {
76849 .notifier_call = hrtimer_cpu_notify,
76850 };
76851
76852 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
76853 index 55fcce6..0e4cf34 100644
76854 --- a/kernel/irq_work.c
76855 +++ b/kernel/irq_work.c
76856 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
76857 return NOTIFY_OK;
76858 }
76859
76860 -static struct notifier_block cpu_notify;
76861 +static struct notifier_block cpu_notify = {
76862 + .notifier_call = irq_work_cpu_notify,
76863 + .priority = 0,
76864 +};
76865
76866 static __init int irq_work_init_cpu_notifier(void)
76867 {
76868 - cpu_notify.notifier_call = irq_work_cpu_notify;
76869 - cpu_notify.priority = 0;
76870 register_cpu_notifier(&cpu_notify);
76871 return 0;
76872 }
76873 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
76874 index 60f48fa..7f3a770 100644
76875 --- a/kernel/jump_label.c
76876 +++ b/kernel/jump_label.c
76877 @@ -13,6 +13,7 @@
76878 #include <linux/sort.h>
76879 #include <linux/err.h>
76880 #include <linux/static_key.h>
76881 +#include <linux/mm.h>
76882
76883 #ifdef HAVE_JUMP_LABEL
76884
76885 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
76886
76887 size = (((unsigned long)stop - (unsigned long)start)
76888 / sizeof(struct jump_entry));
76889 + pax_open_kernel();
76890 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
76891 + pax_close_kernel();
76892 }
76893
76894 static void jump_label_update(struct static_key *key, int enable);
76895 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
76896 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
76897 struct jump_entry *iter;
76898
76899 + pax_open_kernel();
76900 for (iter = iter_start; iter < iter_stop; iter++) {
76901 if (within_module_init(iter->code, mod))
76902 iter->code = 0;
76903 }
76904 + pax_close_kernel();
76905 }
76906
76907 static int
76908 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
76909 index 3127ad5..159d880 100644
76910 --- a/kernel/kallsyms.c
76911 +++ b/kernel/kallsyms.c
76912 @@ -11,6 +11,9 @@
76913 * Changed the compression method from stem compression to "table lookup"
76914 * compression (see scripts/kallsyms.c for a more complete description)
76915 */
76916 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76917 +#define __INCLUDED_BY_HIDESYM 1
76918 +#endif
76919 #include <linux/kallsyms.h>
76920 #include <linux/module.h>
76921 #include <linux/init.h>
76922 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
76923
76924 static inline int is_kernel_inittext(unsigned long addr)
76925 {
76926 + if (system_state != SYSTEM_BOOTING)
76927 + return 0;
76928 +
76929 if (addr >= (unsigned long)_sinittext
76930 && addr <= (unsigned long)_einittext)
76931 return 1;
76932 return 0;
76933 }
76934
76935 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76936 +#ifdef CONFIG_MODULES
76937 +static inline int is_module_text(unsigned long addr)
76938 +{
76939 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
76940 + return 1;
76941 +
76942 + addr = ktla_ktva(addr);
76943 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
76944 +}
76945 +#else
76946 +static inline int is_module_text(unsigned long addr)
76947 +{
76948 + return 0;
76949 +}
76950 +#endif
76951 +#endif
76952 +
76953 static inline int is_kernel_text(unsigned long addr)
76954 {
76955 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
76956 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
76957
76958 static inline int is_kernel(unsigned long addr)
76959 {
76960 +
76961 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76962 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
76963 + return 1;
76964 +
76965 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
76966 +#else
76967 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
76968 +#endif
76969 +
76970 return 1;
76971 return in_gate_area_no_mm(addr);
76972 }
76973
76974 static int is_ksym_addr(unsigned long addr)
76975 {
76976 +
76977 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76978 + if (is_module_text(addr))
76979 + return 0;
76980 +#endif
76981 +
76982 if (all_var)
76983 return is_kernel(addr);
76984
76985 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
76986
76987 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
76988 {
76989 - iter->name[0] = '\0';
76990 iter->nameoff = get_symbol_offset(new_pos);
76991 iter->pos = new_pos;
76992 }
76993 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
76994 {
76995 struct kallsym_iter *iter = m->private;
76996
76997 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76998 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
76999 + return 0;
77000 +#endif
77001 +
77002 /* Some debugging symbols have no name. Ignore them. */
77003 if (!iter->name[0])
77004 return 0;
77005 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
77006 */
77007 type = iter->exported ? toupper(iter->type) :
77008 tolower(iter->type);
77009 +
77010 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
77011 type, iter->name, iter->module_name);
77012 } else
77013 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
77014 struct kallsym_iter *iter;
77015 int ret;
77016
77017 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
77018 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
77019 if (!iter)
77020 return -ENOMEM;
77021 reset_iter(iter, 0);
77022 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
77023 index e30ac0f..3528cac 100644
77024 --- a/kernel/kcmp.c
77025 +++ b/kernel/kcmp.c
77026 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
77027 struct task_struct *task1, *task2;
77028 int ret;
77029
77030 +#ifdef CONFIG_GRKERNSEC
77031 + return -ENOSYS;
77032 +#endif
77033 +
77034 rcu_read_lock();
77035
77036 /*
77037 diff --git a/kernel/kexec.c b/kernel/kexec.c
77038 index 59f7b55..4022f65 100644
77039 --- a/kernel/kexec.c
77040 +++ b/kernel/kexec.c
77041 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
77042 unsigned long flags)
77043 {
77044 struct compat_kexec_segment in;
77045 - struct kexec_segment out, __user *ksegments;
77046 + struct kexec_segment out;
77047 + struct kexec_segment __user *ksegments;
77048 unsigned long i, result;
77049
77050 /* Don't allow clients that don't understand the native
77051 diff --git a/kernel/kmod.c b/kernel/kmod.c
77052 index 8241906..d625f2c 100644
77053 --- a/kernel/kmod.c
77054 +++ b/kernel/kmod.c
77055 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
77056 kfree(info->argv);
77057 }
77058
77059 -static int call_modprobe(char *module_name, int wait)
77060 +static int call_modprobe(char *module_name, char *module_param, int wait)
77061 {
77062 struct subprocess_info *info;
77063 static char *envp[] = {
77064 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
77065 NULL
77066 };
77067
77068 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
77069 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
77070 if (!argv)
77071 goto out;
77072
77073 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
77074 argv[1] = "-q";
77075 argv[2] = "--";
77076 argv[3] = module_name; /* check free_modprobe_argv() */
77077 - argv[4] = NULL;
77078 + argv[4] = module_param;
77079 + argv[5] = NULL;
77080
77081 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
77082 NULL, free_modprobe_argv, NULL);
77083 @@ -129,9 +130,8 @@ out:
77084 * If module auto-loading support is disabled then this function
77085 * becomes a no-operation.
77086 */
77087 -int __request_module(bool wait, const char *fmt, ...)
77088 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
77089 {
77090 - va_list args;
77091 char module_name[MODULE_NAME_LEN];
77092 unsigned int max_modprobes;
77093 int ret;
77094 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
77095 */
77096 WARN_ON_ONCE(wait && current_is_async());
77097
77098 - va_start(args, fmt);
77099 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
77100 - va_end(args);
77101 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
77102 if (ret >= MODULE_NAME_LEN)
77103 return -ENAMETOOLONG;
77104
77105 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
77106 if (ret)
77107 return ret;
77108
77109 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77110 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
77111 + /* hack to workaround consolekit/udisks stupidity */
77112 + read_lock(&tasklist_lock);
77113 + if (!strcmp(current->comm, "mount") &&
77114 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
77115 + read_unlock(&tasklist_lock);
77116 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
77117 + return -EPERM;
77118 + }
77119 + read_unlock(&tasklist_lock);
77120 + }
77121 +#endif
77122 +
77123 /* If modprobe needs a service that is in a module, we get a recursive
77124 * loop. Limit the number of running kmod threads to max_threads/2 or
77125 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
77126 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
77127
77128 trace_module_request(module_name, wait, _RET_IP_);
77129
77130 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
77131 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
77132
77133 atomic_dec(&kmod_concurrent);
77134 return ret;
77135 }
77136 +
77137 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
77138 +{
77139 + va_list args;
77140 + int ret;
77141 +
77142 + va_start(args, fmt);
77143 + ret = ____request_module(wait, module_param, fmt, args);
77144 + va_end(args);
77145 +
77146 + return ret;
77147 +}
77148 +
77149 +int __request_module(bool wait, const char *fmt, ...)
77150 +{
77151 + va_list args;
77152 + int ret;
77153 +
77154 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77155 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
77156 + char module_param[MODULE_NAME_LEN];
77157 +
77158 + memset(module_param, 0, sizeof(module_param));
77159 +
77160 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
77161 +
77162 + va_start(args, fmt);
77163 + ret = ____request_module(wait, module_param, fmt, args);
77164 + va_end(args);
77165 +
77166 + return ret;
77167 + }
77168 +#endif
77169 +
77170 + va_start(args, fmt);
77171 + ret = ____request_module(wait, NULL, fmt, args);
77172 + va_end(args);
77173 +
77174 + return ret;
77175 +}
77176 +
77177 EXPORT_SYMBOL(__request_module);
77178 #endif /* CONFIG_MODULES */
77179
77180 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
77181 *
77182 * Thus the __user pointer cast is valid here.
77183 */
77184 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
77185 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
77186
77187 /*
77188 * If ret is 0, either ____call_usermodehelper failed and the
77189 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
77190 static int proc_cap_handler(struct ctl_table *table, int write,
77191 void __user *buffer, size_t *lenp, loff_t *ppos)
77192 {
77193 - struct ctl_table t;
77194 + ctl_table_no_const t;
77195 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
77196 kernel_cap_t new_cap;
77197 int err, i;
77198 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
77199 index bddf3b2..07b90dd 100644
77200 --- a/kernel/kprobes.c
77201 +++ b/kernel/kprobes.c
77202 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
77203 * kernel image and loaded module images reside. This is required
77204 * so x86_64 can correctly handle the %rip-relative fixups.
77205 */
77206 - kip->insns = module_alloc(PAGE_SIZE);
77207 + kip->insns = module_alloc_exec(PAGE_SIZE);
77208 if (!kip->insns) {
77209 kfree(kip);
77210 return NULL;
77211 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
77212 */
77213 if (!list_is_singular(&kip->list)) {
77214 list_del(&kip->list);
77215 - module_free(NULL, kip->insns);
77216 + module_free_exec(NULL, kip->insns);
77217 kfree(kip);
77218 }
77219 return 1;
77220 @@ -2083,7 +2083,7 @@ static int __init init_kprobes(void)
77221 {
77222 int i, err = 0;
77223 unsigned long offset = 0, size = 0;
77224 - char *modname, namebuf[128];
77225 + char *modname, namebuf[KSYM_NAME_LEN];
77226 const char *symbol_name;
77227 void *addr;
77228 struct kprobe_blackpoint *kb;
77229 @@ -2168,11 +2168,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
77230 kprobe_type = "k";
77231
77232 if (sym)
77233 - seq_printf(pi, "%p %s %s+0x%x %s ",
77234 + seq_printf(pi, "%pK %s %s+0x%x %s ",
77235 p->addr, kprobe_type, sym, offset,
77236 (modname ? modname : " "));
77237 else
77238 - seq_printf(pi, "%p %s %p ",
77239 + seq_printf(pi, "%pK %s %pK ",
77240 p->addr, kprobe_type, p->addr);
77241
77242 if (!pp)
77243 @@ -2209,7 +2209,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
77244 const char *sym = NULL;
77245 unsigned int i = *(loff_t *) v;
77246 unsigned long offset = 0;
77247 - char *modname, namebuf[128];
77248 + char *modname, namebuf[KSYM_NAME_LEN];
77249
77250 head = &kprobe_table[i];
77251 preempt_disable();
77252 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
77253 index 6ada93c..dce7d5d 100644
77254 --- a/kernel/ksysfs.c
77255 +++ b/kernel/ksysfs.c
77256 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
77257 {
77258 if (count+1 > UEVENT_HELPER_PATH_LEN)
77259 return -ENOENT;
77260 + if (!capable(CAP_SYS_ADMIN))
77261 + return -EPERM;
77262 memcpy(uevent_helper, buf, count);
77263 uevent_helper[count] = '\0';
77264 if (count && uevent_helper[count-1] == '\n')
77265 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
77266 return count;
77267 }
77268
77269 -static struct bin_attribute notes_attr = {
77270 +static bin_attribute_no_const notes_attr __read_only = {
77271 .attr = {
77272 .name = "notes",
77273 .mode = S_IRUGO,
77274 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
77275 index 1f3186b..bb7dbc6 100644
77276 --- a/kernel/lockdep.c
77277 +++ b/kernel/lockdep.c
77278 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
77279 end = (unsigned long) &_end,
77280 addr = (unsigned long) obj;
77281
77282 +#ifdef CONFIG_PAX_KERNEXEC
77283 + start = ktla_ktva(start);
77284 +#endif
77285 +
77286 /*
77287 * static variable?
77288 */
77289 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
77290 if (!static_obj(lock->key)) {
77291 debug_locks_off();
77292 printk("INFO: trying to register non-static key.\n");
77293 + printk("lock:%pS key:%pS.\n", lock, lock->key);
77294 printk("the code is fine but needs lockdep annotation.\n");
77295 printk("turning off the locking correctness validator.\n");
77296 dump_stack();
77297 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
77298 if (!class)
77299 return 0;
77300 }
77301 - atomic_inc((atomic_t *)&class->ops);
77302 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
77303 if (very_verbose(class)) {
77304 printk("\nacquire class [%p] %s", class->key, class->name);
77305 if (class->name_version > 1)
77306 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
77307 index b2c71c5..7b88d63 100644
77308 --- a/kernel/lockdep_proc.c
77309 +++ b/kernel/lockdep_proc.c
77310 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
77311 return 0;
77312 }
77313
77314 - seq_printf(m, "%p", class->key);
77315 + seq_printf(m, "%pK", class->key);
77316 #ifdef CONFIG_DEBUG_LOCKDEP
77317 seq_printf(m, " OPS:%8ld", class->ops);
77318 #endif
77319 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
77320
77321 list_for_each_entry(entry, &class->locks_after, entry) {
77322 if (entry->distance == 1) {
77323 - seq_printf(m, " -> [%p] ", entry->class->key);
77324 + seq_printf(m, " -> [%pK] ", entry->class->key);
77325 print_name(m, entry->class);
77326 seq_puts(m, "\n");
77327 }
77328 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
77329 if (!class->key)
77330 continue;
77331
77332 - seq_printf(m, "[%p] ", class->key);
77333 + seq_printf(m, "[%pK] ", class->key);
77334 print_name(m, class);
77335 seq_puts(m, "\n");
77336 }
77337 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
77338 if (!i)
77339 seq_line(m, '-', 40-namelen, namelen);
77340
77341 - snprintf(ip, sizeof(ip), "[<%p>]",
77342 + snprintf(ip, sizeof(ip), "[<%pK>]",
77343 (void *)class->contention_point[i]);
77344 seq_printf(m, "%40s %14lu %29s %pS\n",
77345 name, stats->contention_point[i],
77346 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
77347 if (!i)
77348 seq_line(m, '-', 40-namelen, namelen);
77349
77350 - snprintf(ip, sizeof(ip), "[<%p>]",
77351 + snprintf(ip, sizeof(ip), "[<%pK>]",
77352 (void *)class->contending_point[i]);
77353 seq_printf(m, "%40s %14lu %29s %pS\n",
77354 name, stats->contending_point[i],
77355 diff --git a/kernel/module.c b/kernel/module.c
77356 index fa53db8..6f17200 100644
77357 --- a/kernel/module.c
77358 +++ b/kernel/module.c
77359 @@ -61,6 +61,7 @@
77360 #include <linux/pfn.h>
77361 #include <linux/bsearch.h>
77362 #include <linux/fips.h>
77363 +#include <linux/grsecurity.h>
77364 #include <uapi/linux/module.h>
77365 #include "module-internal.h"
77366
77367 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
77368
77369 /* Bounds of module allocation, for speeding __module_address.
77370 * Protected by module_mutex. */
77371 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
77372 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
77373 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
77374
77375 int register_module_notifier(struct notifier_block * nb)
77376 {
77377 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
77378 return true;
77379
77380 list_for_each_entry_rcu(mod, &modules, list) {
77381 - struct symsearch arr[] = {
77382 + struct symsearch modarr[] = {
77383 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
77384 NOT_GPL_ONLY, false },
77385 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
77386 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
77387 if (mod->state == MODULE_STATE_UNFORMED)
77388 continue;
77389
77390 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
77391 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
77392 return true;
77393 }
77394 return false;
77395 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
77396 static int percpu_modalloc(struct module *mod,
77397 unsigned long size, unsigned long align)
77398 {
77399 - if (align > PAGE_SIZE) {
77400 + if (align-1 >= PAGE_SIZE) {
77401 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
77402 mod->name, align, PAGE_SIZE);
77403 align = PAGE_SIZE;
77404 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
77405 static ssize_t show_coresize(struct module_attribute *mattr,
77406 struct module_kobject *mk, char *buffer)
77407 {
77408 - return sprintf(buffer, "%u\n", mk->mod->core_size);
77409 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
77410 }
77411
77412 static struct module_attribute modinfo_coresize =
77413 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
77414 static ssize_t show_initsize(struct module_attribute *mattr,
77415 struct module_kobject *mk, char *buffer)
77416 {
77417 - return sprintf(buffer, "%u\n", mk->mod->init_size);
77418 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
77419 }
77420
77421 static struct module_attribute modinfo_initsize =
77422 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
77423 */
77424 #ifdef CONFIG_SYSFS
77425
77426 -#ifdef CONFIG_KALLSYMS
77427 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
77428 static inline bool sect_empty(const Elf_Shdr *sect)
77429 {
77430 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
77431 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
77432 {
77433 unsigned int notes, loaded, i;
77434 struct module_notes_attrs *notes_attrs;
77435 - struct bin_attribute *nattr;
77436 + bin_attribute_no_const *nattr;
77437
77438 /* failed to create section attributes, so can't create notes */
77439 if (!mod->sect_attrs)
77440 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
77441 static int module_add_modinfo_attrs(struct module *mod)
77442 {
77443 struct module_attribute *attr;
77444 - struct module_attribute *temp_attr;
77445 + module_attribute_no_const *temp_attr;
77446 int error = 0;
77447 int i;
77448
77449 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
77450
77451 static void unset_module_core_ro_nx(struct module *mod)
77452 {
77453 - set_page_attributes(mod->module_core + mod->core_text_size,
77454 - mod->module_core + mod->core_size,
77455 + set_page_attributes(mod->module_core_rw,
77456 + mod->module_core_rw + mod->core_size_rw,
77457 set_memory_x);
77458 - set_page_attributes(mod->module_core,
77459 - mod->module_core + mod->core_ro_size,
77460 + set_page_attributes(mod->module_core_rx,
77461 + mod->module_core_rx + mod->core_size_rx,
77462 set_memory_rw);
77463 }
77464
77465 static void unset_module_init_ro_nx(struct module *mod)
77466 {
77467 - set_page_attributes(mod->module_init + mod->init_text_size,
77468 - mod->module_init + mod->init_size,
77469 + set_page_attributes(mod->module_init_rw,
77470 + mod->module_init_rw + mod->init_size_rw,
77471 set_memory_x);
77472 - set_page_attributes(mod->module_init,
77473 - mod->module_init + mod->init_ro_size,
77474 + set_page_attributes(mod->module_init_rx,
77475 + mod->module_init_rx + mod->init_size_rx,
77476 set_memory_rw);
77477 }
77478
77479 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
77480 list_for_each_entry_rcu(mod, &modules, list) {
77481 if (mod->state == MODULE_STATE_UNFORMED)
77482 continue;
77483 - if ((mod->module_core) && (mod->core_text_size)) {
77484 - set_page_attributes(mod->module_core,
77485 - mod->module_core + mod->core_text_size,
77486 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
77487 + set_page_attributes(mod->module_core_rx,
77488 + mod->module_core_rx + mod->core_size_rx,
77489 set_memory_rw);
77490 }
77491 - if ((mod->module_init) && (mod->init_text_size)) {
77492 - set_page_attributes(mod->module_init,
77493 - mod->module_init + mod->init_text_size,
77494 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
77495 + set_page_attributes(mod->module_init_rx,
77496 + mod->module_init_rx + mod->init_size_rx,
77497 set_memory_rw);
77498 }
77499 }
77500 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
77501 list_for_each_entry_rcu(mod, &modules, list) {
77502 if (mod->state == MODULE_STATE_UNFORMED)
77503 continue;
77504 - if ((mod->module_core) && (mod->core_text_size)) {
77505 - set_page_attributes(mod->module_core,
77506 - mod->module_core + mod->core_text_size,
77507 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
77508 + set_page_attributes(mod->module_core_rx,
77509 + mod->module_core_rx + mod->core_size_rx,
77510 set_memory_ro);
77511 }
77512 - if ((mod->module_init) && (mod->init_text_size)) {
77513 - set_page_attributes(mod->module_init,
77514 - mod->module_init + mod->init_text_size,
77515 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
77516 + set_page_attributes(mod->module_init_rx,
77517 + mod->module_init_rx + mod->init_size_rx,
77518 set_memory_ro);
77519 }
77520 }
77521 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
77522
77523 /* This may be NULL, but that's OK */
77524 unset_module_init_ro_nx(mod);
77525 - module_free(mod, mod->module_init);
77526 + module_free(mod, mod->module_init_rw);
77527 + module_free_exec(mod, mod->module_init_rx);
77528 kfree(mod->args);
77529 percpu_modfree(mod);
77530
77531 /* Free lock-classes: */
77532 - lockdep_free_key_range(mod->module_core, mod->core_size);
77533 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
77534 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
77535
77536 /* Finally, free the core (containing the module structure) */
77537 unset_module_core_ro_nx(mod);
77538 - module_free(mod, mod->module_core);
77539 + module_free_exec(mod, mod->module_core_rx);
77540 + module_free(mod, mod->module_core_rw);
77541
77542 #ifdef CONFIG_MPU
77543 update_protections(current->mm);
77544 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
77545 int ret = 0;
77546 const struct kernel_symbol *ksym;
77547
77548 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77549 + int is_fs_load = 0;
77550 + int register_filesystem_found = 0;
77551 + char *p;
77552 +
77553 + p = strstr(mod->args, "grsec_modharden_fs");
77554 + if (p) {
77555 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
77556 + /* copy \0 as well */
77557 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
77558 + is_fs_load = 1;
77559 + }
77560 +#endif
77561 +
77562 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
77563 const char *name = info->strtab + sym[i].st_name;
77564
77565 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77566 + /* it's a real shame this will never get ripped and copied
77567 + upstream! ;(
77568 + */
77569 + if (is_fs_load && !strcmp(name, "register_filesystem"))
77570 + register_filesystem_found = 1;
77571 +#endif
77572 +
77573 switch (sym[i].st_shndx) {
77574 case SHN_COMMON:
77575 /* We compiled with -fno-common. These are not
77576 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
77577 ksym = resolve_symbol_wait(mod, info, name);
77578 /* Ok if resolved. */
77579 if (ksym && !IS_ERR(ksym)) {
77580 + pax_open_kernel();
77581 sym[i].st_value = ksym->value;
77582 + pax_close_kernel();
77583 break;
77584 }
77585
77586 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
77587 secbase = (unsigned long)mod_percpu(mod);
77588 else
77589 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
77590 + pax_open_kernel();
77591 sym[i].st_value += secbase;
77592 + pax_close_kernel();
77593 break;
77594 }
77595 }
77596
77597 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77598 + if (is_fs_load && !register_filesystem_found) {
77599 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
77600 + ret = -EPERM;
77601 + }
77602 +#endif
77603 +
77604 return ret;
77605 }
77606
77607 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
77608 || s->sh_entsize != ~0UL
77609 || strstarts(sname, ".init"))
77610 continue;
77611 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
77612 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
77613 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
77614 + else
77615 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
77616 pr_debug("\t%s\n", sname);
77617 }
77618 - switch (m) {
77619 - case 0: /* executable */
77620 - mod->core_size = debug_align(mod->core_size);
77621 - mod->core_text_size = mod->core_size;
77622 - break;
77623 - case 1: /* RO: text and ro-data */
77624 - mod->core_size = debug_align(mod->core_size);
77625 - mod->core_ro_size = mod->core_size;
77626 - break;
77627 - case 3: /* whole core */
77628 - mod->core_size = debug_align(mod->core_size);
77629 - break;
77630 - }
77631 }
77632
77633 pr_debug("Init section allocation order:\n");
77634 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
77635 || s->sh_entsize != ~0UL
77636 || !strstarts(sname, ".init"))
77637 continue;
77638 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
77639 - | INIT_OFFSET_MASK);
77640 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
77641 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
77642 + else
77643 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
77644 + s->sh_entsize |= INIT_OFFSET_MASK;
77645 pr_debug("\t%s\n", sname);
77646 }
77647 - switch (m) {
77648 - case 0: /* executable */
77649 - mod->init_size = debug_align(mod->init_size);
77650 - mod->init_text_size = mod->init_size;
77651 - break;
77652 - case 1: /* RO: text and ro-data */
77653 - mod->init_size = debug_align(mod->init_size);
77654 - mod->init_ro_size = mod->init_size;
77655 - break;
77656 - case 3: /* whole init */
77657 - mod->init_size = debug_align(mod->init_size);
77658 - break;
77659 - }
77660 }
77661 }
77662
77663 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
77664
77665 /* Put symbol section at end of init part of module. */
77666 symsect->sh_flags |= SHF_ALLOC;
77667 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
77668 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
77669 info->index.sym) | INIT_OFFSET_MASK;
77670 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
77671
77672 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
77673 }
77674
77675 /* Append room for core symbols at end of core part. */
77676 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
77677 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
77678 - mod->core_size += strtab_size;
77679 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
77680 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
77681 + mod->core_size_rx += strtab_size;
77682
77683 /* Put string table section at end of init part of module. */
77684 strsect->sh_flags |= SHF_ALLOC;
77685 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
77686 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
77687 info->index.str) | INIT_OFFSET_MASK;
77688 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
77689 }
77690 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
77691 /* Make sure we get permanent strtab: don't use info->strtab. */
77692 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
77693
77694 + pax_open_kernel();
77695 +
77696 /* Set types up while we still have access to sections. */
77697 for (i = 0; i < mod->num_symtab; i++)
77698 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
77699
77700 - mod->core_symtab = dst = mod->module_core + info->symoffs;
77701 - mod->core_strtab = s = mod->module_core + info->stroffs;
77702 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
77703 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
77704 src = mod->symtab;
77705 for (ndst = i = 0; i < mod->num_symtab; i++) {
77706 if (i == 0 ||
77707 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
77708 }
77709 }
77710 mod->core_num_syms = ndst;
77711 +
77712 + pax_close_kernel();
77713 }
77714 #else
77715 static inline void layout_symtab(struct module *mod, struct load_info *info)
77716 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
77717 return vmalloc_exec(size);
77718 }
77719
77720 -static void *module_alloc_update_bounds(unsigned long size)
77721 +static void *module_alloc_update_bounds_rw(unsigned long size)
77722 {
77723 void *ret = module_alloc(size);
77724
77725 if (ret) {
77726 mutex_lock(&module_mutex);
77727 /* Update module bounds. */
77728 - if ((unsigned long)ret < module_addr_min)
77729 - module_addr_min = (unsigned long)ret;
77730 - if ((unsigned long)ret + size > module_addr_max)
77731 - module_addr_max = (unsigned long)ret + size;
77732 + if ((unsigned long)ret < module_addr_min_rw)
77733 + module_addr_min_rw = (unsigned long)ret;
77734 + if ((unsigned long)ret + size > module_addr_max_rw)
77735 + module_addr_max_rw = (unsigned long)ret + size;
77736 + mutex_unlock(&module_mutex);
77737 + }
77738 + return ret;
77739 +}
77740 +
77741 +static void *module_alloc_update_bounds_rx(unsigned long size)
77742 +{
77743 + void *ret = module_alloc_exec(size);
77744 +
77745 + if (ret) {
77746 + mutex_lock(&module_mutex);
77747 + /* Update module bounds. */
77748 + if ((unsigned long)ret < module_addr_min_rx)
77749 + module_addr_min_rx = (unsigned long)ret;
77750 + if ((unsigned long)ret + size > module_addr_max_rx)
77751 + module_addr_max_rx = (unsigned long)ret + size;
77752 mutex_unlock(&module_mutex);
77753 }
77754 return ret;
77755 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
77756 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
77757 {
77758 const char *modmagic = get_modinfo(info, "vermagic");
77759 + const char *license = get_modinfo(info, "license");
77760 int err;
77761
77762 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
77763 + if (!license || !license_is_gpl_compatible(license))
77764 + return -ENOEXEC;
77765 +#endif
77766 +
77767 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
77768 modmagic = NULL;
77769
77770 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
77771 }
77772
77773 /* Set up license info based on the info section */
77774 - set_license(mod, get_modinfo(info, "license"));
77775 + set_license(mod, license);
77776
77777 return 0;
77778 }
77779 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
77780 void *ptr;
77781
77782 /* Do the allocs. */
77783 - ptr = module_alloc_update_bounds(mod->core_size);
77784 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
77785 /*
77786 * The pointer to this block is stored in the module structure
77787 * which is inside the block. Just mark it as not being a
77788 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
77789 if (!ptr)
77790 return -ENOMEM;
77791
77792 - memset(ptr, 0, mod->core_size);
77793 - mod->module_core = ptr;
77794 + memset(ptr, 0, mod->core_size_rw);
77795 + mod->module_core_rw = ptr;
77796
77797 - if (mod->init_size) {
77798 - ptr = module_alloc_update_bounds(mod->init_size);
77799 + if (mod->init_size_rw) {
77800 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
77801 /*
77802 * The pointer to this block is stored in the module structure
77803 * which is inside the block. This block doesn't need to be
77804 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
77805 */
77806 kmemleak_ignore(ptr);
77807 if (!ptr) {
77808 - module_free(mod, mod->module_core);
77809 + module_free(mod, mod->module_core_rw);
77810 return -ENOMEM;
77811 }
77812 - memset(ptr, 0, mod->init_size);
77813 - mod->module_init = ptr;
77814 + memset(ptr, 0, mod->init_size_rw);
77815 + mod->module_init_rw = ptr;
77816 } else
77817 - mod->module_init = NULL;
77818 + mod->module_init_rw = NULL;
77819 +
77820 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
77821 + kmemleak_not_leak(ptr);
77822 + if (!ptr) {
77823 + if (mod->module_init_rw)
77824 + module_free(mod, mod->module_init_rw);
77825 + module_free(mod, mod->module_core_rw);
77826 + return -ENOMEM;
77827 + }
77828 +
77829 + pax_open_kernel();
77830 + memset(ptr, 0, mod->core_size_rx);
77831 + pax_close_kernel();
77832 + mod->module_core_rx = ptr;
77833 +
77834 + if (mod->init_size_rx) {
77835 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
77836 + kmemleak_ignore(ptr);
77837 + if (!ptr && mod->init_size_rx) {
77838 + module_free_exec(mod, mod->module_core_rx);
77839 + if (mod->module_init_rw)
77840 + module_free(mod, mod->module_init_rw);
77841 + module_free(mod, mod->module_core_rw);
77842 + return -ENOMEM;
77843 + }
77844 +
77845 + pax_open_kernel();
77846 + memset(ptr, 0, mod->init_size_rx);
77847 + pax_close_kernel();
77848 + mod->module_init_rx = ptr;
77849 + } else
77850 + mod->module_init_rx = NULL;
77851
77852 /* Transfer each section which specifies SHF_ALLOC */
77853 pr_debug("final section addresses:\n");
77854 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
77855 if (!(shdr->sh_flags & SHF_ALLOC))
77856 continue;
77857
77858 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
77859 - dest = mod->module_init
77860 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77861 - else
77862 - dest = mod->module_core + shdr->sh_entsize;
77863 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
77864 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77865 + dest = mod->module_init_rw
77866 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77867 + else
77868 + dest = mod->module_init_rx
77869 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77870 + } else {
77871 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77872 + dest = mod->module_core_rw + shdr->sh_entsize;
77873 + else
77874 + dest = mod->module_core_rx + shdr->sh_entsize;
77875 + }
77876 +
77877 + if (shdr->sh_type != SHT_NOBITS) {
77878 +
77879 +#ifdef CONFIG_PAX_KERNEXEC
77880 +#ifdef CONFIG_X86_64
77881 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
77882 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
77883 +#endif
77884 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
77885 + pax_open_kernel();
77886 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77887 + pax_close_kernel();
77888 + } else
77889 +#endif
77890
77891 - if (shdr->sh_type != SHT_NOBITS)
77892 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77893 + }
77894 /* Update sh_addr to point to copy in image. */
77895 - shdr->sh_addr = (unsigned long)dest;
77896 +
77897 +#ifdef CONFIG_PAX_KERNEXEC
77898 + if (shdr->sh_flags & SHF_EXECINSTR)
77899 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
77900 + else
77901 +#endif
77902 +
77903 + shdr->sh_addr = (unsigned long)dest;
77904 pr_debug("\t0x%lx %s\n",
77905 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
77906 }
77907 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
77908 * Do it before processing of module parameters, so the module
77909 * can provide parameter accessor functions of its own.
77910 */
77911 - if (mod->module_init)
77912 - flush_icache_range((unsigned long)mod->module_init,
77913 - (unsigned long)mod->module_init
77914 - + mod->init_size);
77915 - flush_icache_range((unsigned long)mod->module_core,
77916 - (unsigned long)mod->module_core + mod->core_size);
77917 + if (mod->module_init_rx)
77918 + flush_icache_range((unsigned long)mod->module_init_rx,
77919 + (unsigned long)mod->module_init_rx
77920 + + mod->init_size_rx);
77921 + flush_icache_range((unsigned long)mod->module_core_rx,
77922 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
77923
77924 set_fs(old_fs);
77925 }
77926 @@ -2977,8 +3082,10 @@ static int alloc_module_percpu(struct module *mod, struct load_info *info)
77927 static void module_deallocate(struct module *mod, struct load_info *info)
77928 {
77929 percpu_modfree(mod);
77930 - module_free(mod, mod->module_init);
77931 - module_free(mod, mod->module_core);
77932 + module_free_exec(mod, mod->module_init_rx);
77933 + module_free_exec(mod, mod->module_core_rx);
77934 + module_free(mod, mod->module_init_rw);
77935 + module_free(mod, mod->module_core_rw);
77936 }
77937
77938 int __weak module_finalize(const Elf_Ehdr *hdr,
77939 @@ -2991,7 +3098,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
77940 static int post_relocation(struct module *mod, const struct load_info *info)
77941 {
77942 /* Sort exception table now relocations are done. */
77943 + pax_open_kernel();
77944 sort_extable(mod->extable, mod->extable + mod->num_exentries);
77945 + pax_close_kernel();
77946
77947 /* Copy relocated percpu area over. */
77948 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
77949 @@ -3045,16 +3154,16 @@ static int do_init_module(struct module *mod)
77950 MODULE_STATE_COMING, mod);
77951
77952 /* Set RO and NX regions for core */
77953 - set_section_ro_nx(mod->module_core,
77954 - mod->core_text_size,
77955 - mod->core_ro_size,
77956 - mod->core_size);
77957 + set_section_ro_nx(mod->module_core_rx,
77958 + mod->core_size_rx,
77959 + mod->core_size_rx,
77960 + mod->core_size_rx);
77961
77962 /* Set RO and NX regions for init */
77963 - set_section_ro_nx(mod->module_init,
77964 - mod->init_text_size,
77965 - mod->init_ro_size,
77966 - mod->init_size);
77967 + set_section_ro_nx(mod->module_init_rx,
77968 + mod->init_size_rx,
77969 + mod->init_size_rx,
77970 + mod->init_size_rx);
77971
77972 do_mod_ctors(mod);
77973 /* Start the module */
77974 @@ -3116,11 +3225,12 @@ static int do_init_module(struct module *mod)
77975 mod->strtab = mod->core_strtab;
77976 #endif
77977 unset_module_init_ro_nx(mod);
77978 - module_free(mod, mod->module_init);
77979 - mod->module_init = NULL;
77980 - mod->init_size = 0;
77981 - mod->init_ro_size = 0;
77982 - mod->init_text_size = 0;
77983 + module_free(mod, mod->module_init_rw);
77984 + module_free_exec(mod, mod->module_init_rx);
77985 + mod->module_init_rw = NULL;
77986 + mod->module_init_rx = NULL;
77987 + mod->init_size_rw = 0;
77988 + mod->init_size_rx = 0;
77989 mutex_unlock(&module_mutex);
77990 wake_up_all(&module_wq);
77991
77992 @@ -3252,9 +3362,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
77993 if (err)
77994 goto free_unload;
77995
77996 + /* Now copy in args */
77997 + mod->args = strndup_user(uargs, ~0UL >> 1);
77998 + if (IS_ERR(mod->args)) {
77999 + err = PTR_ERR(mod->args);
78000 + goto free_unload;
78001 + }
78002 +
78003 /* Set up MODINFO_ATTR fields */
78004 setup_modinfo(mod, info);
78005
78006 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
78007 + {
78008 + char *p, *p2;
78009 +
78010 + if (strstr(mod->args, "grsec_modharden_netdev")) {
78011 + 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);
78012 + err = -EPERM;
78013 + goto free_modinfo;
78014 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
78015 + p += sizeof("grsec_modharden_normal") - 1;
78016 + p2 = strstr(p, "_");
78017 + if (p2) {
78018 + *p2 = '\0';
78019 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
78020 + *p2 = '_';
78021 + }
78022 + err = -EPERM;
78023 + goto free_modinfo;
78024 + }
78025 + }
78026 +#endif
78027 +
78028 /* Fix up syms, so that st_value is a pointer to location. */
78029 err = simplify_symbols(mod, info);
78030 if (err < 0)
78031 @@ -3270,13 +3409,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
78032
78033 flush_module_icache(mod);
78034
78035 - /* Now copy in args */
78036 - mod->args = strndup_user(uargs, ~0UL >> 1);
78037 - if (IS_ERR(mod->args)) {
78038 - err = PTR_ERR(mod->args);
78039 - goto free_arch_cleanup;
78040 - }
78041 -
78042 dynamic_debug_setup(info->debug, info->num_debug);
78043
78044 /* Finally it's fully formed, ready to start executing. */
78045 @@ -3311,11 +3443,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
78046 ddebug_cleanup:
78047 dynamic_debug_remove(info->debug);
78048 synchronize_sched();
78049 - kfree(mod->args);
78050 - free_arch_cleanup:
78051 module_arch_cleanup(mod);
78052 free_modinfo:
78053 free_modinfo(mod);
78054 + kfree(mod->args);
78055 free_unload:
78056 module_unload_free(mod);
78057 unlink_mod:
78058 @@ -3398,10 +3529,16 @@ static const char *get_ksymbol(struct module *mod,
78059 unsigned long nextval;
78060
78061 /* At worse, next value is at end of module */
78062 - if (within_module_init(addr, mod))
78063 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
78064 + if (within_module_init_rx(addr, mod))
78065 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
78066 + else if (within_module_init_rw(addr, mod))
78067 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
78068 + else if (within_module_core_rx(addr, mod))
78069 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
78070 + else if (within_module_core_rw(addr, mod))
78071 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
78072 else
78073 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
78074 + return NULL;
78075
78076 /* Scan for closest preceding symbol, and next symbol. (ELF
78077 starts real symbols at 1). */
78078 @@ -3654,7 +3791,7 @@ static int m_show(struct seq_file *m, void *p)
78079 return 0;
78080
78081 seq_printf(m, "%s %u",
78082 - mod->name, mod->init_size + mod->core_size);
78083 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
78084 print_unload_info(m, mod);
78085
78086 /* Informative for users. */
78087 @@ -3663,7 +3800,7 @@ static int m_show(struct seq_file *m, void *p)
78088 mod->state == MODULE_STATE_COMING ? "Loading":
78089 "Live");
78090 /* Used by oprofile and other similar tools. */
78091 - seq_printf(m, " 0x%pK", mod->module_core);
78092 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
78093
78094 /* Taints info */
78095 if (mod->taints)
78096 @@ -3699,7 +3836,17 @@ static const struct file_operations proc_modules_operations = {
78097
78098 static int __init proc_modules_init(void)
78099 {
78100 +#ifndef CONFIG_GRKERNSEC_HIDESYM
78101 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78102 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
78103 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78104 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
78105 +#else
78106 proc_create("modules", 0, NULL, &proc_modules_operations);
78107 +#endif
78108 +#else
78109 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
78110 +#endif
78111 return 0;
78112 }
78113 module_init(proc_modules_init);
78114 @@ -3760,14 +3907,14 @@ struct module *__module_address(unsigned long addr)
78115 {
78116 struct module *mod;
78117
78118 - if (addr < module_addr_min || addr > module_addr_max)
78119 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
78120 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
78121 return NULL;
78122
78123 list_for_each_entry_rcu(mod, &modules, list) {
78124 if (mod->state == MODULE_STATE_UNFORMED)
78125 continue;
78126 - if (within_module_core(addr, mod)
78127 - || within_module_init(addr, mod))
78128 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
78129 return mod;
78130 }
78131 return NULL;
78132 @@ -3802,11 +3949,20 @@ bool is_module_text_address(unsigned long addr)
78133 */
78134 struct module *__module_text_address(unsigned long addr)
78135 {
78136 - struct module *mod = __module_address(addr);
78137 + struct module *mod;
78138 +
78139 +#ifdef CONFIG_X86_32
78140 + addr = ktla_ktva(addr);
78141 +#endif
78142 +
78143 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
78144 + return NULL;
78145 +
78146 + mod = __module_address(addr);
78147 +
78148 if (mod) {
78149 /* Make sure it's within the text section. */
78150 - if (!within(addr, mod->module_init, mod->init_text_size)
78151 - && !within(addr, mod->module_core, mod->core_text_size))
78152 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
78153 mod = NULL;
78154 }
78155 return mod;
78156 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
78157 index 7e3443f..b2a1e6b 100644
78158 --- a/kernel/mutex-debug.c
78159 +++ b/kernel/mutex-debug.c
78160 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
78161 }
78162
78163 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
78164 - struct thread_info *ti)
78165 + struct task_struct *task)
78166 {
78167 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
78168
78169 /* Mark the current thread as blocked on the lock: */
78170 - ti->task->blocked_on = waiter;
78171 + task->blocked_on = waiter;
78172 }
78173
78174 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
78175 - struct thread_info *ti)
78176 + struct task_struct *task)
78177 {
78178 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
78179 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
78180 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
78181 - ti->task->blocked_on = NULL;
78182 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
78183 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
78184 + task->blocked_on = NULL;
78185
78186 list_del_init(&waiter->list);
78187 waiter->task = NULL;
78188 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
78189 index 0799fd3..d06ae3b 100644
78190 --- a/kernel/mutex-debug.h
78191 +++ b/kernel/mutex-debug.h
78192 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
78193 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
78194 extern void debug_mutex_add_waiter(struct mutex *lock,
78195 struct mutex_waiter *waiter,
78196 - struct thread_info *ti);
78197 + struct task_struct *task);
78198 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
78199 - struct thread_info *ti);
78200 + struct task_struct *task);
78201 extern void debug_mutex_unlock(struct mutex *lock);
78202 extern void debug_mutex_init(struct mutex *lock, const char *name,
78203 struct lock_class_key *key);
78204 diff --git a/kernel/mutex.c b/kernel/mutex.c
78205 index ad53a66..f1bf8bc 100644
78206 --- a/kernel/mutex.c
78207 +++ b/kernel/mutex.c
78208 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
78209 node->locked = 1;
78210 return;
78211 }
78212 - ACCESS_ONCE(prev->next) = node;
78213 + ACCESS_ONCE_RW(prev->next) = node;
78214 smp_wmb();
78215 /* Wait until the lock holder passes the lock down */
78216 while (!ACCESS_ONCE(node->locked))
78217 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
78218 while (!(next = ACCESS_ONCE(node->next)))
78219 arch_mutex_cpu_relax();
78220 }
78221 - ACCESS_ONCE(next->locked) = 1;
78222 + ACCESS_ONCE_RW(next->locked) = 1;
78223 smp_wmb();
78224 }
78225
78226 @@ -341,7 +341,7 @@ slowpath:
78227 spin_lock_mutex(&lock->wait_lock, flags);
78228
78229 debug_mutex_lock_common(lock, &waiter);
78230 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
78231 + debug_mutex_add_waiter(lock, &waiter, task);
78232
78233 /* add waiting tasks to the end of the waitqueue (FIFO): */
78234 list_add_tail(&waiter.list, &lock->wait_list);
78235 @@ -371,8 +371,7 @@ slowpath:
78236 * TASK_UNINTERRUPTIBLE case.)
78237 */
78238 if (unlikely(signal_pending_state(state, task))) {
78239 - mutex_remove_waiter(lock, &waiter,
78240 - task_thread_info(task));
78241 + mutex_remove_waiter(lock, &waiter, task);
78242 mutex_release(&lock->dep_map, 1, ip);
78243 spin_unlock_mutex(&lock->wait_lock, flags);
78244
78245 @@ -391,7 +390,7 @@ slowpath:
78246 done:
78247 lock_acquired(&lock->dep_map, ip);
78248 /* got the lock - rejoice! */
78249 - mutex_remove_waiter(lock, &waiter, current_thread_info());
78250 + mutex_remove_waiter(lock, &waiter, task);
78251 mutex_set_owner(lock);
78252
78253 /* set it to 0 if there are no waiters left: */
78254 diff --git a/kernel/notifier.c b/kernel/notifier.c
78255 index 2d5cc4c..d9ea600 100644
78256 --- a/kernel/notifier.c
78257 +++ b/kernel/notifier.c
78258 @@ -5,6 +5,7 @@
78259 #include <linux/rcupdate.h>
78260 #include <linux/vmalloc.h>
78261 #include <linux/reboot.h>
78262 +#include <linux/mm.h>
78263
78264 /*
78265 * Notifier list for kernel code which wants to be called
78266 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
78267 while ((*nl) != NULL) {
78268 if (n->priority > (*nl)->priority)
78269 break;
78270 - nl = &((*nl)->next);
78271 + nl = (struct notifier_block **)&((*nl)->next);
78272 }
78273 - n->next = *nl;
78274 + pax_open_kernel();
78275 + *(const void **)&n->next = *nl;
78276 rcu_assign_pointer(*nl, n);
78277 + pax_close_kernel();
78278 return 0;
78279 }
78280
78281 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
78282 return 0;
78283 if (n->priority > (*nl)->priority)
78284 break;
78285 - nl = &((*nl)->next);
78286 + nl = (struct notifier_block **)&((*nl)->next);
78287 }
78288 - n->next = *nl;
78289 + pax_open_kernel();
78290 + *(const void **)&n->next = *nl;
78291 rcu_assign_pointer(*nl, n);
78292 + pax_close_kernel();
78293 return 0;
78294 }
78295
78296 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
78297 {
78298 while ((*nl) != NULL) {
78299 if ((*nl) == n) {
78300 + pax_open_kernel();
78301 rcu_assign_pointer(*nl, n->next);
78302 + pax_close_kernel();
78303 return 0;
78304 }
78305 - nl = &((*nl)->next);
78306 + nl = (struct notifier_block **)&((*nl)->next);
78307 }
78308 return -ENOENT;
78309 }
78310 diff --git a/kernel/panic.c b/kernel/panic.c
78311 index 167ec09..0dda5f9 100644
78312 --- a/kernel/panic.c
78313 +++ b/kernel/panic.c
78314 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
78315 unsigned taint, struct slowpath_args *args)
78316 {
78317 printk(KERN_WARNING "------------[ cut here ]------------\n");
78318 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
78319 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
78320
78321 if (args)
78322 vprintk(args->fmt, args->args);
78323 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
78324 */
78325 void __stack_chk_fail(void)
78326 {
78327 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
78328 + dump_stack();
78329 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
78330 __builtin_return_address(0));
78331 }
78332 EXPORT_SYMBOL(__stack_chk_fail);
78333 diff --git a/kernel/pid.c b/kernel/pid.c
78334 index 0db3e79..95b9dc2 100644
78335 --- a/kernel/pid.c
78336 +++ b/kernel/pid.c
78337 @@ -33,6 +33,7 @@
78338 #include <linux/rculist.h>
78339 #include <linux/bootmem.h>
78340 #include <linux/hash.h>
78341 +#include <linux/security.h>
78342 #include <linux/pid_namespace.h>
78343 #include <linux/init_task.h>
78344 #include <linux/syscalls.h>
78345 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
78346
78347 int pid_max = PID_MAX_DEFAULT;
78348
78349 -#define RESERVED_PIDS 300
78350 +#define RESERVED_PIDS 500
78351
78352 int pid_max_min = RESERVED_PIDS + 1;
78353 int pid_max_max = PID_MAX_LIMIT;
78354 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
78355 */
78356 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
78357 {
78358 + struct task_struct *task;
78359 +
78360 rcu_lockdep_assert(rcu_read_lock_held(),
78361 "find_task_by_pid_ns() needs rcu_read_lock()"
78362 " protection");
78363 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
78364 +
78365 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
78366 +
78367 + if (gr_pid_is_chrooted(task))
78368 + return NULL;
78369 +
78370 + return task;
78371 }
78372
78373 struct task_struct *find_task_by_vpid(pid_t vnr)
78374 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
78375 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
78376 }
78377
78378 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
78379 +{
78380 + rcu_lockdep_assert(rcu_read_lock_held(),
78381 + "find_task_by_pid_ns() needs rcu_read_lock()"
78382 + " protection");
78383 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
78384 +}
78385 +
78386 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
78387 {
78388 struct pid *pid;
78389 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
78390 index 6917e8e..9909aeb 100644
78391 --- a/kernel/pid_namespace.c
78392 +++ b/kernel/pid_namespace.c
78393 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
78394 void __user *buffer, size_t *lenp, loff_t *ppos)
78395 {
78396 struct pid_namespace *pid_ns = task_active_pid_ns(current);
78397 - struct ctl_table tmp = *table;
78398 + ctl_table_no_const tmp = *table;
78399
78400 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
78401 return -EPERM;
78402 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
78403 index 42670e9..8719c2f 100644
78404 --- a/kernel/posix-cpu-timers.c
78405 +++ b/kernel/posix-cpu-timers.c
78406 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
78407
78408 static __init int init_posix_cpu_timers(void)
78409 {
78410 - struct k_clock process = {
78411 + static struct k_clock process = {
78412 .clock_getres = process_cpu_clock_getres,
78413 .clock_get = process_cpu_clock_get,
78414 .timer_create = process_cpu_timer_create,
78415 .nsleep = process_cpu_nsleep,
78416 .nsleep_restart = process_cpu_nsleep_restart,
78417 };
78418 - struct k_clock thread = {
78419 + static struct k_clock thread = {
78420 .clock_getres = thread_cpu_clock_getres,
78421 .clock_get = thread_cpu_clock_get,
78422 .timer_create = thread_cpu_timer_create,
78423 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
78424 index 424c2d4..a9194f7 100644
78425 --- a/kernel/posix-timers.c
78426 +++ b/kernel/posix-timers.c
78427 @@ -43,6 +43,7 @@
78428 #include <linux/hash.h>
78429 #include <linux/posix-clock.h>
78430 #include <linux/posix-timers.h>
78431 +#include <linux/grsecurity.h>
78432 #include <linux/syscalls.h>
78433 #include <linux/wait.h>
78434 #include <linux/workqueue.h>
78435 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
78436 * which we beg off on and pass to do_sys_settimeofday().
78437 */
78438
78439 -static struct k_clock posix_clocks[MAX_CLOCKS];
78440 +static struct k_clock *posix_clocks[MAX_CLOCKS];
78441
78442 /*
78443 * These ones are defined below.
78444 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
78445 */
78446 static __init int init_posix_timers(void)
78447 {
78448 - struct k_clock clock_realtime = {
78449 + static struct k_clock clock_realtime = {
78450 .clock_getres = hrtimer_get_res,
78451 .clock_get = posix_clock_realtime_get,
78452 .clock_set = posix_clock_realtime_set,
78453 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
78454 .timer_get = common_timer_get,
78455 .timer_del = common_timer_del,
78456 };
78457 - struct k_clock clock_monotonic = {
78458 + static struct k_clock clock_monotonic = {
78459 .clock_getres = hrtimer_get_res,
78460 .clock_get = posix_ktime_get_ts,
78461 .nsleep = common_nsleep,
78462 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
78463 .timer_get = common_timer_get,
78464 .timer_del = common_timer_del,
78465 };
78466 - struct k_clock clock_monotonic_raw = {
78467 + static struct k_clock clock_monotonic_raw = {
78468 .clock_getres = hrtimer_get_res,
78469 .clock_get = posix_get_monotonic_raw,
78470 };
78471 - struct k_clock clock_realtime_coarse = {
78472 + static struct k_clock clock_realtime_coarse = {
78473 .clock_getres = posix_get_coarse_res,
78474 .clock_get = posix_get_realtime_coarse,
78475 };
78476 - struct k_clock clock_monotonic_coarse = {
78477 + static struct k_clock clock_monotonic_coarse = {
78478 .clock_getres = posix_get_coarse_res,
78479 .clock_get = posix_get_monotonic_coarse,
78480 };
78481 - struct k_clock clock_tai = {
78482 + static struct k_clock clock_tai = {
78483 .clock_getres = hrtimer_get_res,
78484 .clock_get = posix_get_tai,
78485 .nsleep = common_nsleep,
78486 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
78487 .timer_get = common_timer_get,
78488 .timer_del = common_timer_del,
78489 };
78490 - struct k_clock clock_boottime = {
78491 + static struct k_clock clock_boottime = {
78492 .clock_getres = hrtimer_get_res,
78493 .clock_get = posix_get_boottime,
78494 .nsleep = common_nsleep,
78495 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
78496 return;
78497 }
78498
78499 - posix_clocks[clock_id] = *new_clock;
78500 + posix_clocks[clock_id] = new_clock;
78501 }
78502 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
78503
78504 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
78505 return (id & CLOCKFD_MASK) == CLOCKFD ?
78506 &clock_posix_dynamic : &clock_posix_cpu;
78507
78508 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
78509 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
78510 return NULL;
78511 - return &posix_clocks[id];
78512 + return posix_clocks[id];
78513 }
78514
78515 static int common_timer_create(struct k_itimer *new_timer)
78516 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
78517 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
78518 return -EFAULT;
78519
78520 + /* only the CLOCK_REALTIME clock can be set, all other clocks
78521 + have their clock_set fptr set to a nosettime dummy function
78522 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
78523 + call common_clock_set, which calls do_sys_settimeofday, which
78524 + we hook
78525 + */
78526 +
78527 return kc->clock_set(which_clock, &new_tp);
78528 }
78529
78530 diff --git a/kernel/power/process.c b/kernel/power/process.c
78531 index 98088e0..aaf95c0 100644
78532 --- a/kernel/power/process.c
78533 +++ b/kernel/power/process.c
78534 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
78535 u64 elapsed_csecs64;
78536 unsigned int elapsed_csecs;
78537 bool wakeup = false;
78538 + bool timedout = false;
78539
78540 do_gettimeofday(&start);
78541
78542 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
78543
78544 while (true) {
78545 todo = 0;
78546 + if (time_after(jiffies, end_time))
78547 + timedout = true;
78548 read_lock(&tasklist_lock);
78549 do_each_thread(g, p) {
78550 if (p == current || !freeze_task(p))
78551 continue;
78552
78553 - if (!freezer_should_skip(p))
78554 + if (!freezer_should_skip(p)) {
78555 todo++;
78556 + if (timedout) {
78557 + printk(KERN_ERR "Task refusing to freeze:\n");
78558 + sched_show_task(p);
78559 + }
78560 + }
78561 } while_each_thread(g, p);
78562 read_unlock(&tasklist_lock);
78563
78564 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
78565 todo += wq_busy;
78566 }
78567
78568 - if (!todo || time_after(jiffies, end_time))
78569 + if (!todo || timedout)
78570 break;
78571
78572 if (pm_wakeup_pending()) {
78573 diff --git a/kernel/printk.c b/kernel/printk.c
78574 index d37d45c..ab918b3 100644
78575 --- a/kernel/printk.c
78576 +++ b/kernel/printk.c
78577 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
78578 if (from_file && type != SYSLOG_ACTION_OPEN)
78579 return 0;
78580
78581 +#ifdef CONFIG_GRKERNSEC_DMESG
78582 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
78583 + return -EPERM;
78584 +#endif
78585 +
78586 if (syslog_action_restricted(type)) {
78587 if (capable(CAP_SYSLOG))
78588 return 0;
78589 diff --git a/kernel/profile.c b/kernel/profile.c
78590 index 0bf4007..6234708 100644
78591 --- a/kernel/profile.c
78592 +++ b/kernel/profile.c
78593 @@ -37,7 +37,7 @@ struct profile_hit {
78594 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
78595 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
78596
78597 -static atomic_t *prof_buffer;
78598 +static atomic_unchecked_t *prof_buffer;
78599 static unsigned long prof_len, prof_shift;
78600
78601 int prof_on __read_mostly;
78602 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
78603 hits[i].pc = 0;
78604 continue;
78605 }
78606 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
78607 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
78608 hits[i].hits = hits[i].pc = 0;
78609 }
78610 }
78611 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
78612 * Add the current hit(s) and flush the write-queue out
78613 * to the global buffer:
78614 */
78615 - atomic_add(nr_hits, &prof_buffer[pc]);
78616 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
78617 for (i = 0; i < NR_PROFILE_HIT; ++i) {
78618 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
78619 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
78620 hits[i].pc = hits[i].hits = 0;
78621 }
78622 out:
78623 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
78624 {
78625 unsigned long pc;
78626 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
78627 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
78628 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
78629 }
78630 #endif /* !CONFIG_SMP */
78631
78632 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
78633 return -EFAULT;
78634 buf++; p++; count--; read++;
78635 }
78636 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
78637 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
78638 if (copy_to_user(buf, (void *)pnt, count))
78639 return -EFAULT;
78640 read += count;
78641 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
78642 }
78643 #endif
78644 profile_discard_flip_buffers();
78645 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
78646 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
78647 return count;
78648 }
78649
78650 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
78651 index 335a7ae..3bbbceb 100644
78652 --- a/kernel/ptrace.c
78653 +++ b/kernel/ptrace.c
78654 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
78655 if (seize)
78656 flags |= PT_SEIZED;
78657 rcu_read_lock();
78658 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
78659 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
78660 flags |= PT_PTRACE_CAP;
78661 rcu_read_unlock();
78662 task->ptrace = flags;
78663 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
78664 break;
78665 return -EIO;
78666 }
78667 - if (copy_to_user(dst, buf, retval))
78668 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
78669 return -EFAULT;
78670 copied += retval;
78671 src += retval;
78672 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
78673 bool seized = child->ptrace & PT_SEIZED;
78674 int ret = -EIO;
78675 siginfo_t siginfo, *si;
78676 - void __user *datavp = (void __user *) data;
78677 + void __user *datavp = (__force void __user *) data;
78678 unsigned long __user *datalp = datavp;
78679 unsigned long flags;
78680
78681 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
78682 goto out;
78683 }
78684
78685 + if (gr_handle_ptrace(child, request)) {
78686 + ret = -EPERM;
78687 + goto out_put_task_struct;
78688 + }
78689 +
78690 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
78691 ret = ptrace_attach(child, request, addr, data);
78692 /*
78693 * Some architectures need to do book-keeping after
78694 * a ptrace attach.
78695 */
78696 - if (!ret)
78697 + if (!ret) {
78698 arch_ptrace_attach(child);
78699 + gr_audit_ptrace(child);
78700 + }
78701 goto out_put_task_struct;
78702 }
78703
78704 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
78705 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
78706 if (copied != sizeof(tmp))
78707 return -EIO;
78708 - return put_user(tmp, (unsigned long __user *)data);
78709 + return put_user(tmp, (__force unsigned long __user *)data);
78710 }
78711
78712 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
78713 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
78714 }
78715
78716 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
78717 - compat_long_t addr, compat_long_t data)
78718 + compat_ulong_t addr, compat_ulong_t data)
78719 {
78720 struct task_struct *child;
78721 long ret;
78722 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
78723 goto out;
78724 }
78725
78726 + if (gr_handle_ptrace(child, request)) {
78727 + ret = -EPERM;
78728 + goto out_put_task_struct;
78729 + }
78730 +
78731 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
78732 ret = ptrace_attach(child, request, addr, data);
78733 /*
78734 * Some architectures need to do book-keeping after
78735 * a ptrace attach.
78736 */
78737 - if (!ret)
78738 + if (!ret) {
78739 arch_ptrace_attach(child);
78740 + gr_audit_ptrace(child);
78741 + }
78742 goto out_put_task_struct;
78743 }
78744
78745 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
78746 index 48ab703..07561d4 100644
78747 --- a/kernel/rcupdate.c
78748 +++ b/kernel/rcupdate.c
78749 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
78750 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
78751 */
78752 if (till_stall_check < 3) {
78753 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
78754 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
78755 till_stall_check = 3;
78756 } else if (till_stall_check > 300) {
78757 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
78758 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
78759 till_stall_check = 300;
78760 }
78761 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
78762 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
78763 index a0714a5..2ab5e34 100644
78764 --- a/kernel/rcutiny.c
78765 +++ b/kernel/rcutiny.c
78766 @@ -46,7 +46,7 @@
78767 struct rcu_ctrlblk;
78768 static void invoke_rcu_callbacks(void);
78769 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
78770 -static void rcu_process_callbacks(struct softirq_action *unused);
78771 +static void rcu_process_callbacks(void);
78772 static void __call_rcu(struct rcu_head *head,
78773 void (*func)(struct rcu_head *rcu),
78774 struct rcu_ctrlblk *rcp);
78775 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
78776 rcu_is_callbacks_kthread()));
78777 }
78778
78779 -static void rcu_process_callbacks(struct softirq_action *unused)
78780 +static void rcu_process_callbacks(void)
78781 {
78782 __rcu_process_callbacks(&rcu_sched_ctrlblk);
78783 __rcu_process_callbacks(&rcu_bh_ctrlblk);
78784 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
78785 index 8a23300..4255818 100644
78786 --- a/kernel/rcutiny_plugin.h
78787 +++ b/kernel/rcutiny_plugin.h
78788 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
78789 have_rcu_kthread_work = morework;
78790 local_irq_restore(flags);
78791 if (work)
78792 - rcu_process_callbacks(NULL);
78793 + rcu_process_callbacks();
78794 schedule_timeout_interruptible(1); /* Leave CPU for others. */
78795 }
78796
78797 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
78798 index e1f3a8c..42c94a2 100644
78799 --- a/kernel/rcutorture.c
78800 +++ b/kernel/rcutorture.c
78801 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
78802 { 0 };
78803 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
78804 { 0 };
78805 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78806 -static atomic_t n_rcu_torture_alloc;
78807 -static atomic_t n_rcu_torture_alloc_fail;
78808 -static atomic_t n_rcu_torture_free;
78809 -static atomic_t n_rcu_torture_mberror;
78810 -static atomic_t n_rcu_torture_error;
78811 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78812 +static atomic_unchecked_t n_rcu_torture_alloc;
78813 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
78814 +static atomic_unchecked_t n_rcu_torture_free;
78815 +static atomic_unchecked_t n_rcu_torture_mberror;
78816 +static atomic_unchecked_t n_rcu_torture_error;
78817 static long n_rcu_torture_barrier_error;
78818 static long n_rcu_torture_boost_ktrerror;
78819 static long n_rcu_torture_boost_rterror;
78820 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
78821
78822 spin_lock_bh(&rcu_torture_lock);
78823 if (list_empty(&rcu_torture_freelist)) {
78824 - atomic_inc(&n_rcu_torture_alloc_fail);
78825 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
78826 spin_unlock_bh(&rcu_torture_lock);
78827 return NULL;
78828 }
78829 - atomic_inc(&n_rcu_torture_alloc);
78830 + atomic_inc_unchecked(&n_rcu_torture_alloc);
78831 p = rcu_torture_freelist.next;
78832 list_del_init(p);
78833 spin_unlock_bh(&rcu_torture_lock);
78834 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
78835 static void
78836 rcu_torture_free(struct rcu_torture *p)
78837 {
78838 - atomic_inc(&n_rcu_torture_free);
78839 + atomic_inc_unchecked(&n_rcu_torture_free);
78840 spin_lock_bh(&rcu_torture_lock);
78841 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
78842 spin_unlock_bh(&rcu_torture_lock);
78843 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
78844 i = rp->rtort_pipe_count;
78845 if (i > RCU_TORTURE_PIPE_LEN)
78846 i = RCU_TORTURE_PIPE_LEN;
78847 - atomic_inc(&rcu_torture_wcount[i]);
78848 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78849 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78850 rp->rtort_mbtest = 0;
78851 rcu_torture_free(rp);
78852 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
78853 i = rp->rtort_pipe_count;
78854 if (i > RCU_TORTURE_PIPE_LEN)
78855 i = RCU_TORTURE_PIPE_LEN;
78856 - atomic_inc(&rcu_torture_wcount[i]);
78857 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78858 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78859 rp->rtort_mbtest = 0;
78860 list_del(&rp->rtort_free);
78861 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
78862 i = old_rp->rtort_pipe_count;
78863 if (i > RCU_TORTURE_PIPE_LEN)
78864 i = RCU_TORTURE_PIPE_LEN;
78865 - atomic_inc(&rcu_torture_wcount[i]);
78866 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78867 old_rp->rtort_pipe_count++;
78868 cur_ops->deferred_free(old_rp);
78869 }
78870 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
78871 return;
78872 }
78873 if (p->rtort_mbtest == 0)
78874 - atomic_inc(&n_rcu_torture_mberror);
78875 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78876 spin_lock(&rand_lock);
78877 cur_ops->read_delay(&rand);
78878 n_rcu_torture_timers++;
78879 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
78880 continue;
78881 }
78882 if (p->rtort_mbtest == 0)
78883 - atomic_inc(&n_rcu_torture_mberror);
78884 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78885 cur_ops->read_delay(&rand);
78886 preempt_disable();
78887 pipe_count = p->rtort_pipe_count;
78888 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
78889 rcu_torture_current,
78890 rcu_torture_current_version,
78891 list_empty(&rcu_torture_freelist),
78892 - atomic_read(&n_rcu_torture_alloc),
78893 - atomic_read(&n_rcu_torture_alloc_fail),
78894 - atomic_read(&n_rcu_torture_free));
78895 + atomic_read_unchecked(&n_rcu_torture_alloc),
78896 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
78897 + atomic_read_unchecked(&n_rcu_torture_free));
78898 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
78899 - atomic_read(&n_rcu_torture_mberror),
78900 + atomic_read_unchecked(&n_rcu_torture_mberror),
78901 n_rcu_torture_boost_ktrerror,
78902 n_rcu_torture_boost_rterror);
78903 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
78904 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
78905 n_barrier_attempts,
78906 n_rcu_torture_barrier_error);
78907 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
78908 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
78909 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
78910 n_rcu_torture_barrier_error != 0 ||
78911 n_rcu_torture_boost_ktrerror != 0 ||
78912 n_rcu_torture_boost_rterror != 0 ||
78913 n_rcu_torture_boost_failure != 0 ||
78914 i > 1) {
78915 cnt += sprintf(&page[cnt], "!!! ");
78916 - atomic_inc(&n_rcu_torture_error);
78917 + atomic_inc_unchecked(&n_rcu_torture_error);
78918 WARN_ON_ONCE(1);
78919 }
78920 cnt += sprintf(&page[cnt], "Reader Pipe: ");
78921 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
78922 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
78923 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78924 cnt += sprintf(&page[cnt], " %d",
78925 - atomic_read(&rcu_torture_wcount[i]));
78926 + atomic_read_unchecked(&rcu_torture_wcount[i]));
78927 }
78928 cnt += sprintf(&page[cnt], "\n");
78929 if (cur_ops->stats)
78930 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
78931
78932 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
78933
78934 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78935 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78936 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
78937 else if (n_online_successes != n_online_attempts ||
78938 n_offline_successes != n_offline_attempts)
78939 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
78940
78941 rcu_torture_current = NULL;
78942 rcu_torture_current_version = 0;
78943 - atomic_set(&n_rcu_torture_alloc, 0);
78944 - atomic_set(&n_rcu_torture_alloc_fail, 0);
78945 - atomic_set(&n_rcu_torture_free, 0);
78946 - atomic_set(&n_rcu_torture_mberror, 0);
78947 - atomic_set(&n_rcu_torture_error, 0);
78948 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
78949 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
78950 + atomic_set_unchecked(&n_rcu_torture_free, 0);
78951 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
78952 + atomic_set_unchecked(&n_rcu_torture_error, 0);
78953 n_rcu_torture_barrier_error = 0;
78954 n_rcu_torture_boost_ktrerror = 0;
78955 n_rcu_torture_boost_rterror = 0;
78956 n_rcu_torture_boost_failure = 0;
78957 n_rcu_torture_boosts = 0;
78958 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
78959 - atomic_set(&rcu_torture_wcount[i], 0);
78960 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
78961 for_each_possible_cpu(cpu) {
78962 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78963 per_cpu(rcu_torture_count, cpu)[i] = 0;
78964 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
78965 index 3538001..e379e0b 100644
78966 --- a/kernel/rcutree.c
78967 +++ b/kernel/rcutree.c
78968 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
78969 rcu_prepare_for_idle(smp_processor_id());
78970 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78971 smp_mb__before_atomic_inc(); /* See above. */
78972 - atomic_inc(&rdtp->dynticks);
78973 + atomic_inc_unchecked(&rdtp->dynticks);
78974 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
78975 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78976 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78977
78978 /*
78979 * It is illegal to enter an extended quiescent state while
78980 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
78981 int user)
78982 {
78983 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
78984 - atomic_inc(&rdtp->dynticks);
78985 + atomic_inc_unchecked(&rdtp->dynticks);
78986 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78987 smp_mb__after_atomic_inc(); /* See above. */
78988 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78989 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78990 rcu_cleanup_after_idle(smp_processor_id());
78991 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
78992 if (!user && !is_idle_task(current)) {
78993 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
78994 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
78995
78996 if (rdtp->dynticks_nmi_nesting == 0 &&
78997 - (atomic_read(&rdtp->dynticks) & 0x1))
78998 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
78999 return;
79000 rdtp->dynticks_nmi_nesting++;
79001 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
79002 - atomic_inc(&rdtp->dynticks);
79003 + atomic_inc_unchecked(&rdtp->dynticks);
79004 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
79005 smp_mb__after_atomic_inc(); /* See above. */
79006 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
79007 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
79008 }
79009
79010 /**
79011 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
79012 return;
79013 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
79014 smp_mb__before_atomic_inc(); /* See above. */
79015 - atomic_inc(&rdtp->dynticks);
79016 + atomic_inc_unchecked(&rdtp->dynticks);
79017 smp_mb__after_atomic_inc(); /* Force delay to next write. */
79018 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
79019 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
79020 }
79021
79022 /**
79023 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
79024 int ret;
79025
79026 preempt_disable();
79027 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
79028 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
79029 preempt_enable();
79030 return ret;
79031 }
79032 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
79033 */
79034 static int dyntick_save_progress_counter(struct rcu_data *rdp)
79035 {
79036 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
79037 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
79038 return (rdp->dynticks_snap & 0x1) == 0;
79039 }
79040
79041 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
79042 unsigned int curr;
79043 unsigned int snap;
79044
79045 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
79046 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
79047 snap = (unsigned int)rdp->dynticks_snap;
79048
79049 /*
79050 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
79051 rdp = this_cpu_ptr(rsp->rda);
79052 rcu_preempt_check_blocked_tasks(rnp);
79053 rnp->qsmask = rnp->qsmaskinit;
79054 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
79055 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
79056 WARN_ON_ONCE(rnp->completed != rsp->completed);
79057 - ACCESS_ONCE(rnp->completed) = rsp->completed;
79058 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
79059 if (rnp == rdp->mynode)
79060 rcu_start_gp_per_cpu(rsp, rnp, rdp);
79061 rcu_preempt_boost_start_gp(rnp);
79062 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
79063 */
79064 rcu_for_each_node_breadth_first(rsp, rnp) {
79065 raw_spin_lock_irq(&rnp->lock);
79066 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
79067 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
79068 rdp = this_cpu_ptr(rsp->rda);
79069 if (rnp == rdp->mynode)
79070 __rcu_process_gp_end(rsp, rnp, rdp);
79071 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
79072 rsp->qlen += rdp->qlen;
79073 rdp->n_cbs_orphaned += rdp->qlen;
79074 rdp->qlen_lazy = 0;
79075 - ACCESS_ONCE(rdp->qlen) = 0;
79076 + ACCESS_ONCE_RW(rdp->qlen) = 0;
79077 }
79078
79079 /*
79080 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
79081 }
79082 smp_mb(); /* List handling before counting for rcu_barrier(). */
79083 rdp->qlen_lazy -= count_lazy;
79084 - ACCESS_ONCE(rdp->qlen) -= count;
79085 + ACCESS_ONCE_RW(rdp->qlen) -= count;
79086 rdp->n_cbs_invoked += count;
79087
79088 /* Reinstate batch limit if we have worked down the excess. */
79089 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
79090 /*
79091 * Do RCU core processing for the current CPU.
79092 */
79093 -static void rcu_process_callbacks(struct softirq_action *unused)
79094 +static void rcu_process_callbacks(void)
79095 {
79096 struct rcu_state *rsp;
79097
79098 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
79099 local_irq_restore(flags);
79100 return;
79101 }
79102 - ACCESS_ONCE(rdp->qlen)++;
79103 + ACCESS_ONCE_RW(rdp->qlen)++;
79104 if (lazy)
79105 rdp->qlen_lazy++;
79106 else
79107 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
79108 * counter wrap on a 32-bit system. Quite a few more CPUs would of
79109 * course be required on a 64-bit system.
79110 */
79111 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
79112 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
79113 (ulong)atomic_long_read(&rsp->expedited_done) +
79114 ULONG_MAX / 8)) {
79115 synchronize_sched();
79116 - atomic_long_inc(&rsp->expedited_wrap);
79117 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
79118 return;
79119 }
79120
79121 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
79122 * Take a ticket. Note that atomic_inc_return() implies a
79123 * full memory barrier.
79124 */
79125 - snap = atomic_long_inc_return(&rsp->expedited_start);
79126 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
79127 firstsnap = snap;
79128 get_online_cpus();
79129 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
79130 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
79131 synchronize_sched_expedited_cpu_stop,
79132 NULL) == -EAGAIN) {
79133 put_online_cpus();
79134 - atomic_long_inc(&rsp->expedited_tryfail);
79135 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
79136
79137 /* Check to see if someone else did our work for us. */
79138 s = atomic_long_read(&rsp->expedited_done);
79139 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
79140 /* ensure test happens before caller kfree */
79141 smp_mb__before_atomic_inc(); /* ^^^ */
79142 - atomic_long_inc(&rsp->expedited_workdone1);
79143 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
79144 return;
79145 }
79146
79147 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
79148 udelay(trycount * num_online_cpus());
79149 } else {
79150 wait_rcu_gp(call_rcu_sched);
79151 - atomic_long_inc(&rsp->expedited_normal);
79152 + atomic_long_inc_unchecked(&rsp->expedited_normal);
79153 return;
79154 }
79155
79156 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
79157 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
79158 /* ensure test happens before caller kfree */
79159 smp_mb__before_atomic_inc(); /* ^^^ */
79160 - atomic_long_inc(&rsp->expedited_workdone2);
79161 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
79162 return;
79163 }
79164
79165 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
79166 * period works for us.
79167 */
79168 get_online_cpus();
79169 - snap = atomic_long_read(&rsp->expedited_start);
79170 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
79171 smp_mb(); /* ensure read is before try_stop_cpus(). */
79172 }
79173 - atomic_long_inc(&rsp->expedited_stoppedcpus);
79174 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
79175
79176 /*
79177 * Everyone up to our most recent fetch is covered by our grace
79178 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
79179 * than we did already did their update.
79180 */
79181 do {
79182 - atomic_long_inc(&rsp->expedited_done_tries);
79183 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
79184 s = atomic_long_read(&rsp->expedited_done);
79185 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
79186 /* ensure test happens before caller kfree */
79187 smp_mb__before_atomic_inc(); /* ^^^ */
79188 - atomic_long_inc(&rsp->expedited_done_lost);
79189 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
79190 break;
79191 }
79192 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
79193 - atomic_long_inc(&rsp->expedited_done_exit);
79194 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
79195
79196 put_online_cpus();
79197 }
79198 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
79199 * ACCESS_ONCE() to prevent the compiler from speculating
79200 * the increment to precede the early-exit check.
79201 */
79202 - ACCESS_ONCE(rsp->n_barrier_done)++;
79203 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
79204 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
79205 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
79206 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
79207 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
79208
79209 /* Increment ->n_barrier_done to prevent duplicate work. */
79210 smp_mb(); /* Keep increment after above mechanism. */
79211 - ACCESS_ONCE(rsp->n_barrier_done)++;
79212 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
79213 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
79214 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
79215 smp_mb(); /* Keep increment before caller's subsequent code. */
79216 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
79217 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
79218 init_callback_list(rdp);
79219 rdp->qlen_lazy = 0;
79220 - ACCESS_ONCE(rdp->qlen) = 0;
79221 + ACCESS_ONCE_RW(rdp->qlen) = 0;
79222 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
79223 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
79224 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
79225 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
79226 rdp->cpu = cpu;
79227 rdp->rsp = rsp;
79228 rcu_boot_init_nocb_percpu_data(rdp);
79229 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
79230 rdp->blimit = blimit;
79231 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
79232 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
79233 - atomic_set(&rdp->dynticks->dynticks,
79234 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
79235 + atomic_set_unchecked(&rdp->dynticks->dynticks,
79236 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
79237 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
79238
79239 /* Add CPU to rcu_node bitmasks. */
79240 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
79241 struct task_struct *t;
79242
79243 for_each_rcu_flavor(rsp) {
79244 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
79245 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
79246 BUG_ON(IS_ERR(t));
79247 rnp = rcu_get_root(rsp);
79248 raw_spin_lock_irqsave(&rnp->lock, flags);
79249 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
79250 index 4df5034..5ee93f2 100644
79251 --- a/kernel/rcutree.h
79252 +++ b/kernel/rcutree.h
79253 @@ -87,7 +87,7 @@ struct rcu_dynticks {
79254 long long dynticks_nesting; /* Track irq/process nesting level. */
79255 /* Process level is worth LLONG_MAX/2. */
79256 int dynticks_nmi_nesting; /* Track NMI nesting level. */
79257 - atomic_t dynticks; /* Even value for idle, else odd. */
79258 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
79259 #ifdef CONFIG_RCU_FAST_NO_HZ
79260 bool all_lazy; /* Are all CPU's CBs lazy? */
79261 unsigned long nonlazy_posted;
79262 @@ -414,17 +414,17 @@ struct rcu_state {
79263 /* _rcu_barrier(). */
79264 /* End of fields guarded by barrier_mutex. */
79265
79266 - atomic_long_t expedited_start; /* Starting ticket. */
79267 - atomic_long_t expedited_done; /* Done ticket. */
79268 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
79269 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
79270 - atomic_long_t expedited_workdone1; /* # done by others #1. */
79271 - atomic_long_t expedited_workdone2; /* # done by others #2. */
79272 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
79273 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
79274 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
79275 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
79276 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
79277 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
79278 + atomic_long_t expedited_done; /* Done ticket. */
79279 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
79280 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
79281 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
79282 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
79283 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
79284 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
79285 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
79286 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
79287 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
79288
79289 unsigned long jiffies_force_qs; /* Time at which to invoke */
79290 /* force_quiescent_state(). */
79291 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
79292 index 3db5a37..b395fb35 100644
79293 --- a/kernel/rcutree_plugin.h
79294 +++ b/kernel/rcutree_plugin.h
79295 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
79296
79297 /* Clean up and exit. */
79298 smp_mb(); /* ensure expedited GP seen before counter increment. */
79299 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
79300 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
79301 unlock_mb_ret:
79302 mutex_unlock(&sync_rcu_preempt_exp_mutex);
79303 mb_ret:
79304 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
79305 free_cpumask_var(cm);
79306 }
79307
79308 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
79309 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
79310 .store = &rcu_cpu_kthread_task,
79311 .thread_should_run = rcu_cpu_kthread_should_run,
79312 .thread_fn = rcu_cpu_kthread,
79313 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
79314 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
79315 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
79316 cpu, ticks_value, ticks_title,
79317 - atomic_read(&rdtp->dynticks) & 0xfff,
79318 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
79319 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
79320 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
79321 fast_no_hz);
79322 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
79323
79324 /* Enqueue the callback on the nocb list and update counts. */
79325 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
79326 - ACCESS_ONCE(*old_rhpp) = rhp;
79327 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
79328 atomic_long_add(rhcount, &rdp->nocb_q_count);
79329 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
79330
79331 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
79332 * Extract queued callbacks, update counts, and wait
79333 * for a grace period to elapse.
79334 */
79335 - ACCESS_ONCE(rdp->nocb_head) = NULL;
79336 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
79337 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
79338 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
79339 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
79340 - ACCESS_ONCE(rdp->nocb_p_count) += c;
79341 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
79342 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
79343 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
79344 rcu_nocb_wait_gp(rdp);
79345
79346 /* Each pass through the following loop invokes a callback. */
79347 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
79348 list = next;
79349 }
79350 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
79351 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
79352 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
79353 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
79354 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
79355 rdp->n_nocbs_invoked += c;
79356 }
79357 return 0;
79358 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
79359 t = kthread_run(rcu_nocb_kthread, rdp,
79360 "rcuo%c/%d", rsp->abbr, cpu);
79361 BUG_ON(IS_ERR(t));
79362 - ACCESS_ONCE(rdp->nocb_kthread) = t;
79363 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
79364 }
79365 }
79366
79367 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
79368 index cf6c174..a8f4b50 100644
79369 --- a/kernel/rcutree_trace.c
79370 +++ b/kernel/rcutree_trace.c
79371 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
79372 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
79373 rdp->passed_quiesce, rdp->qs_pending);
79374 seq_printf(m, " dt=%d/%llx/%d df=%lu",
79375 - atomic_read(&rdp->dynticks->dynticks),
79376 + atomic_read_unchecked(&rdp->dynticks->dynticks),
79377 rdp->dynticks->dynticks_nesting,
79378 rdp->dynticks->dynticks_nmi_nesting,
79379 rdp->dynticks_fqs);
79380 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
79381 struct rcu_state *rsp = (struct rcu_state *)m->private;
79382
79383 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",
79384 - atomic_long_read(&rsp->expedited_start),
79385 + atomic_long_read_unchecked(&rsp->expedited_start),
79386 atomic_long_read(&rsp->expedited_done),
79387 - atomic_long_read(&rsp->expedited_wrap),
79388 - atomic_long_read(&rsp->expedited_tryfail),
79389 - atomic_long_read(&rsp->expedited_workdone1),
79390 - atomic_long_read(&rsp->expedited_workdone2),
79391 - atomic_long_read(&rsp->expedited_normal),
79392 - atomic_long_read(&rsp->expedited_stoppedcpus),
79393 - atomic_long_read(&rsp->expedited_done_tries),
79394 - atomic_long_read(&rsp->expedited_done_lost),
79395 - atomic_long_read(&rsp->expedited_done_exit));
79396 + atomic_long_read_unchecked(&rsp->expedited_wrap),
79397 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
79398 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
79399 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
79400 + atomic_long_read_unchecked(&rsp->expedited_normal),
79401 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
79402 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
79403 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
79404 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
79405 return 0;
79406 }
79407
79408 diff --git a/kernel/resource.c b/kernel/resource.c
79409 index d738698..5f8e60a 100644
79410 --- a/kernel/resource.c
79411 +++ b/kernel/resource.c
79412 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
79413
79414 static int __init ioresources_init(void)
79415 {
79416 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79417 +#ifdef CONFIG_GRKERNSEC_PROC_USER
79418 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
79419 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
79420 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79421 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
79422 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
79423 +#endif
79424 +#else
79425 proc_create("ioports", 0, NULL, &proc_ioports_operations);
79426 proc_create("iomem", 0, NULL, &proc_iomem_operations);
79427 +#endif
79428 return 0;
79429 }
79430 __initcall(ioresources_init);
79431 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
79432 index 1d96dd0..994ff19 100644
79433 --- a/kernel/rtmutex-tester.c
79434 +++ b/kernel/rtmutex-tester.c
79435 @@ -22,7 +22,7 @@
79436 #define MAX_RT_TEST_MUTEXES 8
79437
79438 static spinlock_t rttest_lock;
79439 -static atomic_t rttest_event;
79440 +static atomic_unchecked_t rttest_event;
79441
79442 struct test_thread_data {
79443 int opcode;
79444 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79445
79446 case RTTEST_LOCKCONT:
79447 td->mutexes[td->opdata] = 1;
79448 - td->event = atomic_add_return(1, &rttest_event);
79449 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79450 return 0;
79451
79452 case RTTEST_RESET:
79453 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79454 return 0;
79455
79456 case RTTEST_RESETEVENT:
79457 - atomic_set(&rttest_event, 0);
79458 + atomic_set_unchecked(&rttest_event, 0);
79459 return 0;
79460
79461 default:
79462 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79463 return ret;
79464
79465 td->mutexes[id] = 1;
79466 - td->event = atomic_add_return(1, &rttest_event);
79467 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79468 rt_mutex_lock(&mutexes[id]);
79469 - td->event = atomic_add_return(1, &rttest_event);
79470 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79471 td->mutexes[id] = 4;
79472 return 0;
79473
79474 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79475 return ret;
79476
79477 td->mutexes[id] = 1;
79478 - td->event = atomic_add_return(1, &rttest_event);
79479 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79480 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
79481 - td->event = atomic_add_return(1, &rttest_event);
79482 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79483 td->mutexes[id] = ret ? 0 : 4;
79484 return ret ? -EINTR : 0;
79485
79486 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
79487 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
79488 return ret;
79489
79490 - td->event = atomic_add_return(1, &rttest_event);
79491 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79492 rt_mutex_unlock(&mutexes[id]);
79493 - td->event = atomic_add_return(1, &rttest_event);
79494 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79495 td->mutexes[id] = 0;
79496 return 0;
79497
79498 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
79499 break;
79500
79501 td->mutexes[dat] = 2;
79502 - td->event = atomic_add_return(1, &rttest_event);
79503 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79504 break;
79505
79506 default:
79507 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
79508 return;
79509
79510 td->mutexes[dat] = 3;
79511 - td->event = atomic_add_return(1, &rttest_event);
79512 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79513 break;
79514
79515 case RTTEST_LOCKNOWAIT:
79516 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
79517 return;
79518
79519 td->mutexes[dat] = 1;
79520 - td->event = atomic_add_return(1, &rttest_event);
79521 + td->event = atomic_add_return_unchecked(1, &rttest_event);
79522 return;
79523
79524 default:
79525 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
79526 index 64de5f8..7735e12 100644
79527 --- a/kernel/sched/auto_group.c
79528 +++ b/kernel/sched/auto_group.c
79529 @@ -11,7 +11,7 @@
79530
79531 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
79532 static struct autogroup autogroup_default;
79533 -static atomic_t autogroup_seq_nr;
79534 +static atomic_unchecked_t autogroup_seq_nr;
79535
79536 void __init autogroup_init(struct task_struct *init_task)
79537 {
79538 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
79539
79540 kref_init(&ag->kref);
79541 init_rwsem(&ag->lock);
79542 - ag->id = atomic_inc_return(&autogroup_seq_nr);
79543 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
79544 ag->tg = tg;
79545 #ifdef CONFIG_RT_GROUP_SCHED
79546 /*
79547 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
79548 index e8b3350..d83d44e 100644
79549 --- a/kernel/sched/core.c
79550 +++ b/kernel/sched/core.c
79551 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
79552 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
79553 * positive (at least 1, or number of jiffies left till timeout) if completed.
79554 */
79555 -long __sched
79556 +long __sched __intentional_overflow(-1)
79557 wait_for_completion_interruptible_timeout(struct completion *x,
79558 unsigned long timeout)
79559 {
79560 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
79561 *
79562 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
79563 */
79564 -int __sched wait_for_completion_killable(struct completion *x)
79565 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
79566 {
79567 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
79568 if (t == -ERESTARTSYS)
79569 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
79570 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
79571 * positive (at least 1, or number of jiffies left till timeout) if completed.
79572 */
79573 -long __sched
79574 +long __sched __intentional_overflow(-1)
79575 wait_for_completion_killable_timeout(struct completion *x,
79576 unsigned long timeout)
79577 {
79578 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
79579 /* convert nice value [19,-20] to rlimit style value [1,40] */
79580 int nice_rlim = 20 - nice;
79581
79582 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
79583 +
79584 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
79585 capable(CAP_SYS_NICE));
79586 }
79587 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
79588 if (nice > 19)
79589 nice = 19;
79590
79591 - if (increment < 0 && !can_nice(current, nice))
79592 + if (increment < 0 && (!can_nice(current, nice) ||
79593 + gr_handle_chroot_nice()))
79594 return -EPERM;
79595
79596 retval = security_task_setnice(current, nice);
79597 @@ -3891,6 +3894,7 @@ recheck:
79598 unsigned long rlim_rtprio =
79599 task_rlimit(p, RLIMIT_RTPRIO);
79600
79601 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
79602 /* can't set/change the rt policy */
79603 if (policy != p->policy && !rlim_rtprio)
79604 return -EPERM;
79605 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
79606
79607 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
79608
79609 -static struct ctl_table sd_ctl_dir[] = {
79610 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
79611 {
79612 .procname = "sched_domain",
79613 .mode = 0555,
79614 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
79615 {}
79616 };
79617
79618 -static struct ctl_table *sd_alloc_ctl_entry(int n)
79619 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
79620 {
79621 - struct ctl_table *entry =
79622 + ctl_table_no_const *entry =
79623 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
79624
79625 return entry;
79626 }
79627
79628 -static void sd_free_ctl_entry(struct ctl_table **tablep)
79629 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
79630 {
79631 - struct ctl_table *entry;
79632 + ctl_table_no_const *entry;
79633
79634 /*
79635 * In the intermediate directories, both the child directory and
79636 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
79637 * will always be set. In the lowest directory the names are
79638 * static strings and all have proc handlers.
79639 */
79640 - for (entry = *tablep; entry->mode; entry++) {
79641 - if (entry->child)
79642 - sd_free_ctl_entry(&entry->child);
79643 + for (entry = tablep; entry->mode; entry++) {
79644 + if (entry->child) {
79645 + sd_free_ctl_entry(entry->child);
79646 + pax_open_kernel();
79647 + entry->child = NULL;
79648 + pax_close_kernel();
79649 + }
79650 if (entry->proc_handler == NULL)
79651 kfree(entry->procname);
79652 }
79653
79654 - kfree(*tablep);
79655 - *tablep = NULL;
79656 + kfree(tablep);
79657 }
79658
79659 static int min_load_idx = 0;
79660 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
79661
79662 static void
79663 -set_table_entry(struct ctl_table *entry,
79664 +set_table_entry(ctl_table_no_const *entry,
79665 const char *procname, void *data, int maxlen,
79666 umode_t mode, proc_handler *proc_handler,
79667 bool load_idx)
79668 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
79669 static struct ctl_table *
79670 sd_alloc_ctl_domain_table(struct sched_domain *sd)
79671 {
79672 - struct ctl_table *table = sd_alloc_ctl_entry(13);
79673 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
79674
79675 if (table == NULL)
79676 return NULL;
79677 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
79678 return table;
79679 }
79680
79681 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
79682 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
79683 {
79684 - struct ctl_table *entry, *table;
79685 + ctl_table_no_const *entry, *table;
79686 struct sched_domain *sd;
79687 int domain_num = 0, i;
79688 char buf[32];
79689 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
79690 static void register_sched_domain_sysctl(void)
79691 {
79692 int i, cpu_num = num_possible_cpus();
79693 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
79694 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
79695 char buf[32];
79696
79697 WARN_ON(sd_ctl_dir[0].child);
79698 + pax_open_kernel();
79699 sd_ctl_dir[0].child = entry;
79700 + pax_close_kernel();
79701
79702 if (entry == NULL)
79703 return;
79704 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
79705 if (sd_sysctl_header)
79706 unregister_sysctl_table(sd_sysctl_header);
79707 sd_sysctl_header = NULL;
79708 - if (sd_ctl_dir[0].child)
79709 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
79710 + if (sd_ctl_dir[0].child) {
79711 + sd_free_ctl_entry(sd_ctl_dir[0].child);
79712 + pax_open_kernel();
79713 + sd_ctl_dir[0].child = NULL;
79714 + pax_close_kernel();
79715 + }
79716 }
79717 #else
79718 static void register_sched_domain_sysctl(void)
79719 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
79720 * happens before everything else. This has to be lower priority than
79721 * the notifier in the perf_event subsystem, though.
79722 */
79723 -static struct notifier_block __cpuinitdata migration_notifier = {
79724 +static struct notifier_block migration_notifier = {
79725 .notifier_call = migration_call,
79726 .priority = CPU_PRI_MIGRATION,
79727 };
79728 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
79729 index c61a614..d7f3d7e 100644
79730 --- a/kernel/sched/fair.c
79731 +++ b/kernel/sched/fair.c
79732 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
79733
79734 static void reset_ptenuma_scan(struct task_struct *p)
79735 {
79736 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
79737 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
79738 p->mm->numa_scan_offset = 0;
79739 }
79740
79741 @@ -5686,7 +5686,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
79742 * run_rebalance_domains is triggered when needed from the scheduler tick.
79743 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
79744 */
79745 -static void run_rebalance_domains(struct softirq_action *h)
79746 +static void run_rebalance_domains(void)
79747 {
79748 int this_cpu = smp_processor_id();
79749 struct rq *this_rq = cpu_rq(this_cpu);
79750 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
79751 index ce39224d..0e09343 100644
79752 --- a/kernel/sched/sched.h
79753 +++ b/kernel/sched/sched.h
79754 @@ -1009,7 +1009,7 @@ struct sched_class {
79755 #ifdef CONFIG_FAIR_GROUP_SCHED
79756 void (*task_move_group) (struct task_struct *p, int on_rq);
79757 #endif
79758 -};
79759 +} __do_const;
79760
79761 #define sched_class_highest (&stop_sched_class)
79762 #define for_each_class(class) \
79763 diff --git a/kernel/signal.c b/kernel/signal.c
79764 index 113411b..17190e2 100644
79765 --- a/kernel/signal.c
79766 +++ b/kernel/signal.c
79767 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
79768
79769 int print_fatal_signals __read_mostly;
79770
79771 -static void __user *sig_handler(struct task_struct *t, int sig)
79772 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
79773 {
79774 return t->sighand->action[sig - 1].sa.sa_handler;
79775 }
79776
79777 -static int sig_handler_ignored(void __user *handler, int sig)
79778 +static int sig_handler_ignored(__sighandler_t handler, int sig)
79779 {
79780 /* Is it explicitly or implicitly ignored? */
79781 return handler == SIG_IGN ||
79782 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
79783
79784 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
79785 {
79786 - void __user *handler;
79787 + __sighandler_t handler;
79788
79789 handler = sig_handler(t, sig);
79790
79791 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
79792 atomic_inc(&user->sigpending);
79793 rcu_read_unlock();
79794
79795 + if (!override_rlimit)
79796 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
79797 +
79798 if (override_rlimit ||
79799 atomic_read(&user->sigpending) <=
79800 task_rlimit(t, RLIMIT_SIGPENDING)) {
79801 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
79802
79803 int unhandled_signal(struct task_struct *tsk, int sig)
79804 {
79805 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
79806 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
79807 if (is_global_init(tsk))
79808 return 1;
79809 if (handler != SIG_IGN && handler != SIG_DFL)
79810 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
79811 }
79812 }
79813
79814 + /* allow glibc communication via tgkill to other threads in our
79815 + thread group */
79816 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
79817 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
79818 + && gr_handle_signal(t, sig))
79819 + return -EPERM;
79820 +
79821 return security_task_kill(t, info, sig, 0);
79822 }
79823
79824 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79825 return send_signal(sig, info, p, 1);
79826 }
79827
79828 -static int
79829 +int
79830 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79831 {
79832 return send_signal(sig, info, t, 0);
79833 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79834 unsigned long int flags;
79835 int ret, blocked, ignored;
79836 struct k_sigaction *action;
79837 + int is_unhandled = 0;
79838
79839 spin_lock_irqsave(&t->sighand->siglock, flags);
79840 action = &t->sighand->action[sig-1];
79841 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79842 }
79843 if (action->sa.sa_handler == SIG_DFL)
79844 t->signal->flags &= ~SIGNAL_UNKILLABLE;
79845 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
79846 + is_unhandled = 1;
79847 ret = specific_send_sig_info(sig, info, t);
79848 spin_unlock_irqrestore(&t->sighand->siglock, flags);
79849
79850 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
79851 + normal operation */
79852 + if (is_unhandled) {
79853 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
79854 + gr_handle_crash(t, sig);
79855 + }
79856 +
79857 return ret;
79858 }
79859
79860 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79861 ret = check_kill_permission(sig, info, p);
79862 rcu_read_unlock();
79863
79864 - if (!ret && sig)
79865 + if (!ret && sig) {
79866 ret = do_send_sig_info(sig, info, p, true);
79867 + if (!ret)
79868 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
79869 + }
79870
79871 return ret;
79872 }
79873 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
79874 int error = -ESRCH;
79875
79876 rcu_read_lock();
79877 - p = find_task_by_vpid(pid);
79878 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
79879 + /* allow glibc communication via tgkill to other threads in our
79880 + thread group */
79881 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
79882 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
79883 + p = find_task_by_vpid_unrestricted(pid);
79884 + else
79885 +#endif
79886 + p = find_task_by_vpid(pid);
79887 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
79888 error = check_kill_permission(sig, info, p);
79889 /*
79890 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
79891 }
79892 seg = get_fs();
79893 set_fs(KERNEL_DS);
79894 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
79895 - (stack_t __force __user *) &uoss,
79896 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
79897 + (stack_t __force_user *) &uoss,
79898 compat_user_stack_pointer());
79899 set_fs(seg);
79900 if (ret >= 0 && uoss_ptr) {
79901 diff --git a/kernel/smp.c b/kernel/smp.c
79902 index 4dba0f7..fe9f773 100644
79903 --- a/kernel/smp.c
79904 +++ b/kernel/smp.c
79905 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
79906 return NOTIFY_OK;
79907 }
79908
79909 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
79910 +static struct notifier_block hotplug_cfd_notifier = {
79911 .notifier_call = hotplug_cfd,
79912 };
79913
79914 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
79915 index 02fc5c9..e54c335 100644
79916 --- a/kernel/smpboot.c
79917 +++ b/kernel/smpboot.c
79918 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
79919 }
79920 smpboot_unpark_thread(plug_thread, cpu);
79921 }
79922 - list_add(&plug_thread->list, &hotplug_threads);
79923 + pax_list_add(&plug_thread->list, &hotplug_threads);
79924 out:
79925 mutex_unlock(&smpboot_threads_lock);
79926 return ret;
79927 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
79928 {
79929 get_online_cpus();
79930 mutex_lock(&smpboot_threads_lock);
79931 - list_del(&plug_thread->list);
79932 + pax_list_del(&plug_thread->list);
79933 smpboot_destroy_threads(plug_thread);
79934 mutex_unlock(&smpboot_threads_lock);
79935 put_online_cpus();
79936 diff --git a/kernel/softirq.c b/kernel/softirq.c
79937 index 3d6833f..da6d93d 100644
79938 --- a/kernel/softirq.c
79939 +++ b/kernel/softirq.c
79940 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
79941 EXPORT_SYMBOL(irq_stat);
79942 #endif
79943
79944 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
79945 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
79946
79947 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
79948
79949 -char *softirq_to_name[NR_SOFTIRQS] = {
79950 +const char * const softirq_to_name[NR_SOFTIRQS] = {
79951 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
79952 "TASKLET", "SCHED", "HRTIMER", "RCU"
79953 };
79954 @@ -250,7 +250,7 @@ restart:
79955 kstat_incr_softirqs_this_cpu(vec_nr);
79956
79957 trace_softirq_entry(vec_nr);
79958 - h->action(h);
79959 + h->action();
79960 trace_softirq_exit(vec_nr);
79961 if (unlikely(prev_count != preempt_count())) {
79962 printk(KERN_ERR "huh, entered softirq %u %s %p"
79963 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
79964 or_softirq_pending(1UL << nr);
79965 }
79966
79967 -void open_softirq(int nr, void (*action)(struct softirq_action *))
79968 +void __init open_softirq(int nr, void (*action)(void))
79969 {
79970 softirq_vec[nr].action = action;
79971 }
79972 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
79973
79974 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
79975
79976 -static void tasklet_action(struct softirq_action *a)
79977 +static void tasklet_action(void)
79978 {
79979 struct tasklet_struct *list;
79980
79981 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
79982 }
79983 }
79984
79985 -static void tasklet_hi_action(struct softirq_action *a)
79986 +static void tasklet_hi_action(void)
79987 {
79988 struct tasklet_struct *list;
79989
79990 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
79991 return NOTIFY_OK;
79992 }
79993
79994 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
79995 +static struct notifier_block remote_softirq_cpu_notifier = {
79996 .notifier_call = remote_softirq_cpu_notify,
79997 };
79998
79999 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
80000 return NOTIFY_OK;
80001 }
80002
80003 -static struct notifier_block __cpuinitdata cpu_nfb = {
80004 +static struct notifier_block cpu_nfb = {
80005 .notifier_call = cpu_callback
80006 };
80007
80008 -static struct smp_hotplug_thread softirq_threads = {
80009 +static struct smp_hotplug_thread softirq_threads __read_only = {
80010 .store = &ksoftirqd,
80011 .thread_should_run = ksoftirqd_should_run,
80012 .thread_fn = run_ksoftirqd,
80013 diff --git a/kernel/srcu.c b/kernel/srcu.c
80014 index 01d5ccb..cdcbee6 100644
80015 --- a/kernel/srcu.c
80016 +++ b/kernel/srcu.c
80017 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
80018
80019 idx = ACCESS_ONCE(sp->completed) & 0x1;
80020 preempt_disable();
80021 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
80022 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
80023 smp_mb(); /* B */ /* Avoid leaking the critical section. */
80024 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
80025 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
80026 preempt_enable();
80027 return idx;
80028 }
80029 diff --git a/kernel/sys.c b/kernel/sys.c
80030 index 2bbd9a7..0875671 100644
80031 --- a/kernel/sys.c
80032 +++ b/kernel/sys.c
80033 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
80034 error = -EACCES;
80035 goto out;
80036 }
80037 +
80038 + if (gr_handle_chroot_setpriority(p, niceval)) {
80039 + error = -EACCES;
80040 + goto out;
80041 + }
80042 +
80043 no_nice = security_task_setnice(p, niceval);
80044 if (no_nice) {
80045 error = no_nice;
80046 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
80047 goto error;
80048 }
80049
80050 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
80051 + goto error;
80052 +
80053 if (rgid != (gid_t) -1 ||
80054 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
80055 new->sgid = new->egid;
80056 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
80057 old = current_cred();
80058
80059 retval = -EPERM;
80060 +
80061 + if (gr_check_group_change(kgid, kgid, kgid))
80062 + goto error;
80063 +
80064 if (nsown_capable(CAP_SETGID))
80065 new->gid = new->egid = new->sgid = new->fsgid = kgid;
80066 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
80067 @@ -678,7 +691,7 @@ error:
80068 /*
80069 * change the user struct in a credentials set to match the new UID
80070 */
80071 -static int set_user(struct cred *new)
80072 +int set_user(struct cred *new)
80073 {
80074 struct user_struct *new_user;
80075
80076 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
80077 goto error;
80078 }
80079
80080 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
80081 + goto error;
80082 +
80083 if (!uid_eq(new->uid, old->uid)) {
80084 retval = set_user(new);
80085 if (retval < 0)
80086 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
80087 old = current_cred();
80088
80089 retval = -EPERM;
80090 +
80091 + if (gr_check_crash_uid(kuid))
80092 + goto error;
80093 + if (gr_check_user_change(kuid, kuid, kuid))
80094 + goto error;
80095 +
80096 if (nsown_capable(CAP_SETUID)) {
80097 new->suid = new->uid = kuid;
80098 if (!uid_eq(kuid, old->uid)) {
80099 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
80100 goto error;
80101 }
80102
80103 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
80104 + goto error;
80105 +
80106 if (ruid != (uid_t) -1) {
80107 new->uid = kruid;
80108 if (!uid_eq(kruid, old->uid)) {
80109 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
80110 goto error;
80111 }
80112
80113 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
80114 + goto error;
80115 +
80116 if (rgid != (gid_t) -1)
80117 new->gid = krgid;
80118 if (egid != (gid_t) -1)
80119 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
80120 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
80121 nsown_capable(CAP_SETUID)) {
80122 if (!uid_eq(kuid, old->fsuid)) {
80123 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
80124 + goto error;
80125 +
80126 new->fsuid = kuid;
80127 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
80128 goto change_okay;
80129 }
80130 }
80131
80132 +error:
80133 abort_creds(new);
80134 return old_fsuid;
80135
80136 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
80137 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
80138 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
80139 nsown_capable(CAP_SETGID)) {
80140 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
80141 + goto error;
80142 +
80143 if (!gid_eq(kgid, old->fsgid)) {
80144 new->fsgid = kgid;
80145 goto change_okay;
80146 }
80147 }
80148
80149 +error:
80150 abort_creds(new);
80151 return old_fsgid;
80152
80153 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
80154 return -EFAULT;
80155
80156 down_read(&uts_sem);
80157 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
80158 + error = __copy_to_user(name->sysname, &utsname()->sysname,
80159 __OLD_UTS_LEN);
80160 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
80161 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
80162 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
80163 __OLD_UTS_LEN);
80164 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
80165 - error |= __copy_to_user(&name->release, &utsname()->release,
80166 + error |= __copy_to_user(name->release, &utsname()->release,
80167 __OLD_UTS_LEN);
80168 error |= __put_user(0, name->release + __OLD_UTS_LEN);
80169 - error |= __copy_to_user(&name->version, &utsname()->version,
80170 + error |= __copy_to_user(name->version, &utsname()->version,
80171 __OLD_UTS_LEN);
80172 error |= __put_user(0, name->version + __OLD_UTS_LEN);
80173 - error |= __copy_to_user(&name->machine, &utsname()->machine,
80174 + error |= __copy_to_user(name->machine, &utsname()->machine,
80175 __OLD_UTS_LEN);
80176 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
80177 up_read(&uts_sem);
80178 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
80179 */
80180 new_rlim->rlim_cur = 1;
80181 }
80182 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
80183 + is changed to a lower value. Since tasks can be created by the same
80184 + user in between this limit change and an execve by this task, force
80185 + a recheck only for this task by setting PF_NPROC_EXCEEDED
80186 + */
80187 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
80188 + tsk->flags |= PF_NPROC_EXCEEDED;
80189 }
80190 if (!retval) {
80191 if (old_rlim)
80192 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
80193 index 9edcf45..713c960 100644
80194 --- a/kernel/sysctl.c
80195 +++ b/kernel/sysctl.c
80196 @@ -93,7 +93,6 @@
80197
80198
80199 #if defined(CONFIG_SYSCTL)
80200 -
80201 /* External variables not in a header file. */
80202 extern int sysctl_overcommit_memory;
80203 extern int sysctl_overcommit_ratio;
80204 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
80205
80206 /* Constants used for minimum and maximum */
80207 #ifdef CONFIG_LOCKUP_DETECTOR
80208 -static int sixty = 60;
80209 -static int neg_one = -1;
80210 +static int sixty __read_only = 60;
80211 #endif
80212
80213 -static int zero;
80214 -static int __maybe_unused one = 1;
80215 -static int __maybe_unused two = 2;
80216 -static int __maybe_unused three = 3;
80217 -static unsigned long one_ul = 1;
80218 -static int one_hundred = 100;
80219 +static int neg_one __read_only = -1;
80220 +static int zero __read_only = 0;
80221 +static int __maybe_unused one __read_only = 1;
80222 +static int __maybe_unused two __read_only = 2;
80223 +static int __maybe_unused three __read_only = 3;
80224 +static unsigned long one_ul __read_only = 1;
80225 +static int one_hundred __read_only = 100;
80226 #ifdef CONFIG_PRINTK
80227 -static int ten_thousand = 10000;
80228 +static int ten_thousand __read_only = 10000;
80229 #endif
80230
80231 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
80232 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
80233 void __user *buffer, size_t *lenp, loff_t *ppos);
80234 #endif
80235
80236 -#ifdef CONFIG_PRINTK
80237 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
80238 void __user *buffer, size_t *lenp, loff_t *ppos);
80239 -#endif
80240
80241 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
80242 void __user *buffer, size_t *lenp, loff_t *ppos);
80243 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
80244
80245 #endif
80246
80247 +extern struct ctl_table grsecurity_table[];
80248 +
80249 static struct ctl_table kern_table[];
80250 static struct ctl_table vm_table[];
80251 static struct ctl_table fs_table[];
80252 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
80253 int sysctl_legacy_va_layout;
80254 #endif
80255
80256 +#ifdef CONFIG_PAX_SOFTMODE
80257 +static ctl_table pax_table[] = {
80258 + {
80259 + .procname = "softmode",
80260 + .data = &pax_softmode,
80261 + .maxlen = sizeof(unsigned int),
80262 + .mode = 0600,
80263 + .proc_handler = &proc_dointvec,
80264 + },
80265 +
80266 + { }
80267 +};
80268 +#endif
80269 +
80270 /* The default sysctl tables: */
80271
80272 static struct ctl_table sysctl_base_table[] = {
80273 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
80274 #endif
80275
80276 static struct ctl_table kern_table[] = {
80277 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
80278 + {
80279 + .procname = "grsecurity",
80280 + .mode = 0500,
80281 + .child = grsecurity_table,
80282 + },
80283 +#endif
80284 +
80285 +#ifdef CONFIG_PAX_SOFTMODE
80286 + {
80287 + .procname = "pax",
80288 + .mode = 0500,
80289 + .child = pax_table,
80290 + },
80291 +#endif
80292 +
80293 {
80294 .procname = "sched_child_runs_first",
80295 .data = &sysctl_sched_child_runs_first,
80296 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
80297 .data = &modprobe_path,
80298 .maxlen = KMOD_PATH_LEN,
80299 .mode = 0644,
80300 - .proc_handler = proc_dostring,
80301 + .proc_handler = proc_dostring_modpriv,
80302 },
80303 {
80304 .procname = "modules_disabled",
80305 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
80306 .extra1 = &zero,
80307 .extra2 = &one,
80308 },
80309 +#endif
80310 {
80311 .procname = "kptr_restrict",
80312 .data = &kptr_restrict,
80313 .maxlen = sizeof(int),
80314 .mode = 0644,
80315 .proc_handler = proc_dointvec_minmax_sysadmin,
80316 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80317 + .extra1 = &two,
80318 +#else
80319 .extra1 = &zero,
80320 +#endif
80321 .extra2 = &two,
80322 },
80323 -#endif
80324 {
80325 .procname = "ngroups_max",
80326 .data = &ngroups_max,
80327 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
80328 */
80329 {
80330 .procname = "perf_event_paranoid",
80331 - .data = &sysctl_perf_event_paranoid,
80332 - .maxlen = sizeof(sysctl_perf_event_paranoid),
80333 + .data = &sysctl_perf_event_legitimately_concerned,
80334 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
80335 .mode = 0644,
80336 - .proc_handler = proc_dointvec,
80337 + /* go ahead, be a hero */
80338 + .proc_handler = proc_dointvec_minmax_sysadmin,
80339 + .extra1 = &neg_one,
80340 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80341 + .extra2 = &three,
80342 +#else
80343 + .extra2 = &two,
80344 +#endif
80345 },
80346 {
80347 .procname = "perf_event_mlock_kb",
80348 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
80349 .proc_handler = proc_dointvec_minmax,
80350 .extra1 = &zero,
80351 },
80352 + {
80353 + .procname = "heap_stack_gap",
80354 + .data = &sysctl_heap_stack_gap,
80355 + .maxlen = sizeof(sysctl_heap_stack_gap),
80356 + .mode = 0644,
80357 + .proc_handler = proc_doulongvec_minmax,
80358 + },
80359 #else
80360 {
80361 .procname = "nr_trim_pages",
80362 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
80363 buffer, lenp, ppos);
80364 }
80365
80366 +int proc_dostring_modpriv(struct ctl_table *table, int write,
80367 + void __user *buffer, size_t *lenp, loff_t *ppos)
80368 +{
80369 + if (write && !capable(CAP_SYS_MODULE))
80370 + return -EPERM;
80371 +
80372 + return _proc_do_string(table->data, table->maxlen, write,
80373 + buffer, lenp, ppos);
80374 +}
80375 +
80376 static size_t proc_skip_spaces(char **buf)
80377 {
80378 size_t ret;
80379 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
80380 len = strlen(tmp);
80381 if (len > *size)
80382 len = *size;
80383 + if (len > sizeof(tmp))
80384 + len = sizeof(tmp);
80385 if (copy_to_user(*buf, tmp, len))
80386 return -EFAULT;
80387 *size -= len;
80388 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
80389 static int proc_taint(struct ctl_table *table, int write,
80390 void __user *buffer, size_t *lenp, loff_t *ppos)
80391 {
80392 - struct ctl_table t;
80393 + ctl_table_no_const t;
80394 unsigned long tmptaint = get_taint();
80395 int err;
80396
80397 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
80398 return err;
80399 }
80400
80401 -#ifdef CONFIG_PRINTK
80402 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
80403 void __user *buffer, size_t *lenp, loff_t *ppos)
80404 {
80405 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
80406
80407 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
80408 }
80409 -#endif
80410
80411 struct do_proc_dointvec_minmax_conv_param {
80412 int *min;
80413 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
80414 *i = val;
80415 } else {
80416 val = convdiv * (*i) / convmul;
80417 - if (!first)
80418 + if (!first) {
80419 err = proc_put_char(&buffer, &left, '\t');
80420 + if (err)
80421 + break;
80422 + }
80423 err = proc_put_long(&buffer, &left, val, false);
80424 if (err)
80425 break;
80426 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
80427 return -ENOSYS;
80428 }
80429
80430 +int proc_dostring_modpriv(struct ctl_table *table, int write,
80431 + void __user *buffer, size_t *lenp, loff_t *ppos)
80432 +{
80433 + return -ENOSYS;
80434 +}
80435 +
80436 int proc_dointvec(struct ctl_table *table, int write,
80437 void __user *buffer, size_t *lenp, loff_t *ppos)
80438 {
80439 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
80440 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
80441 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
80442 EXPORT_SYMBOL(proc_dostring);
80443 +EXPORT_SYMBOL(proc_dostring_modpriv);
80444 EXPORT_SYMBOL(proc_doulongvec_minmax);
80445 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
80446 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
80447 index 145bb4d..b2aa969 100644
80448 --- a/kernel/taskstats.c
80449 +++ b/kernel/taskstats.c
80450 @@ -28,9 +28,12 @@
80451 #include <linux/fs.h>
80452 #include <linux/file.h>
80453 #include <linux/pid_namespace.h>
80454 +#include <linux/grsecurity.h>
80455 #include <net/genetlink.h>
80456 #include <linux/atomic.h>
80457
80458 +extern int gr_is_taskstats_denied(int pid);
80459 +
80460 /*
80461 * Maximum length of a cpumask that can be specified in
80462 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
80463 @@ -570,6 +573,9 @@ err:
80464
80465 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
80466 {
80467 + if (gr_is_taskstats_denied(current->pid))
80468 + return -EACCES;
80469 +
80470 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
80471 return cmd_attr_register_cpumask(info);
80472 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
80473 diff --git a/kernel/time.c b/kernel/time.c
80474 index d3617db..c98bbe9 100644
80475 --- a/kernel/time.c
80476 +++ b/kernel/time.c
80477 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
80478 return error;
80479
80480 if (tz) {
80481 + /* we log in do_settimeofday called below, so don't log twice
80482 + */
80483 + if (!tv)
80484 + gr_log_timechange();
80485 +
80486 sys_tz = *tz;
80487 update_vsyscall_tz();
80488 if (firsttime) {
80489 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
80490 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
80491 * value to a scaled second value.
80492 */
80493 -unsigned long
80494 +unsigned long __intentional_overflow(-1)
80495 timespec_to_jiffies(const struct timespec *value)
80496 {
80497 unsigned long sec = value->tv_sec;
80498 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
80499 index f11d83b..d016d91 100644
80500 --- a/kernel/time/alarmtimer.c
80501 +++ b/kernel/time/alarmtimer.c
80502 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
80503 struct platform_device *pdev;
80504 int error = 0;
80505 int i;
80506 - struct k_clock alarm_clock = {
80507 + static struct k_clock alarm_clock = {
80508 .clock_getres = alarm_clock_getres,
80509 .clock_get = alarm_clock_get,
80510 .timer_create = alarm_timer_create,
80511 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
80512 index baeeb5c..c22704a 100644
80513 --- a/kernel/time/timekeeping.c
80514 +++ b/kernel/time/timekeeping.c
80515 @@ -15,6 +15,7 @@
80516 #include <linux/init.h>
80517 #include <linux/mm.h>
80518 #include <linux/sched.h>
80519 +#include <linux/grsecurity.h>
80520 #include <linux/syscore_ops.h>
80521 #include <linux/clocksource.h>
80522 #include <linux/jiffies.h>
80523 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
80524 if (!timespec_valid_strict(tv))
80525 return -EINVAL;
80526
80527 + gr_log_timechange();
80528 +
80529 raw_spin_lock_irqsave(&timekeeper_lock, flags);
80530 write_seqcount_begin(&timekeeper_seq);
80531
80532 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
80533 index 3bdf283..cc68d83 100644
80534 --- a/kernel/time/timer_list.c
80535 +++ b/kernel/time/timer_list.c
80536 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
80537
80538 static void print_name_offset(struct seq_file *m, void *sym)
80539 {
80540 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80541 + SEQ_printf(m, "<%p>", NULL);
80542 +#else
80543 char symname[KSYM_NAME_LEN];
80544
80545 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
80546 SEQ_printf(m, "<%pK>", sym);
80547 else
80548 SEQ_printf(m, "%s", symname);
80549 +#endif
80550 }
80551
80552 static void
80553 @@ -119,7 +123,11 @@ next_one:
80554 static void
80555 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
80556 {
80557 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80558 + SEQ_printf(m, " .base: %p\n", NULL);
80559 +#else
80560 SEQ_printf(m, " .base: %pK\n", base);
80561 +#endif
80562 SEQ_printf(m, " .index: %d\n",
80563 base->index);
80564 SEQ_printf(m, " .resolution: %Lu nsecs\n",
80565 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
80566 {
80567 struct proc_dir_entry *pe;
80568
80569 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
80570 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
80571 +#else
80572 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
80573 +#endif
80574 if (!pe)
80575 return -ENOMEM;
80576 return 0;
80577 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
80578 index 0b537f2..40d6c20 100644
80579 --- a/kernel/time/timer_stats.c
80580 +++ b/kernel/time/timer_stats.c
80581 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
80582 static unsigned long nr_entries;
80583 static struct entry entries[MAX_ENTRIES];
80584
80585 -static atomic_t overflow_count;
80586 +static atomic_unchecked_t overflow_count;
80587
80588 /*
80589 * The entries are in a hash-table, for fast lookup:
80590 @@ -140,7 +140,7 @@ static void reset_entries(void)
80591 nr_entries = 0;
80592 memset(entries, 0, sizeof(entries));
80593 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
80594 - atomic_set(&overflow_count, 0);
80595 + atomic_set_unchecked(&overflow_count, 0);
80596 }
80597
80598 static struct entry *alloc_entry(void)
80599 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
80600 if (likely(entry))
80601 entry->count++;
80602 else
80603 - atomic_inc(&overflow_count);
80604 + atomic_inc_unchecked(&overflow_count);
80605
80606 out_unlock:
80607 raw_spin_unlock_irqrestore(lock, flags);
80608 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
80609
80610 static void print_name_offset(struct seq_file *m, unsigned long addr)
80611 {
80612 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80613 + seq_printf(m, "<%p>", NULL);
80614 +#else
80615 char symname[KSYM_NAME_LEN];
80616
80617 if (lookup_symbol_name(addr, symname) < 0)
80618 - seq_printf(m, "<%p>", (void *)addr);
80619 + seq_printf(m, "<%pK>", (void *)addr);
80620 else
80621 seq_printf(m, "%s", symname);
80622 +#endif
80623 }
80624
80625 static int tstats_show(struct seq_file *m, void *v)
80626 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
80627
80628 seq_puts(m, "Timer Stats Version: v0.2\n");
80629 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
80630 - if (atomic_read(&overflow_count))
80631 + if (atomic_read_unchecked(&overflow_count))
80632 seq_printf(m, "Overflow: %d entries\n",
80633 - atomic_read(&overflow_count));
80634 + atomic_read_unchecked(&overflow_count));
80635
80636 for (i = 0; i < nr_entries; i++) {
80637 entry = entries + i;
80638 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
80639 {
80640 struct proc_dir_entry *pe;
80641
80642 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
80643 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
80644 +#else
80645 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
80646 +#endif
80647 if (!pe)
80648 return -ENOMEM;
80649 return 0;
80650 diff --git a/kernel/timer.c b/kernel/timer.c
80651 index 15bc1b4..32da49c 100644
80652 --- a/kernel/timer.c
80653 +++ b/kernel/timer.c
80654 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
80655 /*
80656 * This function runs timers and the timer-tq in bottom half context.
80657 */
80658 -static void run_timer_softirq(struct softirq_action *h)
80659 +static void run_timer_softirq(void)
80660 {
80661 struct tvec_base *base = __this_cpu_read(tvec_bases);
80662
80663 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
80664 *
80665 * In all cases the return value is guaranteed to be non-negative.
80666 */
80667 -signed long __sched schedule_timeout(signed long timeout)
80668 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
80669 {
80670 struct timer_list timer;
80671 unsigned long expire;
80672 @@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
80673 return NOTIFY_OK;
80674 }
80675
80676 -static struct notifier_block __cpuinitdata timers_nb = {
80677 +static struct notifier_block timers_nb = {
80678 .notifier_call = timer_cpu_notify,
80679 };
80680
80681 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
80682 index b8b8560..75b1a09 100644
80683 --- a/kernel/trace/blktrace.c
80684 +++ b/kernel/trace/blktrace.c
80685 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
80686 struct blk_trace *bt = filp->private_data;
80687 char buf[16];
80688
80689 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
80690 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
80691
80692 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
80693 }
80694 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
80695 return 1;
80696
80697 bt = buf->chan->private_data;
80698 - atomic_inc(&bt->dropped);
80699 + atomic_inc_unchecked(&bt->dropped);
80700 return 0;
80701 }
80702
80703 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
80704
80705 bt->dir = dir;
80706 bt->dev = dev;
80707 - atomic_set(&bt->dropped, 0);
80708 + atomic_set_unchecked(&bt->dropped, 0);
80709
80710 ret = -EIO;
80711 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
80712 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
80713 index 6c508ff..ee55a13 100644
80714 --- a/kernel/trace/ftrace.c
80715 +++ b/kernel/trace/ftrace.c
80716 @@ -1915,12 +1915,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
80717 if (unlikely(ftrace_disabled))
80718 return 0;
80719
80720 + ret = ftrace_arch_code_modify_prepare();
80721 + FTRACE_WARN_ON(ret);
80722 + if (ret)
80723 + return 0;
80724 +
80725 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
80726 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
80727 if (ret) {
80728 ftrace_bug(ret, ip);
80729 - return 0;
80730 }
80731 - return 1;
80732 + return ret ? 0 : 1;
80733 }
80734
80735 /*
80736 @@ -3931,8 +3936,10 @@ static int ftrace_process_locs(struct module *mod,
80737 if (!count)
80738 return 0;
80739
80740 + pax_open_kernel();
80741 sort(start, count, sizeof(*start),
80742 ftrace_cmp_ips, ftrace_swap_ips);
80743 + pax_close_kernel();
80744
80745 start_pg = ftrace_allocate_pages(count);
80746 if (!start_pg)
80747 @@ -4655,8 +4662,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
80748 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
80749
80750 static int ftrace_graph_active;
80751 -static struct notifier_block ftrace_suspend_notifier;
80752 -
80753 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
80754 {
80755 return 0;
80756 @@ -4800,6 +4805,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
80757 return NOTIFY_DONE;
80758 }
80759
80760 +static struct notifier_block ftrace_suspend_notifier = {
80761 + .notifier_call = ftrace_suspend_notifier_call
80762 +};
80763 +
80764 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
80765 trace_func_graph_ent_t entryfunc)
80766 {
80767 @@ -4813,7 +4822,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
80768 goto out;
80769 }
80770
80771 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
80772 register_pm_notifier(&ftrace_suspend_notifier);
80773
80774 ftrace_graph_active++;
80775 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
80776 index e444ff8..438b8f4 100644
80777 --- a/kernel/trace/ring_buffer.c
80778 +++ b/kernel/trace/ring_buffer.c
80779 @@ -352,9 +352,9 @@ struct buffer_data_page {
80780 */
80781 struct buffer_page {
80782 struct list_head list; /* list of buffer pages */
80783 - local_t write; /* index for next write */
80784 + local_unchecked_t write; /* index for next write */
80785 unsigned read; /* index for next read */
80786 - local_t entries; /* entries on this page */
80787 + local_unchecked_t entries; /* entries on this page */
80788 unsigned long real_end; /* real end of data */
80789 struct buffer_data_page *page; /* Actual data page */
80790 };
80791 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
80792 unsigned long last_overrun;
80793 local_t entries_bytes;
80794 local_t entries;
80795 - local_t overrun;
80796 - local_t commit_overrun;
80797 + local_unchecked_t overrun;
80798 + local_unchecked_t commit_overrun;
80799 local_t dropped_events;
80800 local_t committing;
80801 local_t commits;
80802 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80803 *
80804 * We add a counter to the write field to denote this.
80805 */
80806 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
80807 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
80808 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
80809 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
80810
80811 /*
80812 * Just make sure we have seen our old_write and synchronize
80813 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80814 * cmpxchg to only update if an interrupt did not already
80815 * do it for us. If the cmpxchg fails, we don't care.
80816 */
80817 - (void)local_cmpxchg(&next_page->write, old_write, val);
80818 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
80819 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
80820 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
80821
80822 /*
80823 * No need to worry about races with clearing out the commit.
80824 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
80825
80826 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
80827 {
80828 - return local_read(&bpage->entries) & RB_WRITE_MASK;
80829 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
80830 }
80831
80832 static inline unsigned long rb_page_write(struct buffer_page *bpage)
80833 {
80834 - return local_read(&bpage->write) & RB_WRITE_MASK;
80835 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
80836 }
80837
80838 static int
80839 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
80840 * bytes consumed in ring buffer from here.
80841 * Increment overrun to account for the lost events.
80842 */
80843 - local_add(page_entries, &cpu_buffer->overrun);
80844 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
80845 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80846 }
80847
80848 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
80849 * it is our responsibility to update
80850 * the counters.
80851 */
80852 - local_add(entries, &cpu_buffer->overrun);
80853 + local_add_unchecked(entries, &cpu_buffer->overrun);
80854 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80855
80856 /*
80857 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80858 if (tail == BUF_PAGE_SIZE)
80859 tail_page->real_end = 0;
80860
80861 - local_sub(length, &tail_page->write);
80862 + local_sub_unchecked(length, &tail_page->write);
80863 return;
80864 }
80865
80866 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80867 rb_event_set_padding(event);
80868
80869 /* Set the write back to the previous setting */
80870 - local_sub(length, &tail_page->write);
80871 + local_sub_unchecked(length, &tail_page->write);
80872 return;
80873 }
80874
80875 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80876
80877 /* Set write to end of buffer */
80878 length = (tail + length) - BUF_PAGE_SIZE;
80879 - local_sub(length, &tail_page->write);
80880 + local_sub_unchecked(length, &tail_page->write);
80881 }
80882
80883 /*
80884 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80885 * about it.
80886 */
80887 if (unlikely(next_page == commit_page)) {
80888 - local_inc(&cpu_buffer->commit_overrun);
80889 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80890 goto out_reset;
80891 }
80892
80893 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80894 cpu_buffer->tail_page) &&
80895 (cpu_buffer->commit_page ==
80896 cpu_buffer->reader_page))) {
80897 - local_inc(&cpu_buffer->commit_overrun);
80898 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80899 goto out_reset;
80900 }
80901 }
80902 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80903 length += RB_LEN_TIME_EXTEND;
80904
80905 tail_page = cpu_buffer->tail_page;
80906 - write = local_add_return(length, &tail_page->write);
80907 + write = local_add_return_unchecked(length, &tail_page->write);
80908
80909 /* set write to only the index of the write */
80910 write &= RB_WRITE_MASK;
80911 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80912 kmemcheck_annotate_bitfield(event, bitfield);
80913 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
80914
80915 - local_inc(&tail_page->entries);
80916 + local_inc_unchecked(&tail_page->entries);
80917
80918 /*
80919 * If this is the first commit on the page, then update
80920 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80921
80922 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
80923 unsigned long write_mask =
80924 - local_read(&bpage->write) & ~RB_WRITE_MASK;
80925 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
80926 unsigned long event_length = rb_event_length(event);
80927 /*
80928 * This is on the tail page. It is possible that
80929 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80930 */
80931 old_index += write_mask;
80932 new_index += write_mask;
80933 - index = local_cmpxchg(&bpage->write, old_index, new_index);
80934 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
80935 if (index == old_index) {
80936 /* update counters */
80937 local_sub(event_length, &cpu_buffer->entries_bytes);
80938 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80939
80940 /* Do the likely case first */
80941 if (likely(bpage->page == (void *)addr)) {
80942 - local_dec(&bpage->entries);
80943 + local_dec_unchecked(&bpage->entries);
80944 return;
80945 }
80946
80947 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80948 start = bpage;
80949 do {
80950 if (bpage->page == (void *)addr) {
80951 - local_dec(&bpage->entries);
80952 + local_dec_unchecked(&bpage->entries);
80953 return;
80954 }
80955 rb_inc_page(cpu_buffer, &bpage);
80956 @@ -3138,7 +3138,7 @@ static inline unsigned long
80957 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
80958 {
80959 return local_read(&cpu_buffer->entries) -
80960 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
80961 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
80962 }
80963
80964 /**
80965 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
80966 return 0;
80967
80968 cpu_buffer = buffer->buffers[cpu];
80969 - ret = local_read(&cpu_buffer->overrun);
80970 + ret = local_read_unchecked(&cpu_buffer->overrun);
80971
80972 return ret;
80973 }
80974 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
80975 return 0;
80976
80977 cpu_buffer = buffer->buffers[cpu];
80978 - ret = local_read(&cpu_buffer->commit_overrun);
80979 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
80980
80981 return ret;
80982 }
80983 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
80984 /* if you care about this being correct, lock the buffer */
80985 for_each_buffer_cpu(buffer, cpu) {
80986 cpu_buffer = buffer->buffers[cpu];
80987 - overruns += local_read(&cpu_buffer->overrun);
80988 + overruns += local_read_unchecked(&cpu_buffer->overrun);
80989 }
80990
80991 return overruns;
80992 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80993 /*
80994 * Reset the reader page to size zero.
80995 */
80996 - local_set(&cpu_buffer->reader_page->write, 0);
80997 - local_set(&cpu_buffer->reader_page->entries, 0);
80998 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80999 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
81000 local_set(&cpu_buffer->reader_page->page->commit, 0);
81001 cpu_buffer->reader_page->real_end = 0;
81002
81003 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
81004 * want to compare with the last_overrun.
81005 */
81006 smp_mb();
81007 - overwrite = local_read(&(cpu_buffer->overrun));
81008 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
81009
81010 /*
81011 * Here's the tricky part.
81012 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
81013
81014 cpu_buffer->head_page
81015 = list_entry(cpu_buffer->pages, struct buffer_page, list);
81016 - local_set(&cpu_buffer->head_page->write, 0);
81017 - local_set(&cpu_buffer->head_page->entries, 0);
81018 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
81019 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
81020 local_set(&cpu_buffer->head_page->page->commit, 0);
81021
81022 cpu_buffer->head_page->read = 0;
81023 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
81024
81025 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
81026 INIT_LIST_HEAD(&cpu_buffer->new_pages);
81027 - local_set(&cpu_buffer->reader_page->write, 0);
81028 - local_set(&cpu_buffer->reader_page->entries, 0);
81029 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
81030 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
81031 local_set(&cpu_buffer->reader_page->page->commit, 0);
81032 cpu_buffer->reader_page->read = 0;
81033
81034 local_set(&cpu_buffer->entries_bytes, 0);
81035 - local_set(&cpu_buffer->overrun, 0);
81036 - local_set(&cpu_buffer->commit_overrun, 0);
81037 + local_set_unchecked(&cpu_buffer->overrun, 0);
81038 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
81039 local_set(&cpu_buffer->dropped_events, 0);
81040 local_set(&cpu_buffer->entries, 0);
81041 local_set(&cpu_buffer->committing, 0);
81042 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
81043 rb_init_page(bpage);
81044 bpage = reader->page;
81045 reader->page = *data_page;
81046 - local_set(&reader->write, 0);
81047 - local_set(&reader->entries, 0);
81048 + local_set_unchecked(&reader->write, 0);
81049 + local_set_unchecked(&reader->entries, 0);
81050 reader->read = 0;
81051 *data_page = bpage;
81052
81053 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
81054 index 0b936d8..306a7eb 100644
81055 --- a/kernel/trace/trace.c
81056 +++ b/kernel/trace/trace.c
81057 @@ -3302,7 +3302,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
81058 return 0;
81059 }
81060
81061 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
81062 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
81063 {
81064 /* do nothing if flag is already set */
81065 if (!!(trace_flags & mask) == !!enabled)
81066 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
81067 index 51b4448..7be601f 100644
81068 --- a/kernel/trace/trace.h
81069 +++ b/kernel/trace/trace.h
81070 @@ -1035,7 +1035,7 @@ extern const char *__stop___trace_bprintk_fmt[];
81071 void trace_printk_init_buffers(void);
81072 void trace_printk_start_comm(void);
81073 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
81074 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
81075 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
81076
81077 /*
81078 * Normal trace_printk() and friends allocates special buffers
81079 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
81080 index 6dfd48b..a6d88d0 100644
81081 --- a/kernel/trace/trace_events.c
81082 +++ b/kernel/trace/trace_events.c
81083 @@ -1731,10 +1731,6 @@ static LIST_HEAD(ftrace_module_file_list);
81084 struct ftrace_module_file_ops {
81085 struct list_head list;
81086 struct module *mod;
81087 - struct file_operations id;
81088 - struct file_operations enable;
81089 - struct file_operations format;
81090 - struct file_operations filter;
81091 };
81092
81093 static struct ftrace_module_file_ops *
81094 @@ -1775,17 +1771,12 @@ trace_create_file_ops(struct module *mod)
81095
81096 file_ops->mod = mod;
81097
81098 - file_ops->id = ftrace_event_id_fops;
81099 - file_ops->id.owner = mod;
81100 -
81101 - file_ops->enable = ftrace_enable_fops;
81102 - file_ops->enable.owner = mod;
81103 -
81104 - file_ops->filter = ftrace_event_filter_fops;
81105 - file_ops->filter.owner = mod;
81106 -
81107 - file_ops->format = ftrace_event_format_fops;
81108 - file_ops->format.owner = mod;
81109 + pax_open_kernel();
81110 + mod->trace_id.owner = mod;
81111 + mod->trace_enable.owner = mod;
81112 + mod->trace_filter.owner = mod;
81113 + mod->trace_format.owner = mod;
81114 + pax_close_kernel();
81115
81116 list_add(&file_ops->list, &ftrace_module_file_list);
81117
81118 @@ -1878,8 +1869,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
81119 struct ftrace_module_file_ops *file_ops)
81120 {
81121 return __trace_add_new_event(call, tr,
81122 - &file_ops->id, &file_ops->enable,
81123 - &file_ops->filter, &file_ops->format);
81124 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
81125 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
81126 }
81127
81128 #else
81129 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
81130 index a5e8f48..a9690d2 100644
81131 --- a/kernel/trace/trace_mmiotrace.c
81132 +++ b/kernel/trace/trace_mmiotrace.c
81133 @@ -24,7 +24,7 @@ struct header_iter {
81134 static struct trace_array *mmio_trace_array;
81135 static bool overrun_detected;
81136 static unsigned long prev_overruns;
81137 -static atomic_t dropped_count;
81138 +static atomic_unchecked_t dropped_count;
81139
81140 static void mmio_reset_data(struct trace_array *tr)
81141 {
81142 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
81143
81144 static unsigned long count_overruns(struct trace_iterator *iter)
81145 {
81146 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
81147 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
81148 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
81149
81150 if (over > prev_overruns)
81151 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
81152 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
81153 sizeof(*entry), 0, pc);
81154 if (!event) {
81155 - atomic_inc(&dropped_count);
81156 + atomic_inc_unchecked(&dropped_count);
81157 return;
81158 }
81159 entry = ring_buffer_event_data(event);
81160 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
81161 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
81162 sizeof(*entry), 0, pc);
81163 if (!event) {
81164 - atomic_inc(&dropped_count);
81165 + atomic_inc_unchecked(&dropped_count);
81166 return;
81167 }
81168 entry = ring_buffer_event_data(event);
81169 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
81170 index bb922d9..2a54a257 100644
81171 --- a/kernel/trace/trace_output.c
81172 +++ b/kernel/trace/trace_output.c
81173 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
81174
81175 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
81176 if (!IS_ERR(p)) {
81177 - p = mangle_path(s->buffer + s->len, p, "\n");
81178 + p = mangle_path(s->buffer + s->len, p, "\n\\");
81179 if (p) {
81180 s->len = p - s->buffer;
81181 return 1;
81182 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
81183 goto out;
81184 }
81185
81186 + pax_open_kernel();
81187 if (event->funcs->trace == NULL)
81188 - event->funcs->trace = trace_nop_print;
81189 + *(void **)&event->funcs->trace = trace_nop_print;
81190 if (event->funcs->raw == NULL)
81191 - event->funcs->raw = trace_nop_print;
81192 + *(void **)&event->funcs->raw = trace_nop_print;
81193 if (event->funcs->hex == NULL)
81194 - event->funcs->hex = trace_nop_print;
81195 + *(void **)&event->funcs->hex = trace_nop_print;
81196 if (event->funcs->binary == NULL)
81197 - event->funcs->binary = trace_nop_print;
81198 + *(void **)&event->funcs->binary = trace_nop_print;
81199 + pax_close_kernel();
81200
81201 key = event->type & (EVENT_HASHSIZE - 1);
81202
81203 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
81204 index b20428c..4845a10 100644
81205 --- a/kernel/trace/trace_stack.c
81206 +++ b/kernel/trace/trace_stack.c
81207 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
81208 return;
81209
81210 /* we do not handle interrupt stacks yet */
81211 - if (!object_is_on_stack(stack))
81212 + if (!object_starts_on_stack(stack))
81213 return;
81214
81215 local_irq_save(flags);
81216 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
81217 index d8c30db..e065e89 100644
81218 --- a/kernel/user_namespace.c
81219 +++ b/kernel/user_namespace.c
81220 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
81221 if (atomic_read(&current->mm->mm_users) > 1)
81222 return -EINVAL;
81223
81224 - if (current->fs->users != 1)
81225 + if (atomic_read(&current->fs->users) != 1)
81226 return -EINVAL;
81227
81228 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
81229 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
81230 index 4f69f9a..7c6f8f8 100644
81231 --- a/kernel/utsname_sysctl.c
81232 +++ b/kernel/utsname_sysctl.c
81233 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
81234 static int proc_do_uts_string(ctl_table *table, int write,
81235 void __user *buffer, size_t *lenp, loff_t *ppos)
81236 {
81237 - struct ctl_table uts_table;
81238 + ctl_table_no_const uts_table;
81239 int r;
81240 memcpy(&uts_table, table, sizeof(uts_table));
81241 uts_table.data = get_uts(table, write);
81242 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
81243 index 05039e3..17490c7 100644
81244 --- a/kernel/watchdog.c
81245 +++ b/kernel/watchdog.c
81246 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
81247 }
81248 #endif /* CONFIG_SYSCTL */
81249
81250 -static struct smp_hotplug_thread watchdog_threads = {
81251 +static struct smp_hotplug_thread watchdog_threads __read_only = {
81252 .store = &softlockup_watchdog,
81253 .thread_should_run = watchdog_should_run,
81254 .thread_fn = watchdog,
81255 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
81256 index ee8e29a..410568e 100644
81257 --- a/kernel/workqueue.c
81258 +++ b/kernel/workqueue.c
81259 @@ -4584,7 +4584,7 @@ static void rebind_workers(struct worker_pool *pool)
81260 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
81261 worker_flags |= WORKER_REBOUND;
81262 worker_flags &= ~WORKER_UNBOUND;
81263 - ACCESS_ONCE(worker->flags) = worker_flags;
81264 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
81265 }
81266
81267 spin_unlock_irq(&pool->lock);
81268 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
81269 index 74fdc5c..3310593 100644
81270 --- a/lib/Kconfig.debug
81271 +++ b/lib/Kconfig.debug
81272 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
81273
81274 config DEBUG_LOCK_ALLOC
81275 bool "Lock debugging: detect incorrect freeing of live locks"
81276 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
81277 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
81278 select DEBUG_SPINLOCK
81279 select DEBUG_MUTEXES
81280 select LOCKDEP
81281 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
81282
81283 config PROVE_LOCKING
81284 bool "Lock debugging: prove locking correctness"
81285 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
81286 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
81287 select LOCKDEP
81288 select DEBUG_SPINLOCK
81289 select DEBUG_MUTEXES
81290 @@ -614,7 +614,7 @@ config LOCKDEP
81291
81292 config LOCK_STAT
81293 bool "Lock usage statistics"
81294 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
81295 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
81296 select LOCKDEP
81297 select DEBUG_SPINLOCK
81298 select DEBUG_MUTEXES
81299 @@ -1282,6 +1282,7 @@ config LATENCYTOP
81300 depends on DEBUG_KERNEL
81301 depends on STACKTRACE_SUPPORT
81302 depends on PROC_FS
81303 + depends on !GRKERNSEC_HIDESYM
81304 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
81305 select KALLSYMS
81306 select KALLSYMS_ALL
81307 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
81308 config DEBUG_STRICT_USER_COPY_CHECKS
81309 bool "Strict user copy size checks"
81310 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
81311 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
81312 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
81313 help
81314 Enabling this option turns a certain set of sanity checks for user
81315 copy operations into compile time failures.
81316 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
81317
81318 config PROVIDE_OHCI1394_DMA_INIT
81319 bool "Remote debugging over FireWire early on boot"
81320 - depends on PCI && X86
81321 + depends on PCI && X86 && !GRKERNSEC
81322 help
81323 If you want to debug problems which hang or crash the kernel early
81324 on boot and the crashing machine has a FireWire port, you can use
81325 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
81326
81327 config FIREWIRE_OHCI_REMOTE_DMA
81328 bool "Remote debugging over FireWire with firewire-ohci"
81329 - depends on FIREWIRE_OHCI
81330 + depends on FIREWIRE_OHCI && !GRKERNSEC
81331 help
81332 This option lets you use the FireWire bus for remote debugging
81333 with help of the firewire-ohci driver. It enables unfiltered
81334 diff --git a/lib/Makefile b/lib/Makefile
81335 index c55a037..fb46e3b 100644
81336 --- a/lib/Makefile
81337 +++ b/lib/Makefile
81338 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
81339
81340 obj-$(CONFIG_BTREE) += btree.o
81341 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
81342 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
81343 +obj-y += list_debug.o
81344 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
81345
81346 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
81347 diff --git a/lib/bitmap.c b/lib/bitmap.c
81348 index 06f7e4f..f3cf2b0 100644
81349 --- a/lib/bitmap.c
81350 +++ b/lib/bitmap.c
81351 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
81352 {
81353 int c, old_c, totaldigits, ndigits, nchunks, nbits;
81354 u32 chunk;
81355 - const char __user __force *ubuf = (const char __user __force *)buf;
81356 + const char __user *ubuf = (const char __force_user *)buf;
81357
81358 bitmap_zero(maskp, nmaskbits);
81359
81360 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
81361 {
81362 if (!access_ok(VERIFY_READ, ubuf, ulen))
81363 return -EFAULT;
81364 - return __bitmap_parse((const char __force *)ubuf,
81365 + return __bitmap_parse((const char __force_kernel *)ubuf,
81366 ulen, 1, maskp, nmaskbits);
81367
81368 }
81369 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
81370 {
81371 unsigned a, b;
81372 int c, old_c, totaldigits;
81373 - const char __user __force *ubuf = (const char __user __force *)buf;
81374 + const char __user *ubuf = (const char __force_user *)buf;
81375 int exp_digit, in_range;
81376
81377 totaldigits = c = 0;
81378 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
81379 {
81380 if (!access_ok(VERIFY_READ, ubuf, ulen))
81381 return -EFAULT;
81382 - return __bitmap_parselist((const char __force *)ubuf,
81383 + return __bitmap_parselist((const char __force_kernel *)ubuf,
81384 ulen, 1, maskp, nmaskbits);
81385 }
81386 EXPORT_SYMBOL(bitmap_parselist_user);
81387 diff --git a/lib/bug.c b/lib/bug.c
81388 index 1686034..a9c00c8 100644
81389 --- a/lib/bug.c
81390 +++ b/lib/bug.c
81391 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
81392 return BUG_TRAP_TYPE_NONE;
81393
81394 bug = find_bug(bugaddr);
81395 + if (!bug)
81396 + return BUG_TRAP_TYPE_NONE;
81397
81398 file = NULL;
81399 line = 0;
81400 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
81401 index 37061ed..da83f48 100644
81402 --- a/lib/debugobjects.c
81403 +++ b/lib/debugobjects.c
81404 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
81405 if (limit > 4)
81406 return;
81407
81408 - is_on_stack = object_is_on_stack(addr);
81409 + is_on_stack = object_starts_on_stack(addr);
81410 if (is_on_stack == onstack)
81411 return;
81412
81413 diff --git a/lib/devres.c b/lib/devres.c
81414 index 8235331..5881053 100644
81415 --- a/lib/devres.c
81416 +++ b/lib/devres.c
81417 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
81418 void devm_iounmap(struct device *dev, void __iomem *addr)
81419 {
81420 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
81421 - (void *)addr));
81422 + (void __force *)addr));
81423 iounmap(addr);
81424 }
81425 EXPORT_SYMBOL(devm_iounmap);
81426 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
81427 {
81428 ioport_unmap(addr);
81429 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
81430 - devm_ioport_map_match, (void *)addr));
81431 + devm_ioport_map_match, (void __force *)addr));
81432 }
81433 EXPORT_SYMBOL(devm_ioport_unmap);
81434 #endif /* CONFIG_HAS_IOPORT */
81435 diff --git a/lib/div64.c b/lib/div64.c
81436 index a163b6c..9618fa5 100644
81437 --- a/lib/div64.c
81438 +++ b/lib/div64.c
81439 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
81440 EXPORT_SYMBOL(__div64_32);
81441
81442 #ifndef div_s64_rem
81443 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
81444 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
81445 {
81446 u64 quotient;
81447
81448 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
81449 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
81450 */
81451 #ifndef div64_u64
81452 -u64 div64_u64(u64 dividend, u64 divisor)
81453 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
81454 {
81455 u32 high = divisor >> 32;
81456 u64 quot;
81457 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
81458 index d87a17a..ac0d79a 100644
81459 --- a/lib/dma-debug.c
81460 +++ b/lib/dma-debug.c
81461 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
81462
81463 void dma_debug_add_bus(struct bus_type *bus)
81464 {
81465 - struct notifier_block *nb;
81466 + notifier_block_no_const *nb;
81467
81468 if (global_disable)
81469 return;
81470 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
81471
81472 static void check_for_stack(struct device *dev, void *addr)
81473 {
81474 - if (object_is_on_stack(addr))
81475 + if (object_starts_on_stack(addr))
81476 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
81477 "stack [addr=%p]\n", addr);
81478 }
81479 diff --git a/lib/inflate.c b/lib/inflate.c
81480 index 013a761..c28f3fc 100644
81481 --- a/lib/inflate.c
81482 +++ b/lib/inflate.c
81483 @@ -269,7 +269,7 @@ static void free(void *where)
81484 malloc_ptr = free_mem_ptr;
81485 }
81486 #else
81487 -#define malloc(a) kmalloc(a, GFP_KERNEL)
81488 +#define malloc(a) kmalloc((a), GFP_KERNEL)
81489 #define free(a) kfree(a)
81490 #endif
81491
81492 diff --git a/lib/ioremap.c b/lib/ioremap.c
81493 index 0c9216c..863bd89 100644
81494 --- a/lib/ioremap.c
81495 +++ b/lib/ioremap.c
81496 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
81497 unsigned long next;
81498
81499 phys_addr -= addr;
81500 - pmd = pmd_alloc(&init_mm, pud, addr);
81501 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
81502 if (!pmd)
81503 return -ENOMEM;
81504 do {
81505 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
81506 unsigned long next;
81507
81508 phys_addr -= addr;
81509 - pud = pud_alloc(&init_mm, pgd, addr);
81510 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
81511 if (!pud)
81512 return -ENOMEM;
81513 do {
81514 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
81515 index bd2bea9..6b3c95e 100644
81516 --- a/lib/is_single_threaded.c
81517 +++ b/lib/is_single_threaded.c
81518 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
81519 struct task_struct *p, *t;
81520 bool ret;
81521
81522 + if (!mm)
81523 + return true;
81524 +
81525 if (atomic_read(&task->signal->live) != 1)
81526 return false;
81527
81528 diff --git a/lib/kobject.c b/lib/kobject.c
81529 index b7e29a6..2f3ca75 100644
81530 --- a/lib/kobject.c
81531 +++ b/lib/kobject.c
81532 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
81533 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
81534 if (!kset)
81535 return NULL;
81536 - retval = kobject_set_name(&kset->kobj, name);
81537 + retval = kobject_set_name(&kset->kobj, "%s", name);
81538 if (retval) {
81539 kfree(kset);
81540 return NULL;
81541 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
81542
81543
81544 static DEFINE_SPINLOCK(kobj_ns_type_lock);
81545 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
81546 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
81547
81548 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
81549 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
81550 {
81551 enum kobj_ns_type type = ops->type;
81552 int error;
81553 diff --git a/lib/list_debug.c b/lib/list_debug.c
81554 index c24c2f7..06e070b 100644
81555 --- a/lib/list_debug.c
81556 +++ b/lib/list_debug.c
81557 @@ -11,7 +11,9 @@
81558 #include <linux/bug.h>
81559 #include <linux/kernel.h>
81560 #include <linux/rculist.h>
81561 +#include <linux/mm.h>
81562
81563 +#ifdef CONFIG_DEBUG_LIST
81564 /*
81565 * Insert a new entry between two known consecutive entries.
81566 *
81567 @@ -19,21 +21,32 @@
81568 * the prev/next entries already!
81569 */
81570
81571 -void __list_add(struct list_head *new,
81572 - struct list_head *prev,
81573 - struct list_head *next)
81574 +static bool __list_add_debug(struct list_head *new,
81575 + struct list_head *prev,
81576 + struct list_head *next)
81577 {
81578 - WARN(next->prev != prev,
81579 + if (WARN(next->prev != prev,
81580 "list_add corruption. next->prev should be "
81581 "prev (%p), but was %p. (next=%p).\n",
81582 - prev, next->prev, next);
81583 - WARN(prev->next != next,
81584 + prev, next->prev, next) ||
81585 + WARN(prev->next != next,
81586 "list_add corruption. prev->next should be "
81587 "next (%p), but was %p. (prev=%p).\n",
81588 - next, prev->next, prev);
81589 - WARN(new == prev || new == next,
81590 - "list_add double add: new=%p, prev=%p, next=%p.\n",
81591 - new, prev, next);
81592 + next, prev->next, prev) ||
81593 + WARN(new == prev || new == next,
81594 + "list_add double add: new=%p, prev=%p, next=%p.\n",
81595 + new, prev, next))
81596 + return false;
81597 + return true;
81598 +}
81599 +
81600 +void __list_add(struct list_head *new,
81601 + struct list_head *prev,
81602 + struct list_head *next)
81603 +{
81604 + if (!__list_add_debug(new, prev, next))
81605 + return;
81606 +
81607 next->prev = new;
81608 new->next = next;
81609 new->prev = prev;
81610 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
81611 }
81612 EXPORT_SYMBOL(__list_add);
81613
81614 -void __list_del_entry(struct list_head *entry)
81615 +static bool __list_del_entry_debug(struct list_head *entry)
81616 {
81617 struct list_head *prev, *next;
81618
81619 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
81620 WARN(next->prev != entry,
81621 "list_del corruption. next->prev should be %p, "
81622 "but was %p\n", entry, next->prev))
81623 + return false;
81624 + return true;
81625 +}
81626 +
81627 +void __list_del_entry(struct list_head *entry)
81628 +{
81629 + if (!__list_del_entry_debug(entry))
81630 return;
81631
81632 - __list_del(prev, next);
81633 + __list_del(entry->prev, entry->next);
81634 }
81635 EXPORT_SYMBOL(__list_del_entry);
81636
81637 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
81638 void __list_add_rcu(struct list_head *new,
81639 struct list_head *prev, struct list_head *next)
81640 {
81641 - WARN(next->prev != prev,
81642 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
81643 - prev, next->prev, next);
81644 - WARN(prev->next != next,
81645 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
81646 - next, prev->next, prev);
81647 + if (!__list_add_debug(new, prev, next))
81648 + return;
81649 +
81650 new->next = next;
81651 new->prev = prev;
81652 rcu_assign_pointer(list_next_rcu(prev), new);
81653 next->prev = new;
81654 }
81655 EXPORT_SYMBOL(__list_add_rcu);
81656 +#endif
81657 +
81658 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
81659 +{
81660 +#ifdef CONFIG_DEBUG_LIST
81661 + if (!__list_add_debug(new, prev, next))
81662 + return;
81663 +#endif
81664 +
81665 + pax_open_kernel();
81666 + next->prev = new;
81667 + new->next = next;
81668 + new->prev = prev;
81669 + prev->next = new;
81670 + pax_close_kernel();
81671 +}
81672 +EXPORT_SYMBOL(__pax_list_add);
81673 +
81674 +void pax_list_del(struct list_head *entry)
81675 +{
81676 +#ifdef CONFIG_DEBUG_LIST
81677 + if (!__list_del_entry_debug(entry))
81678 + return;
81679 +#endif
81680 +
81681 + pax_open_kernel();
81682 + __list_del(entry->prev, entry->next);
81683 + entry->next = LIST_POISON1;
81684 + entry->prev = LIST_POISON2;
81685 + pax_close_kernel();
81686 +}
81687 +EXPORT_SYMBOL(pax_list_del);
81688 +
81689 +void pax_list_del_init(struct list_head *entry)
81690 +{
81691 + pax_open_kernel();
81692 + __list_del(entry->prev, entry->next);
81693 + INIT_LIST_HEAD(entry);
81694 + pax_close_kernel();
81695 +}
81696 +EXPORT_SYMBOL(pax_list_del_init);
81697 +
81698 +void __pax_list_add_rcu(struct list_head *new,
81699 + struct list_head *prev, struct list_head *next)
81700 +{
81701 +#ifdef CONFIG_DEBUG_LIST
81702 + if (!__list_add_debug(new, prev, next))
81703 + return;
81704 +#endif
81705 +
81706 + pax_open_kernel();
81707 + new->next = next;
81708 + new->prev = prev;
81709 + rcu_assign_pointer(list_next_rcu(prev), new);
81710 + next->prev = new;
81711 + pax_close_kernel();
81712 +}
81713 +EXPORT_SYMBOL(__pax_list_add_rcu);
81714 +
81715 +void pax_list_del_rcu(struct list_head *entry)
81716 +{
81717 +#ifdef CONFIG_DEBUG_LIST
81718 + if (!__list_del_entry_debug(entry))
81719 + return;
81720 +#endif
81721 +
81722 + pax_open_kernel();
81723 + __list_del(entry->prev, entry->next);
81724 + entry->next = LIST_POISON1;
81725 + entry->prev = LIST_POISON2;
81726 + pax_close_kernel();
81727 +}
81728 +EXPORT_SYMBOL(pax_list_del_rcu);
81729 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
81730 index e796429..6e38f9f 100644
81731 --- a/lib/radix-tree.c
81732 +++ b/lib/radix-tree.c
81733 @@ -92,7 +92,7 @@ struct radix_tree_preload {
81734 int nr;
81735 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
81736 };
81737 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
81738 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
81739
81740 static inline void *ptr_to_indirect(void *ptr)
81741 {
81742 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
81743 index bb2b201..46abaf9 100644
81744 --- a/lib/strncpy_from_user.c
81745 +++ b/lib/strncpy_from_user.c
81746 @@ -21,7 +21,7 @@
81747 */
81748 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
81749 {
81750 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81751 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81752 long res = 0;
81753
81754 /*
81755 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
81756 index a28df52..3d55877 100644
81757 --- a/lib/strnlen_user.c
81758 +++ b/lib/strnlen_user.c
81759 @@ -26,7 +26,7 @@
81760 */
81761 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
81762 {
81763 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81764 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81765 long align, res = 0;
81766 unsigned long c;
81767
81768 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
81769 index d23762e..e21eab2 100644
81770 --- a/lib/swiotlb.c
81771 +++ b/lib/swiotlb.c
81772 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
81773
81774 void
81775 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
81776 - dma_addr_t dev_addr)
81777 + dma_addr_t dev_addr, struct dma_attrs *attrs)
81778 {
81779 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
81780
81781 diff --git a/lib/usercopy.c b/lib/usercopy.c
81782 index 4f5b1dd..7cab418 100644
81783 --- a/lib/usercopy.c
81784 +++ b/lib/usercopy.c
81785 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
81786 WARN(1, "Buffer overflow detected!\n");
81787 }
81788 EXPORT_SYMBOL(copy_from_user_overflow);
81789 +
81790 +void copy_to_user_overflow(void)
81791 +{
81792 + WARN(1, "Buffer overflow detected!\n");
81793 +}
81794 +EXPORT_SYMBOL(copy_to_user_overflow);
81795 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
81796 index e149c64..24aa71a 100644
81797 --- a/lib/vsprintf.c
81798 +++ b/lib/vsprintf.c
81799 @@ -16,6 +16,9 @@
81800 * - scnprintf and vscnprintf
81801 */
81802
81803 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81804 +#define __INCLUDED_BY_HIDESYM 1
81805 +#endif
81806 #include <stdarg.h>
81807 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
81808 #include <linux/types.h>
81809 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
81810 return number(buf, end, *(const netdev_features_t *)addr, spec);
81811 }
81812
81813 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81814 +int kptr_restrict __read_mostly = 2;
81815 +#else
81816 int kptr_restrict __read_mostly;
81817 +#endif
81818
81819 /*
81820 * Show a '%p' thing. A kernel extension is that the '%p' is followed
81821 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
81822 * - 'f' For simple symbolic function names without offset
81823 * - 'S' For symbolic direct pointers with offset
81824 * - 's' For symbolic direct pointers without offset
81825 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
81826 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
81827 * - 'B' For backtraced symbolic direct pointers with offset
81828 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
81829 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81830
81831 if (!ptr && *fmt != 'K') {
81832 /*
81833 - * Print (null) with the same width as a pointer so it makes
81834 + * Print (nil) with the same width as a pointer so it makes
81835 * tabular output look nice.
81836 */
81837 if (spec.field_width == -1)
81838 spec.field_width = default_width;
81839 - return string(buf, end, "(null)", spec);
81840 + return string(buf, end, "(nil)", spec);
81841 }
81842
81843 switch (*fmt) {
81844 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81845 /* Fallthrough */
81846 case 'S':
81847 case 's':
81848 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81849 + break;
81850 +#else
81851 + return symbol_string(buf, end, ptr, spec, fmt);
81852 +#endif
81853 + case 'A':
81854 case 'B':
81855 return symbol_string(buf, end, ptr, spec, fmt);
81856 case 'R':
81857 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81858 va_end(va);
81859 return buf;
81860 }
81861 + case 'P':
81862 + break;
81863 case 'K':
81864 /*
81865 * %pK cannot be used in IRQ context because its test
81866 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81867 return number(buf, end,
81868 (unsigned long long) *((phys_addr_t *)ptr), spec);
81869 }
81870 +
81871 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81872 + /* 'P' = approved pointers to copy to userland,
81873 + as in the /proc/kallsyms case, as we make it display nothing
81874 + for non-root users, and the real contents for root users
81875 + Also ignore 'K' pointers, since we force their NULLing for non-root users
81876 + above
81877 + */
81878 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
81879 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
81880 + dump_stack();
81881 + ptr = NULL;
81882 + }
81883 +#endif
81884 +
81885 spec.flags |= SMALL;
81886 if (spec.field_width == -1) {
81887 spec.field_width = default_width;
81888 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81889 typeof(type) value; \
81890 if (sizeof(type) == 8) { \
81891 args = PTR_ALIGN(args, sizeof(u32)); \
81892 - *(u32 *)&value = *(u32 *)args; \
81893 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
81894 + *(u32 *)&value = *(const u32 *)args; \
81895 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
81896 } else { \
81897 args = PTR_ALIGN(args, sizeof(type)); \
81898 - value = *(typeof(type) *)args; \
81899 + value = *(const typeof(type) *)args; \
81900 } \
81901 args += sizeof(type); \
81902 value; \
81903 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81904 case FORMAT_TYPE_STR: {
81905 const char *str_arg = args;
81906 args += strlen(str_arg) + 1;
81907 - str = string(str, end, (char *)str_arg, spec);
81908 + str = string(str, end, str_arg, spec);
81909 break;
81910 }
81911
81912 diff --git a/localversion-grsec b/localversion-grsec
81913 new file mode 100644
81914 index 0000000..7cd6065
81915 --- /dev/null
81916 +++ b/localversion-grsec
81917 @@ -0,0 +1 @@
81918 +-grsec
81919 diff --git a/mm/Kconfig b/mm/Kconfig
81920 index e742d06..c56fdd8 100644
81921 --- a/mm/Kconfig
81922 +++ b/mm/Kconfig
81923 @@ -317,10 +317,10 @@ config KSM
81924 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
81925
81926 config DEFAULT_MMAP_MIN_ADDR
81927 - int "Low address space to protect from user allocation"
81928 + int "Low address space to protect from user allocation"
81929 depends on MMU
81930 - default 4096
81931 - help
81932 + default 65536
81933 + help
81934 This is the portion of low virtual memory which should be protected
81935 from userspace allocation. Keeping a user from writing to low pages
81936 can help reduce the impact of kernel NULL pointer bugs.
81937 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
81938
81939 config HWPOISON_INJECT
81940 tristate "HWPoison pages injector"
81941 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
81942 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
81943 select PROC_PAGE_MONITOR
81944
81945 config NOMMU_INITIAL_TRIM_EXCESS
81946 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
81947 index 5025174..9fc1c5c 100644
81948 --- a/mm/backing-dev.c
81949 +++ b/mm/backing-dev.c
81950 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
81951 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81952 unsigned int cap)
81953 {
81954 - char tmp[32];
81955 int err;
81956
81957 bdi->name = name;
81958 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81959 if (err)
81960 return err;
81961
81962 - sprintf(tmp, "%.28s%s", name, "-%d");
81963 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
81964 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return(&bdi_seq));
81965 if (err) {
81966 bdi_destroy(bdi);
81967 return err;
81968 diff --git a/mm/filemap.c b/mm/filemap.c
81969 index 7905fe7..e60faa8 100644
81970 --- a/mm/filemap.c
81971 +++ b/mm/filemap.c
81972 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
81973 struct address_space *mapping = file->f_mapping;
81974
81975 if (!mapping->a_ops->readpage)
81976 - return -ENOEXEC;
81977 + return -ENODEV;
81978 file_accessed(file);
81979 vma->vm_ops = &generic_file_vm_ops;
81980 return 0;
81981 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
81982 *pos = i_size_read(inode);
81983
81984 if (limit != RLIM_INFINITY) {
81985 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
81986 if (*pos >= limit) {
81987 send_sig(SIGXFSZ, current, 0);
81988 return -EFBIG;
81989 diff --git a/mm/fremap.c b/mm/fremap.c
81990 index 87da359..3f41cb1 100644
81991 --- a/mm/fremap.c
81992 +++ b/mm/fremap.c
81993 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
81994 retry:
81995 vma = find_vma(mm, start);
81996
81997 +#ifdef CONFIG_PAX_SEGMEXEC
81998 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
81999 + goto out;
82000 +#endif
82001 +
82002 /*
82003 * Make sure the vma is shared, that it supports prefaulting,
82004 * and that the remapped range is valid and fully within
82005 diff --git a/mm/highmem.c b/mm/highmem.c
82006 index b32b70c..e512eb0 100644
82007 --- a/mm/highmem.c
82008 +++ b/mm/highmem.c
82009 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
82010 * So no dangers, even with speculative execution.
82011 */
82012 page = pte_page(pkmap_page_table[i]);
82013 + pax_open_kernel();
82014 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
82015 -
82016 + pax_close_kernel();
82017 set_page_address(page, NULL);
82018 need_flush = 1;
82019 }
82020 @@ -198,9 +199,11 @@ start:
82021 }
82022 }
82023 vaddr = PKMAP_ADDR(last_pkmap_nr);
82024 +
82025 + pax_open_kernel();
82026 set_pte_at(&init_mm, vaddr,
82027 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
82028 -
82029 + pax_close_kernel();
82030 pkmap_count[last_pkmap_nr] = 1;
82031 set_page_address(page, (void *)vaddr);
82032
82033 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
82034 index 5cf99bf..28634c8 100644
82035 --- a/mm/hugetlb.c
82036 +++ b/mm/hugetlb.c
82037 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
82038 struct hstate *h = &default_hstate;
82039 unsigned long tmp;
82040 int ret;
82041 + ctl_table_no_const hugetlb_table;
82042
82043 tmp = h->max_huge_pages;
82044
82045 if (write && h->order >= MAX_ORDER)
82046 return -EINVAL;
82047
82048 - table->data = &tmp;
82049 - table->maxlen = sizeof(unsigned long);
82050 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
82051 + hugetlb_table = *table;
82052 + hugetlb_table.data = &tmp;
82053 + hugetlb_table.maxlen = sizeof(unsigned long);
82054 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
82055 if (ret)
82056 goto out;
82057
82058 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
82059 struct hstate *h = &default_hstate;
82060 unsigned long tmp;
82061 int ret;
82062 + ctl_table_no_const hugetlb_table;
82063
82064 tmp = h->nr_overcommit_huge_pages;
82065
82066 if (write && h->order >= MAX_ORDER)
82067 return -EINVAL;
82068
82069 - table->data = &tmp;
82070 - table->maxlen = sizeof(unsigned long);
82071 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
82072 + hugetlb_table = *table;
82073 + hugetlb_table.data = &tmp;
82074 + hugetlb_table.maxlen = sizeof(unsigned long);
82075 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
82076 if (ret)
82077 goto out;
82078
82079 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
82080 return 1;
82081 }
82082
82083 +#ifdef CONFIG_PAX_SEGMEXEC
82084 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
82085 +{
82086 + struct mm_struct *mm = vma->vm_mm;
82087 + struct vm_area_struct *vma_m;
82088 + unsigned long address_m;
82089 + pte_t *ptep_m;
82090 +
82091 + vma_m = pax_find_mirror_vma(vma);
82092 + if (!vma_m)
82093 + return;
82094 +
82095 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82096 + address_m = address + SEGMEXEC_TASK_SIZE;
82097 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
82098 + get_page(page_m);
82099 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
82100 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
82101 +}
82102 +#endif
82103 +
82104 /*
82105 * Hugetlb_cow() should be called with page lock of the original hugepage held.
82106 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
82107 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
82108 make_huge_pte(vma, new_page, 1));
82109 page_remove_rmap(old_page);
82110 hugepage_add_new_anon_rmap(new_page, vma, address);
82111 +
82112 +#ifdef CONFIG_PAX_SEGMEXEC
82113 + pax_mirror_huge_pte(vma, address, new_page);
82114 +#endif
82115 +
82116 /* Make the old page be freed below */
82117 new_page = old_page;
82118 }
82119 @@ -2821,6 +2851,10 @@ retry:
82120 && (vma->vm_flags & VM_SHARED)));
82121 set_huge_pte_at(mm, address, ptep, new_pte);
82122
82123 +#ifdef CONFIG_PAX_SEGMEXEC
82124 + pax_mirror_huge_pte(vma, address, page);
82125 +#endif
82126 +
82127 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
82128 /* Optimization, do the COW without a second fault */
82129 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
82130 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82131 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
82132 struct hstate *h = hstate_vma(vma);
82133
82134 +#ifdef CONFIG_PAX_SEGMEXEC
82135 + struct vm_area_struct *vma_m;
82136 +#endif
82137 +
82138 address &= huge_page_mask(h);
82139
82140 ptep = huge_pte_offset(mm, address);
82141 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82142 VM_FAULT_SET_HINDEX(hstate_index(h));
82143 }
82144
82145 +#ifdef CONFIG_PAX_SEGMEXEC
82146 + vma_m = pax_find_mirror_vma(vma);
82147 + if (vma_m) {
82148 + unsigned long address_m;
82149 +
82150 + if (vma->vm_start > vma_m->vm_start) {
82151 + address_m = address;
82152 + address -= SEGMEXEC_TASK_SIZE;
82153 + vma = vma_m;
82154 + h = hstate_vma(vma);
82155 + } else
82156 + address_m = address + SEGMEXEC_TASK_SIZE;
82157 +
82158 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
82159 + return VM_FAULT_OOM;
82160 + address_m &= HPAGE_MASK;
82161 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
82162 + }
82163 +#endif
82164 +
82165 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
82166 if (!ptep)
82167 return VM_FAULT_OOM;
82168 diff --git a/mm/internal.h b/mm/internal.h
82169 index 8562de0..7fdfe92 100644
82170 --- a/mm/internal.h
82171 +++ b/mm/internal.h
82172 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
82173 * in mm/page_alloc.c
82174 */
82175 extern void __free_pages_bootmem(struct page *page, unsigned int order);
82176 +extern void free_compound_page(struct page *page);
82177 extern void prep_compound_page(struct page *page, unsigned long order);
82178 #ifdef CONFIG_MEMORY_FAILURE
82179 extern bool is_free_buddy_page(struct page *page);
82180 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
82181 index c8d7f31..2dbeffd 100644
82182 --- a/mm/kmemleak.c
82183 +++ b/mm/kmemleak.c
82184 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
82185
82186 for (i = 0; i < object->trace_len; i++) {
82187 void *ptr = (void *)object->trace[i];
82188 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
82189 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
82190 }
82191 }
82192
82193 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
82194 return -ENOMEM;
82195 }
82196
82197 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
82198 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
82199 &kmemleak_fops);
82200 if (!dentry)
82201 pr_warning("Failed to create the debugfs kmemleak file\n");
82202 diff --git a/mm/maccess.c b/mm/maccess.c
82203 index d53adf9..03a24bf 100644
82204 --- a/mm/maccess.c
82205 +++ b/mm/maccess.c
82206 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
82207 set_fs(KERNEL_DS);
82208 pagefault_disable();
82209 ret = __copy_from_user_inatomic(dst,
82210 - (__force const void __user *)src, size);
82211 + (const void __force_user *)src, size);
82212 pagefault_enable();
82213 set_fs(old_fs);
82214
82215 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
82216
82217 set_fs(KERNEL_DS);
82218 pagefault_disable();
82219 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
82220 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
82221 pagefault_enable();
82222 set_fs(old_fs);
82223
82224 diff --git a/mm/madvise.c b/mm/madvise.c
82225 index 7055883..aafb1ed 100644
82226 --- a/mm/madvise.c
82227 +++ b/mm/madvise.c
82228 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
82229 pgoff_t pgoff;
82230 unsigned long new_flags = vma->vm_flags;
82231
82232 +#ifdef CONFIG_PAX_SEGMEXEC
82233 + struct vm_area_struct *vma_m;
82234 +#endif
82235 +
82236 switch (behavior) {
82237 case MADV_NORMAL:
82238 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
82239 @@ -126,6 +130,13 @@ success:
82240 /*
82241 * vm_flags is protected by the mmap_sem held in write mode.
82242 */
82243 +
82244 +#ifdef CONFIG_PAX_SEGMEXEC
82245 + vma_m = pax_find_mirror_vma(vma);
82246 + if (vma_m)
82247 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
82248 +#endif
82249 +
82250 vma->vm_flags = new_flags;
82251
82252 out:
82253 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
82254 struct vm_area_struct ** prev,
82255 unsigned long start, unsigned long end)
82256 {
82257 +
82258 +#ifdef CONFIG_PAX_SEGMEXEC
82259 + struct vm_area_struct *vma_m;
82260 +#endif
82261 +
82262 *prev = vma;
82263 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
82264 return -EINVAL;
82265 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
82266 zap_page_range(vma, start, end - start, &details);
82267 } else
82268 zap_page_range(vma, start, end - start, NULL);
82269 +
82270 +#ifdef CONFIG_PAX_SEGMEXEC
82271 + vma_m = pax_find_mirror_vma(vma);
82272 + if (vma_m) {
82273 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
82274 + struct zap_details details = {
82275 + .nonlinear_vma = vma_m,
82276 + .last_index = ULONG_MAX,
82277 + };
82278 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
82279 + } else
82280 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
82281 + }
82282 +#endif
82283 +
82284 return 0;
82285 }
82286
82287 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
82288 if (end < start)
82289 return error;
82290
82291 +#ifdef CONFIG_PAX_SEGMEXEC
82292 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
82293 + if (end > SEGMEXEC_TASK_SIZE)
82294 + return error;
82295 + } else
82296 +#endif
82297 +
82298 + if (end > TASK_SIZE)
82299 + return error;
82300 +
82301 error = 0;
82302 if (end == start)
82303 return error;
82304 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
82305 index ceb0c7f..b2b8e94 100644
82306 --- a/mm/memory-failure.c
82307 +++ b/mm/memory-failure.c
82308 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
82309
82310 int sysctl_memory_failure_recovery __read_mostly = 1;
82311
82312 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
82313 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
82314
82315 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
82316
82317 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
82318 pfn, t->comm, t->pid);
82319 si.si_signo = SIGBUS;
82320 si.si_errno = 0;
82321 - si.si_addr = (void *)addr;
82322 + si.si_addr = (void __user *)addr;
82323 #ifdef __ARCH_SI_TRAPNO
82324 si.si_trapno = trapno;
82325 #endif
82326 @@ -760,7 +760,7 @@ static struct page_state {
82327 unsigned long res;
82328 char *msg;
82329 int (*action)(struct page *p, unsigned long pfn);
82330 -} error_states[] = {
82331 +} __do_const error_states[] = {
82332 { reserved, reserved, "reserved kernel", me_kernel },
82333 /*
82334 * free pages are specially detected outside this table:
82335 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
82336 nr_pages = 1 << compound_order(hpage);
82337 else /* normal page or thp */
82338 nr_pages = 1;
82339 - atomic_long_add(nr_pages, &num_poisoned_pages);
82340 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
82341
82342 /*
82343 * We need/can do nothing about count=0 pages.
82344 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
82345 if (!PageHWPoison(hpage)
82346 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
82347 || (p != hpage && TestSetPageHWPoison(hpage))) {
82348 - atomic_long_sub(nr_pages, &num_poisoned_pages);
82349 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
82350 return 0;
82351 }
82352 set_page_hwpoison_huge_page(hpage);
82353 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
82354 }
82355 if (hwpoison_filter(p)) {
82356 if (TestClearPageHWPoison(p))
82357 - atomic_long_sub(nr_pages, &num_poisoned_pages);
82358 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
82359 unlock_page(hpage);
82360 put_page(hpage);
82361 return 0;
82362 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
82363 return 0;
82364 }
82365 if (TestClearPageHWPoison(p))
82366 - atomic_long_sub(nr_pages, &num_poisoned_pages);
82367 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
82368 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
82369 return 0;
82370 }
82371 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
82372 */
82373 if (TestClearPageHWPoison(page)) {
82374 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
82375 - atomic_long_sub(nr_pages, &num_poisoned_pages);
82376 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
82377 freeit = 1;
82378 if (PageHuge(page))
82379 clear_page_hwpoison_huge_page(page);
82380 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
82381 } else {
82382 set_page_hwpoison_huge_page(hpage);
82383 dequeue_hwpoisoned_huge_page(hpage);
82384 - atomic_long_add(1 << compound_trans_order(hpage),
82385 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
82386 &num_poisoned_pages);
82387 }
82388 /* keep elevated page count for bad page */
82389 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
82390 if (PageHuge(page)) {
82391 set_page_hwpoison_huge_page(hpage);
82392 dequeue_hwpoisoned_huge_page(hpage);
82393 - atomic_long_add(1 << compound_trans_order(hpage),
82394 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
82395 &num_poisoned_pages);
82396 } else {
82397 SetPageHWPoison(page);
82398 - atomic_long_inc(&num_poisoned_pages);
82399 + atomic_long_inc_unchecked(&num_poisoned_pages);
82400 }
82401 }
82402 /* keep elevated page count for bad page */
82403 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
82404 put_page(page);
82405 pr_info("soft_offline: %#lx: invalidated\n", pfn);
82406 SetPageHWPoison(page);
82407 - atomic_long_inc(&num_poisoned_pages);
82408 + atomic_long_inc_unchecked(&num_poisoned_pages);
82409 return 0;
82410 }
82411
82412 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
82413 ret = -EIO;
82414 } else {
82415 SetPageHWPoison(page);
82416 - atomic_long_inc(&num_poisoned_pages);
82417 + atomic_long_inc_unchecked(&num_poisoned_pages);
82418 }
82419 } else {
82420 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
82421 diff --git a/mm/memory.c b/mm/memory.c
82422 index 61a262b..77a94d1 100644
82423 --- a/mm/memory.c
82424 +++ b/mm/memory.c
82425 @@ -429,6 +429,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
82426 free_pte_range(tlb, pmd, addr);
82427 } while (pmd++, addr = next, addr != end);
82428
82429 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
82430 start &= PUD_MASK;
82431 if (start < floor)
82432 return;
82433 @@ -443,6 +444,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
82434 pmd = pmd_offset(pud, start);
82435 pud_clear(pud);
82436 pmd_free_tlb(tlb, pmd, start);
82437 +#endif
82438 +
82439 }
82440
82441 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
82442 @@ -462,6 +465,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
82443 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
82444 } while (pud++, addr = next, addr != end);
82445
82446 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
82447 start &= PGDIR_MASK;
82448 if (start < floor)
82449 return;
82450 @@ -476,6 +480,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
82451 pud = pud_offset(pgd, start);
82452 pgd_clear(pgd);
82453 pud_free_tlb(tlb, pud, start);
82454 +#endif
82455 +
82456 }
82457
82458 /*
82459 @@ -1635,12 +1641,6 @@ no_page_table:
82460 return page;
82461 }
82462
82463 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
82464 -{
82465 - return stack_guard_page_start(vma, addr) ||
82466 - stack_guard_page_end(vma, addr+PAGE_SIZE);
82467 -}
82468 -
82469 /**
82470 * __get_user_pages() - pin user pages in memory
82471 * @tsk: task_struct of target task
82472 @@ -1727,10 +1727,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
82473
82474 i = 0;
82475
82476 - do {
82477 + while (nr_pages) {
82478 struct vm_area_struct *vma;
82479
82480 - vma = find_extend_vma(mm, start);
82481 + vma = find_vma(mm, start);
82482 if (!vma && in_gate_area(mm, start)) {
82483 unsigned long pg = start & PAGE_MASK;
82484 pgd_t *pgd;
82485 @@ -1779,7 +1779,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
82486 goto next_page;
82487 }
82488
82489 - if (!vma ||
82490 + if (!vma || start < vma->vm_start ||
82491 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
82492 !(vm_flags & vma->vm_flags))
82493 return i ? : -EFAULT;
82494 @@ -1808,11 +1808,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
82495 int ret;
82496 unsigned int fault_flags = 0;
82497
82498 - /* For mlock, just skip the stack guard page. */
82499 - if (foll_flags & FOLL_MLOCK) {
82500 - if (stack_guard_page(vma, start))
82501 - goto next_page;
82502 - }
82503 if (foll_flags & FOLL_WRITE)
82504 fault_flags |= FAULT_FLAG_WRITE;
82505 if (nonblocking)
82506 @@ -1892,7 +1887,7 @@ next_page:
82507 start += page_increm * PAGE_SIZE;
82508 nr_pages -= page_increm;
82509 } while (nr_pages && start < vma->vm_end);
82510 - } while (nr_pages);
82511 + }
82512 return i;
82513 }
82514 EXPORT_SYMBOL(__get_user_pages);
82515 @@ -2099,6 +2094,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
82516 page_add_file_rmap(page);
82517 set_pte_at(mm, addr, pte, mk_pte(page, prot));
82518
82519 +#ifdef CONFIG_PAX_SEGMEXEC
82520 + pax_mirror_file_pte(vma, addr, page, ptl);
82521 +#endif
82522 +
82523 retval = 0;
82524 pte_unmap_unlock(pte, ptl);
82525 return retval;
82526 @@ -2143,9 +2142,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
82527 if (!page_count(page))
82528 return -EINVAL;
82529 if (!(vma->vm_flags & VM_MIXEDMAP)) {
82530 +
82531 +#ifdef CONFIG_PAX_SEGMEXEC
82532 + struct vm_area_struct *vma_m;
82533 +#endif
82534 +
82535 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
82536 BUG_ON(vma->vm_flags & VM_PFNMAP);
82537 vma->vm_flags |= VM_MIXEDMAP;
82538 +
82539 +#ifdef CONFIG_PAX_SEGMEXEC
82540 + vma_m = pax_find_mirror_vma(vma);
82541 + if (vma_m)
82542 + vma_m->vm_flags |= VM_MIXEDMAP;
82543 +#endif
82544 +
82545 }
82546 return insert_page(vma, addr, page, vma->vm_page_prot);
82547 }
82548 @@ -2228,6 +2239,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
82549 unsigned long pfn)
82550 {
82551 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
82552 + BUG_ON(vma->vm_mirror);
82553
82554 if (addr < vma->vm_start || addr >= vma->vm_end)
82555 return -EFAULT;
82556 @@ -2475,7 +2487,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
82557
82558 BUG_ON(pud_huge(*pud));
82559
82560 - pmd = pmd_alloc(mm, pud, addr);
82561 + pmd = (mm == &init_mm) ?
82562 + pmd_alloc_kernel(mm, pud, addr) :
82563 + pmd_alloc(mm, pud, addr);
82564 if (!pmd)
82565 return -ENOMEM;
82566 do {
82567 @@ -2495,7 +2509,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
82568 unsigned long next;
82569 int err;
82570
82571 - pud = pud_alloc(mm, pgd, addr);
82572 + pud = (mm == &init_mm) ?
82573 + pud_alloc_kernel(mm, pgd, addr) :
82574 + pud_alloc(mm, pgd, addr);
82575 if (!pud)
82576 return -ENOMEM;
82577 do {
82578 @@ -2583,6 +2599,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
82579 copy_user_highpage(dst, src, va, vma);
82580 }
82581
82582 +#ifdef CONFIG_PAX_SEGMEXEC
82583 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
82584 +{
82585 + struct mm_struct *mm = vma->vm_mm;
82586 + spinlock_t *ptl;
82587 + pte_t *pte, entry;
82588 +
82589 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
82590 + entry = *pte;
82591 + if (!pte_present(entry)) {
82592 + if (!pte_none(entry)) {
82593 + BUG_ON(pte_file(entry));
82594 + free_swap_and_cache(pte_to_swp_entry(entry));
82595 + pte_clear_not_present_full(mm, address, pte, 0);
82596 + }
82597 + } else {
82598 + struct page *page;
82599 +
82600 + flush_cache_page(vma, address, pte_pfn(entry));
82601 + entry = ptep_clear_flush(vma, address, pte);
82602 + BUG_ON(pte_dirty(entry));
82603 + page = vm_normal_page(vma, address, entry);
82604 + if (page) {
82605 + update_hiwater_rss(mm);
82606 + if (PageAnon(page))
82607 + dec_mm_counter_fast(mm, MM_ANONPAGES);
82608 + else
82609 + dec_mm_counter_fast(mm, MM_FILEPAGES);
82610 + page_remove_rmap(page);
82611 + page_cache_release(page);
82612 + }
82613 + }
82614 + pte_unmap_unlock(pte, ptl);
82615 +}
82616 +
82617 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
82618 + *
82619 + * the ptl of the lower mapped page is held on entry and is not released on exit
82620 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
82621 + */
82622 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
82623 +{
82624 + struct mm_struct *mm = vma->vm_mm;
82625 + unsigned long address_m;
82626 + spinlock_t *ptl_m;
82627 + struct vm_area_struct *vma_m;
82628 + pmd_t *pmd_m;
82629 + pte_t *pte_m, entry_m;
82630 +
82631 + BUG_ON(!page_m || !PageAnon(page_m));
82632 +
82633 + vma_m = pax_find_mirror_vma(vma);
82634 + if (!vma_m)
82635 + return;
82636 +
82637 + BUG_ON(!PageLocked(page_m));
82638 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82639 + address_m = address + SEGMEXEC_TASK_SIZE;
82640 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
82641 + pte_m = pte_offset_map(pmd_m, address_m);
82642 + ptl_m = pte_lockptr(mm, pmd_m);
82643 + if (ptl != ptl_m) {
82644 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
82645 + if (!pte_none(*pte_m))
82646 + goto out;
82647 + }
82648 +
82649 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
82650 + page_cache_get(page_m);
82651 + page_add_anon_rmap(page_m, vma_m, address_m);
82652 + inc_mm_counter_fast(mm, MM_ANONPAGES);
82653 + set_pte_at(mm, address_m, pte_m, entry_m);
82654 + update_mmu_cache(vma_m, address_m, pte_m);
82655 +out:
82656 + if (ptl != ptl_m)
82657 + spin_unlock(ptl_m);
82658 + pte_unmap(pte_m);
82659 + unlock_page(page_m);
82660 +}
82661 +
82662 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
82663 +{
82664 + struct mm_struct *mm = vma->vm_mm;
82665 + unsigned long address_m;
82666 + spinlock_t *ptl_m;
82667 + struct vm_area_struct *vma_m;
82668 + pmd_t *pmd_m;
82669 + pte_t *pte_m, entry_m;
82670 +
82671 + BUG_ON(!page_m || PageAnon(page_m));
82672 +
82673 + vma_m = pax_find_mirror_vma(vma);
82674 + if (!vma_m)
82675 + return;
82676 +
82677 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82678 + address_m = address + SEGMEXEC_TASK_SIZE;
82679 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
82680 + pte_m = pte_offset_map(pmd_m, address_m);
82681 + ptl_m = pte_lockptr(mm, pmd_m);
82682 + if (ptl != ptl_m) {
82683 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
82684 + if (!pte_none(*pte_m))
82685 + goto out;
82686 + }
82687 +
82688 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
82689 + page_cache_get(page_m);
82690 + page_add_file_rmap(page_m);
82691 + inc_mm_counter_fast(mm, MM_FILEPAGES);
82692 + set_pte_at(mm, address_m, pte_m, entry_m);
82693 + update_mmu_cache(vma_m, address_m, pte_m);
82694 +out:
82695 + if (ptl != ptl_m)
82696 + spin_unlock(ptl_m);
82697 + pte_unmap(pte_m);
82698 +}
82699 +
82700 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
82701 +{
82702 + struct mm_struct *mm = vma->vm_mm;
82703 + unsigned long address_m;
82704 + spinlock_t *ptl_m;
82705 + struct vm_area_struct *vma_m;
82706 + pmd_t *pmd_m;
82707 + pte_t *pte_m, entry_m;
82708 +
82709 + vma_m = pax_find_mirror_vma(vma);
82710 + if (!vma_m)
82711 + return;
82712 +
82713 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82714 + address_m = address + SEGMEXEC_TASK_SIZE;
82715 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
82716 + pte_m = pte_offset_map(pmd_m, address_m);
82717 + ptl_m = pte_lockptr(mm, pmd_m);
82718 + if (ptl != ptl_m) {
82719 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
82720 + if (!pte_none(*pte_m))
82721 + goto out;
82722 + }
82723 +
82724 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
82725 + set_pte_at(mm, address_m, pte_m, entry_m);
82726 +out:
82727 + if (ptl != ptl_m)
82728 + spin_unlock(ptl_m);
82729 + pte_unmap(pte_m);
82730 +}
82731 +
82732 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
82733 +{
82734 + struct page *page_m;
82735 + pte_t entry;
82736 +
82737 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
82738 + goto out;
82739 +
82740 + entry = *pte;
82741 + page_m = vm_normal_page(vma, address, entry);
82742 + if (!page_m)
82743 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
82744 + else if (PageAnon(page_m)) {
82745 + if (pax_find_mirror_vma(vma)) {
82746 + pte_unmap_unlock(pte, ptl);
82747 + lock_page(page_m);
82748 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
82749 + if (pte_same(entry, *pte))
82750 + pax_mirror_anon_pte(vma, address, page_m, ptl);
82751 + else
82752 + unlock_page(page_m);
82753 + }
82754 + } else
82755 + pax_mirror_file_pte(vma, address, page_m, ptl);
82756 +
82757 +out:
82758 + pte_unmap_unlock(pte, ptl);
82759 +}
82760 +#endif
82761 +
82762 /*
82763 * This routine handles present pages, when users try to write
82764 * to a shared page. It is done by copying the page to a new address
82765 @@ -2799,6 +2995,12 @@ gotten:
82766 */
82767 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82768 if (likely(pte_same(*page_table, orig_pte))) {
82769 +
82770 +#ifdef CONFIG_PAX_SEGMEXEC
82771 + if (pax_find_mirror_vma(vma))
82772 + BUG_ON(!trylock_page(new_page));
82773 +#endif
82774 +
82775 if (old_page) {
82776 if (!PageAnon(old_page)) {
82777 dec_mm_counter_fast(mm, MM_FILEPAGES);
82778 @@ -2850,6 +3052,10 @@ gotten:
82779 page_remove_rmap(old_page);
82780 }
82781
82782 +#ifdef CONFIG_PAX_SEGMEXEC
82783 + pax_mirror_anon_pte(vma, address, new_page, ptl);
82784 +#endif
82785 +
82786 /* Free the old page.. */
82787 new_page = old_page;
82788 ret |= VM_FAULT_WRITE;
82789 @@ -3125,6 +3331,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82790 swap_free(entry);
82791 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
82792 try_to_free_swap(page);
82793 +
82794 +#ifdef CONFIG_PAX_SEGMEXEC
82795 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
82796 +#endif
82797 +
82798 unlock_page(page);
82799 if (page != swapcache) {
82800 /*
82801 @@ -3148,6 +3359,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82802
82803 /* No need to invalidate - it was non-present before */
82804 update_mmu_cache(vma, address, page_table);
82805 +
82806 +#ifdef CONFIG_PAX_SEGMEXEC
82807 + pax_mirror_anon_pte(vma, address, page, ptl);
82808 +#endif
82809 +
82810 unlock:
82811 pte_unmap_unlock(page_table, ptl);
82812 out:
82813 @@ -3167,40 +3383,6 @@ out_release:
82814 }
82815
82816 /*
82817 - * This is like a special single-page "expand_{down|up}wards()",
82818 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
82819 - * doesn't hit another vma.
82820 - */
82821 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
82822 -{
82823 - address &= PAGE_MASK;
82824 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
82825 - struct vm_area_struct *prev = vma->vm_prev;
82826 -
82827 - /*
82828 - * Is there a mapping abutting this one below?
82829 - *
82830 - * That's only ok if it's the same stack mapping
82831 - * that has gotten split..
82832 - */
82833 - if (prev && prev->vm_end == address)
82834 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
82835 -
82836 - expand_downwards(vma, address - PAGE_SIZE);
82837 - }
82838 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
82839 - struct vm_area_struct *next = vma->vm_next;
82840 -
82841 - /* As VM_GROWSDOWN but s/below/above/ */
82842 - if (next && next->vm_start == address + PAGE_SIZE)
82843 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
82844 -
82845 - expand_upwards(vma, address + PAGE_SIZE);
82846 - }
82847 - return 0;
82848 -}
82849 -
82850 -/*
82851 * We enter with non-exclusive mmap_sem (to exclude vma changes,
82852 * but allow concurrent faults), and pte mapped but not yet locked.
82853 * We return with mmap_sem still held, but pte unmapped and unlocked.
82854 @@ -3209,27 +3391,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82855 unsigned long address, pte_t *page_table, pmd_t *pmd,
82856 unsigned int flags)
82857 {
82858 - struct page *page;
82859 + struct page *page = NULL;
82860 spinlock_t *ptl;
82861 pte_t entry;
82862
82863 - pte_unmap(page_table);
82864 -
82865 - /* Check if we need to add a guard page to the stack */
82866 - if (check_stack_guard_page(vma, address) < 0)
82867 - return VM_FAULT_SIGBUS;
82868 -
82869 - /* Use the zero-page for reads */
82870 if (!(flags & FAULT_FLAG_WRITE)) {
82871 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
82872 vma->vm_page_prot));
82873 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82874 + ptl = pte_lockptr(mm, pmd);
82875 + spin_lock(ptl);
82876 if (!pte_none(*page_table))
82877 goto unlock;
82878 goto setpte;
82879 }
82880
82881 /* Allocate our own private page. */
82882 + pte_unmap(page_table);
82883 +
82884 if (unlikely(anon_vma_prepare(vma)))
82885 goto oom;
82886 page = alloc_zeroed_user_highpage_movable(vma, address);
82887 @@ -3253,6 +3431,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82888 if (!pte_none(*page_table))
82889 goto release;
82890
82891 +#ifdef CONFIG_PAX_SEGMEXEC
82892 + if (pax_find_mirror_vma(vma))
82893 + BUG_ON(!trylock_page(page));
82894 +#endif
82895 +
82896 inc_mm_counter_fast(mm, MM_ANONPAGES);
82897 page_add_new_anon_rmap(page, vma, address);
82898 setpte:
82899 @@ -3260,6 +3443,12 @@ setpte:
82900
82901 /* No need to invalidate - it was non-present before */
82902 update_mmu_cache(vma, address, page_table);
82903 +
82904 +#ifdef CONFIG_PAX_SEGMEXEC
82905 + if (page)
82906 + pax_mirror_anon_pte(vma, address, page, ptl);
82907 +#endif
82908 +
82909 unlock:
82910 pte_unmap_unlock(page_table, ptl);
82911 return 0;
82912 @@ -3403,6 +3592,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82913 */
82914 /* Only go through if we didn't race with anybody else... */
82915 if (likely(pte_same(*page_table, orig_pte))) {
82916 +
82917 +#ifdef CONFIG_PAX_SEGMEXEC
82918 + if (anon && pax_find_mirror_vma(vma))
82919 + BUG_ON(!trylock_page(page));
82920 +#endif
82921 +
82922 flush_icache_page(vma, page);
82923 entry = mk_pte(page, vma->vm_page_prot);
82924 if (flags & FAULT_FLAG_WRITE)
82925 @@ -3422,6 +3617,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82926
82927 /* no need to invalidate: a not-present page won't be cached */
82928 update_mmu_cache(vma, address, page_table);
82929 +
82930 +#ifdef CONFIG_PAX_SEGMEXEC
82931 + if (anon)
82932 + pax_mirror_anon_pte(vma, address, page, ptl);
82933 + else
82934 + pax_mirror_file_pte(vma, address, page, ptl);
82935 +#endif
82936 +
82937 } else {
82938 if (cow_page)
82939 mem_cgroup_uncharge_page(cow_page);
82940 @@ -3743,6 +3946,12 @@ int handle_pte_fault(struct mm_struct *mm,
82941 if (flags & FAULT_FLAG_WRITE)
82942 flush_tlb_fix_spurious_fault(vma, address);
82943 }
82944 +
82945 +#ifdef CONFIG_PAX_SEGMEXEC
82946 + pax_mirror_pte(vma, address, pte, pmd, ptl);
82947 + return 0;
82948 +#endif
82949 +
82950 unlock:
82951 pte_unmap_unlock(pte, ptl);
82952 return 0;
82953 @@ -3759,6 +3968,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82954 pmd_t *pmd;
82955 pte_t *pte;
82956
82957 +#ifdef CONFIG_PAX_SEGMEXEC
82958 + struct vm_area_struct *vma_m;
82959 +#endif
82960 +
82961 __set_current_state(TASK_RUNNING);
82962
82963 count_vm_event(PGFAULT);
82964 @@ -3770,6 +3983,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82965 if (unlikely(is_vm_hugetlb_page(vma)))
82966 return hugetlb_fault(mm, vma, address, flags);
82967
82968 +#ifdef CONFIG_PAX_SEGMEXEC
82969 + vma_m = pax_find_mirror_vma(vma);
82970 + if (vma_m) {
82971 + unsigned long address_m;
82972 + pgd_t *pgd_m;
82973 + pud_t *pud_m;
82974 + pmd_t *pmd_m;
82975 +
82976 + if (vma->vm_start > vma_m->vm_start) {
82977 + address_m = address;
82978 + address -= SEGMEXEC_TASK_SIZE;
82979 + vma = vma_m;
82980 + } else
82981 + address_m = address + SEGMEXEC_TASK_SIZE;
82982 +
82983 + pgd_m = pgd_offset(mm, address_m);
82984 + pud_m = pud_alloc(mm, pgd_m, address_m);
82985 + if (!pud_m)
82986 + return VM_FAULT_OOM;
82987 + pmd_m = pmd_alloc(mm, pud_m, address_m);
82988 + if (!pmd_m)
82989 + return VM_FAULT_OOM;
82990 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
82991 + return VM_FAULT_OOM;
82992 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
82993 + }
82994 +#endif
82995 +
82996 retry:
82997 pgd = pgd_offset(mm, address);
82998 pud = pud_alloc(mm, pgd, address);
82999 @@ -3868,6 +4109,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
83000 spin_unlock(&mm->page_table_lock);
83001 return 0;
83002 }
83003 +
83004 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
83005 +{
83006 + pud_t *new = pud_alloc_one(mm, address);
83007 + if (!new)
83008 + return -ENOMEM;
83009 +
83010 + smp_wmb(); /* See comment in __pte_alloc */
83011 +
83012 + spin_lock(&mm->page_table_lock);
83013 + if (pgd_present(*pgd)) /* Another has populated it */
83014 + pud_free(mm, new);
83015 + else
83016 + pgd_populate_kernel(mm, pgd, new);
83017 + spin_unlock(&mm->page_table_lock);
83018 + return 0;
83019 +}
83020 #endif /* __PAGETABLE_PUD_FOLDED */
83021
83022 #ifndef __PAGETABLE_PMD_FOLDED
83023 @@ -3898,6 +4156,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
83024 spin_unlock(&mm->page_table_lock);
83025 return 0;
83026 }
83027 +
83028 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
83029 +{
83030 + pmd_t *new = pmd_alloc_one(mm, address);
83031 + if (!new)
83032 + return -ENOMEM;
83033 +
83034 + smp_wmb(); /* See comment in __pte_alloc */
83035 +
83036 + spin_lock(&mm->page_table_lock);
83037 +#ifndef __ARCH_HAS_4LEVEL_HACK
83038 + if (pud_present(*pud)) /* Another has populated it */
83039 + pmd_free(mm, new);
83040 + else
83041 + pud_populate_kernel(mm, pud, new);
83042 +#else
83043 + if (pgd_present(*pud)) /* Another has populated it */
83044 + pmd_free(mm, new);
83045 + else
83046 + pgd_populate_kernel(mm, pud, new);
83047 +#endif /* __ARCH_HAS_4LEVEL_HACK */
83048 + spin_unlock(&mm->page_table_lock);
83049 + return 0;
83050 +}
83051 #endif /* __PAGETABLE_PMD_FOLDED */
83052
83053 #if !defined(__HAVE_ARCH_GATE_AREA)
83054 @@ -3911,7 +4193,7 @@ static int __init gate_vma_init(void)
83055 gate_vma.vm_start = FIXADDR_USER_START;
83056 gate_vma.vm_end = FIXADDR_USER_END;
83057 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
83058 - gate_vma.vm_page_prot = __P101;
83059 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
83060
83061 return 0;
83062 }
83063 @@ -4045,8 +4327,8 @@ out:
83064 return ret;
83065 }
83066
83067 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
83068 - void *buf, int len, int write)
83069 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
83070 + void *buf, size_t len, int write)
83071 {
83072 resource_size_t phys_addr;
83073 unsigned long prot = 0;
83074 @@ -4071,8 +4353,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
83075 * Access another process' address space as given in mm. If non-NULL, use the
83076 * given task for page fault accounting.
83077 */
83078 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83079 - unsigned long addr, void *buf, int len, int write)
83080 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83081 + unsigned long addr, void *buf, size_t len, int write)
83082 {
83083 struct vm_area_struct *vma;
83084 void *old_buf = buf;
83085 @@ -4080,7 +4362,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83086 down_read(&mm->mmap_sem);
83087 /* ignore errors, just check how much was successfully transferred */
83088 while (len) {
83089 - int bytes, ret, offset;
83090 + ssize_t bytes, ret, offset;
83091 void *maddr;
83092 struct page *page = NULL;
83093
83094 @@ -4139,8 +4421,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83095 *
83096 * The caller must hold a reference on @mm.
83097 */
83098 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83099 - void *buf, int len, int write)
83100 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83101 + void *buf, size_t len, int write)
83102 {
83103 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83104 }
83105 @@ -4150,11 +4432,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83106 * Source/target buffer must be kernel space,
83107 * Do not walk the page table directly, use get_user_pages
83108 */
83109 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
83110 - void *buf, int len, int write)
83111 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
83112 + void *buf, size_t len, int write)
83113 {
83114 struct mm_struct *mm;
83115 - int ret;
83116 + ssize_t ret;
83117
83118 mm = get_task_mm(tsk);
83119 if (!mm)
83120 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
83121 index 7431001..0f8344e 100644
83122 --- a/mm/mempolicy.c
83123 +++ b/mm/mempolicy.c
83124 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
83125 unsigned long vmstart;
83126 unsigned long vmend;
83127
83128 +#ifdef CONFIG_PAX_SEGMEXEC
83129 + struct vm_area_struct *vma_m;
83130 +#endif
83131 +
83132 vma = find_vma(mm, start);
83133 if (!vma || vma->vm_start > start)
83134 return -EFAULT;
83135 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
83136 if (err)
83137 goto out;
83138 }
83139 +
83140 err = vma_replace_policy(vma, new_pol);
83141 if (err)
83142 goto out;
83143 +
83144 +#ifdef CONFIG_PAX_SEGMEXEC
83145 + vma_m = pax_find_mirror_vma(vma);
83146 + if (vma_m) {
83147 + err = vma_replace_policy(vma_m, new_pol);
83148 + if (err)
83149 + goto out;
83150 + }
83151 +#endif
83152 +
83153 }
83154
83155 out:
83156 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
83157
83158 if (end < start)
83159 return -EINVAL;
83160 +
83161 +#ifdef CONFIG_PAX_SEGMEXEC
83162 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83163 + if (end > SEGMEXEC_TASK_SIZE)
83164 + return -EINVAL;
83165 + } else
83166 +#endif
83167 +
83168 + if (end > TASK_SIZE)
83169 + return -EINVAL;
83170 +
83171 if (end == start)
83172 return 0;
83173
83174 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
83175 */
83176 tcred = __task_cred(task);
83177 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
83178 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
83179 - !capable(CAP_SYS_NICE)) {
83180 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
83181 rcu_read_unlock();
83182 err = -EPERM;
83183 goto out_put;
83184 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
83185 goto out;
83186 }
83187
83188 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
83189 + if (mm != current->mm &&
83190 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
83191 + mmput(mm);
83192 + err = -EPERM;
83193 + goto out;
83194 + }
83195 +#endif
83196 +
83197 err = do_migrate_pages(mm, old, new,
83198 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
83199
83200 diff --git a/mm/migrate.c b/mm/migrate.c
83201 index 6f0c244..6d1ae32 100644
83202 --- a/mm/migrate.c
83203 +++ b/mm/migrate.c
83204 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
83205 */
83206 tcred = __task_cred(task);
83207 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
83208 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
83209 - !capable(CAP_SYS_NICE)) {
83210 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
83211 rcu_read_unlock();
83212 err = -EPERM;
83213 goto out;
83214 diff --git a/mm/mlock.c b/mm/mlock.c
83215 index 79b7cf7..9944291 100644
83216 --- a/mm/mlock.c
83217 +++ b/mm/mlock.c
83218 @@ -13,6 +13,7 @@
83219 #include <linux/pagemap.h>
83220 #include <linux/mempolicy.h>
83221 #include <linux/syscalls.h>
83222 +#include <linux/security.h>
83223 #include <linux/sched.h>
83224 #include <linux/export.h>
83225 #include <linux/rmap.h>
83226 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
83227 {
83228 unsigned long nstart, end, tmp;
83229 struct vm_area_struct * vma, * prev;
83230 - int error;
83231 + int error = 0;
83232
83233 VM_BUG_ON(start & ~PAGE_MASK);
83234 VM_BUG_ON(len != PAGE_ALIGN(len));
83235 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
83236 return -EINVAL;
83237 if (end == start)
83238 return 0;
83239 + if (end > TASK_SIZE)
83240 + return -EINVAL;
83241 +
83242 vma = find_vma(current->mm, start);
83243 if (!vma || vma->vm_start > start)
83244 return -ENOMEM;
83245 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
83246 for (nstart = start ; ; ) {
83247 vm_flags_t newflags;
83248
83249 +#ifdef CONFIG_PAX_SEGMEXEC
83250 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
83251 + break;
83252 +#endif
83253 +
83254 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
83255
83256 newflags = vma->vm_flags & ~VM_LOCKED;
83257 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
83258 lock_limit >>= PAGE_SHIFT;
83259
83260 /* check against resource limits */
83261 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
83262 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
83263 error = do_mlock(start, len, 1);
83264 up_write(&current->mm->mmap_sem);
83265 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
83266 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
83267 vm_flags_t newflags;
83268
83269 +#ifdef CONFIG_PAX_SEGMEXEC
83270 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
83271 + break;
83272 +#endif
83273 +
83274 newflags = vma->vm_flags & ~VM_LOCKED;
83275 if (flags & MCL_CURRENT)
83276 newflags |= VM_LOCKED;
83277 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
83278 lock_limit >>= PAGE_SHIFT;
83279
83280 ret = -ENOMEM;
83281 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
83282 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
83283 capable(CAP_IPC_LOCK))
83284 ret = do_mlockall(flags);
83285 diff --git a/mm/mmap.c b/mm/mmap.c
83286 index f681e18..623110e 100644
83287 --- a/mm/mmap.c
83288 +++ b/mm/mmap.c
83289 @@ -36,6 +36,7 @@
83290 #include <linux/sched/sysctl.h>
83291 #include <linux/notifier.h>
83292 #include <linux/memory.h>
83293 +#include <linux/random.h>
83294
83295 #include <asm/uaccess.h>
83296 #include <asm/cacheflush.h>
83297 @@ -52,6 +53,16 @@
83298 #define arch_rebalance_pgtables(addr, len) (addr)
83299 #endif
83300
83301 +static inline void verify_mm_writelocked(struct mm_struct *mm)
83302 +{
83303 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
83304 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83305 + up_read(&mm->mmap_sem);
83306 + BUG();
83307 + }
83308 +#endif
83309 +}
83310 +
83311 static void unmap_region(struct mm_struct *mm,
83312 struct vm_area_struct *vma, struct vm_area_struct *prev,
83313 unsigned long start, unsigned long end);
83314 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
83315 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
83316 *
83317 */
83318 -pgprot_t protection_map[16] = {
83319 +pgprot_t protection_map[16] __read_only = {
83320 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
83321 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
83322 };
83323
83324 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
83325 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
83326 {
83327 - return __pgprot(pgprot_val(protection_map[vm_flags &
83328 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
83329 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
83330 pgprot_val(arch_vm_get_page_prot(vm_flags)));
83331 +
83332 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
83333 + if (!(__supported_pte_mask & _PAGE_NX) &&
83334 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
83335 + (vm_flags & (VM_READ | VM_WRITE)))
83336 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
83337 +#endif
83338 +
83339 + return prot;
83340 }
83341 EXPORT_SYMBOL(vm_get_page_prot);
83342
83343 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
83344 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
83345 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
83346 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
83347 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
83348 /*
83349 * Make sure vm_committed_as in one cacheline and not cacheline shared with
83350 * other variables. It can be updated by several CPUs frequently.
83351 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
83352 struct vm_area_struct *next = vma->vm_next;
83353
83354 might_sleep();
83355 + BUG_ON(vma->vm_mirror);
83356 if (vma->vm_ops && vma->vm_ops->close)
83357 vma->vm_ops->close(vma);
83358 if (vma->vm_file)
83359 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
83360 * not page aligned -Ram Gupta
83361 */
83362 rlim = rlimit(RLIMIT_DATA);
83363 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
83364 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
83365 (mm->end_data - mm->start_data) > rlim)
83366 goto out;
83367 @@ -933,6 +956,12 @@ static int
83368 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
83369 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
83370 {
83371 +
83372 +#ifdef CONFIG_PAX_SEGMEXEC
83373 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
83374 + return 0;
83375 +#endif
83376 +
83377 if (is_mergeable_vma(vma, file, vm_flags) &&
83378 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
83379 if (vma->vm_pgoff == vm_pgoff)
83380 @@ -952,6 +981,12 @@ static int
83381 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
83382 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
83383 {
83384 +
83385 +#ifdef CONFIG_PAX_SEGMEXEC
83386 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
83387 + return 0;
83388 +#endif
83389 +
83390 if (is_mergeable_vma(vma, file, vm_flags) &&
83391 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
83392 pgoff_t vm_pglen;
83393 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
83394 struct vm_area_struct *vma_merge(struct mm_struct *mm,
83395 struct vm_area_struct *prev, unsigned long addr,
83396 unsigned long end, unsigned long vm_flags,
83397 - struct anon_vma *anon_vma, struct file *file,
83398 + struct anon_vma *anon_vma, struct file *file,
83399 pgoff_t pgoff, struct mempolicy *policy)
83400 {
83401 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
83402 struct vm_area_struct *area, *next;
83403 int err;
83404
83405 +#ifdef CONFIG_PAX_SEGMEXEC
83406 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
83407 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
83408 +
83409 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
83410 +#endif
83411 +
83412 /*
83413 * We later require that vma->vm_flags == vm_flags,
83414 * so this tests vma->vm_flags & VM_SPECIAL, too.
83415 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
83416 if (next && next->vm_end == end) /* cases 6, 7, 8 */
83417 next = next->vm_next;
83418
83419 +#ifdef CONFIG_PAX_SEGMEXEC
83420 + if (prev)
83421 + prev_m = pax_find_mirror_vma(prev);
83422 + if (area)
83423 + area_m = pax_find_mirror_vma(area);
83424 + if (next)
83425 + next_m = pax_find_mirror_vma(next);
83426 +#endif
83427 +
83428 /*
83429 * Can it merge with the predecessor?
83430 */
83431 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
83432 /* cases 1, 6 */
83433 err = vma_adjust(prev, prev->vm_start,
83434 next->vm_end, prev->vm_pgoff, NULL);
83435 - } else /* cases 2, 5, 7 */
83436 +
83437 +#ifdef CONFIG_PAX_SEGMEXEC
83438 + if (!err && prev_m)
83439 + err = vma_adjust(prev_m, prev_m->vm_start,
83440 + next_m->vm_end, prev_m->vm_pgoff, NULL);
83441 +#endif
83442 +
83443 + } else { /* cases 2, 5, 7 */
83444 err = vma_adjust(prev, prev->vm_start,
83445 end, prev->vm_pgoff, NULL);
83446 +
83447 +#ifdef CONFIG_PAX_SEGMEXEC
83448 + if (!err && prev_m)
83449 + err = vma_adjust(prev_m, prev_m->vm_start,
83450 + end_m, prev_m->vm_pgoff, NULL);
83451 +#endif
83452 +
83453 + }
83454 if (err)
83455 return NULL;
83456 khugepaged_enter_vma_merge(prev);
83457 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
83458 mpol_equal(policy, vma_policy(next)) &&
83459 can_vma_merge_before(next, vm_flags,
83460 anon_vma, file, pgoff+pglen)) {
83461 - if (prev && addr < prev->vm_end) /* case 4 */
83462 + if (prev && addr < prev->vm_end) { /* case 4 */
83463 err = vma_adjust(prev, prev->vm_start,
83464 addr, prev->vm_pgoff, NULL);
83465 - else /* cases 3, 8 */
83466 +
83467 +#ifdef CONFIG_PAX_SEGMEXEC
83468 + if (!err && prev_m)
83469 + err = vma_adjust(prev_m, prev_m->vm_start,
83470 + addr_m, prev_m->vm_pgoff, NULL);
83471 +#endif
83472 +
83473 + } else { /* cases 3, 8 */
83474 err = vma_adjust(area, addr, next->vm_end,
83475 next->vm_pgoff - pglen, NULL);
83476 +
83477 +#ifdef CONFIG_PAX_SEGMEXEC
83478 + if (!err && area_m)
83479 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
83480 + next_m->vm_pgoff - pglen, NULL);
83481 +#endif
83482 +
83483 + }
83484 if (err)
83485 return NULL;
83486 khugepaged_enter_vma_merge(area);
83487 @@ -1165,8 +1246,10 @@ none:
83488 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
83489 struct file *file, long pages)
83490 {
83491 - const unsigned long stack_flags
83492 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
83493 +
83494 +#ifdef CONFIG_PAX_RANDMMAP
83495 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
83496 +#endif
83497
83498 mm->total_vm += pages;
83499
83500 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
83501 mm->shared_vm += pages;
83502 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
83503 mm->exec_vm += pages;
83504 - } else if (flags & stack_flags)
83505 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
83506 mm->stack_vm += pages;
83507 }
83508 #endif /* CONFIG_PROC_FS */
83509 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83510 * (the exception is when the underlying filesystem is noexec
83511 * mounted, in which case we dont add PROT_EXEC.)
83512 */
83513 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83514 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83515 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
83516 prot |= PROT_EXEC;
83517
83518 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83519 /* Obtain the address to map to. we verify (or select) it and ensure
83520 * that it represents a valid section of the address space.
83521 */
83522 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
83523 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
83524 if (addr & ~PAGE_MASK)
83525 return addr;
83526
83527 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83528 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
83529 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
83530
83531 +#ifdef CONFIG_PAX_MPROTECT
83532 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83533 +
83534 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
83535 + if (file && (vm_flags & VM_EXEC) && mm->binfmt &&
83536 + mm->binfmt->handle_mmap)
83537 + mm->binfmt->handle_mmap(file);
83538 +#endif
83539 +
83540 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83541 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
83542 + gr_log_rwxmmap(file);
83543 +
83544 +#ifdef CONFIG_PAX_EMUPLT
83545 + vm_flags &= ~VM_EXEC;
83546 +#else
83547 + return -EPERM;
83548 +#endif
83549 +
83550 + }
83551 +
83552 + if (!(vm_flags & VM_EXEC))
83553 + vm_flags &= ~VM_MAYEXEC;
83554 +#else
83555 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83556 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83557 +#endif
83558 + else
83559 + vm_flags &= ~VM_MAYWRITE;
83560 + }
83561 +#endif
83562 +
83563 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
83564 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
83565 + vm_flags &= ~VM_PAGEEXEC;
83566 +#endif
83567 +
83568 if (flags & MAP_LOCKED)
83569 if (!can_do_mlock())
83570 return -EPERM;
83571 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83572 locked += mm->locked_vm;
83573 lock_limit = rlimit(RLIMIT_MEMLOCK);
83574 lock_limit >>= PAGE_SHIFT;
83575 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
83576 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
83577 return -EAGAIN;
83578 }
83579 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
83580 vm_flags |= VM_NORESERVE;
83581 }
83582
83583 + if (!gr_acl_handle_mmap(file, prot))
83584 + return -EACCES;
83585 +
83586 addr = mmap_region(file, addr, len, vm_flags, pgoff);
83587 if (!IS_ERR_VALUE(addr) &&
83588 ((vm_flags & VM_LOCKED) ||
83589 @@ -1432,7 +1556,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
83590 vm_flags_t vm_flags = vma->vm_flags;
83591
83592 /* If it was private or non-writable, the write bit is already clear */
83593 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
83594 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
83595 return 0;
83596
83597 /* The backer wishes to know when pages are first written to? */
83598 @@ -1480,7 +1604,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
83599 unsigned long charged = 0;
83600 struct inode *inode = file ? file_inode(file) : NULL;
83601
83602 +#ifdef CONFIG_PAX_SEGMEXEC
83603 + struct vm_area_struct *vma_m = NULL;
83604 +#endif
83605 +
83606 + /*
83607 + * mm->mmap_sem is required to protect against another thread
83608 + * changing the mappings in case we sleep.
83609 + */
83610 + verify_mm_writelocked(mm);
83611 +
83612 /* Check against address space limit. */
83613 +
83614 +#ifdef CONFIG_PAX_RANDMMAP
83615 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
83616 +#endif
83617 +
83618 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
83619 unsigned long nr_pages;
83620
83621 @@ -1499,11 +1638,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
83622
83623 /* Clear old maps */
83624 error = -ENOMEM;
83625 -munmap_back:
83626 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83627 if (do_munmap(mm, addr, len))
83628 return -ENOMEM;
83629 - goto munmap_back;
83630 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83631 }
83632
83633 /*
83634 @@ -1534,6 +1672,16 @@ munmap_back:
83635 goto unacct_error;
83636 }
83637
83638 +#ifdef CONFIG_PAX_SEGMEXEC
83639 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
83640 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83641 + if (!vma_m) {
83642 + error = -ENOMEM;
83643 + goto free_vma;
83644 + }
83645 + }
83646 +#endif
83647 +
83648 vma->vm_mm = mm;
83649 vma->vm_start = addr;
83650 vma->vm_end = addr + len;
83651 @@ -1558,6 +1706,13 @@ munmap_back:
83652 if (error)
83653 goto unmap_and_free_vma;
83654
83655 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
83656 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
83657 + vma->vm_flags |= VM_PAGEEXEC;
83658 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83659 + }
83660 +#endif
83661 +
83662 /* Can addr have changed??
83663 *
83664 * Answer: Yes, several device drivers can do it in their
83665 @@ -1596,6 +1751,11 @@ munmap_back:
83666 vma_link(mm, vma, prev, rb_link, rb_parent);
83667 file = vma->vm_file;
83668
83669 +#ifdef CONFIG_PAX_SEGMEXEC
83670 + if (vma_m)
83671 + BUG_ON(pax_mirror_vma(vma_m, vma));
83672 +#endif
83673 +
83674 /* Once vma denies write, undo our temporary denial count */
83675 if (correct_wcount)
83676 atomic_inc(&inode->i_writecount);
83677 @@ -1603,6 +1763,7 @@ out:
83678 perf_event_mmap(vma);
83679
83680 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
83681 + track_exec_limit(mm, addr, addr + len, vm_flags);
83682 if (vm_flags & VM_LOCKED) {
83683 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
83684 vma == get_gate_vma(current->mm)))
83685 @@ -1626,6 +1787,12 @@ unmap_and_free_vma:
83686 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
83687 charged = 0;
83688 free_vma:
83689 +
83690 +#ifdef CONFIG_PAX_SEGMEXEC
83691 + if (vma_m)
83692 + kmem_cache_free(vm_area_cachep, vma_m);
83693 +#endif
83694 +
83695 kmem_cache_free(vm_area_cachep, vma);
83696 unacct_error:
83697 if (charged)
83698 @@ -1633,7 +1800,63 @@ unacct_error:
83699 return error;
83700 }
83701
83702 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
83703 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
83704 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
83705 +{
83706 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
83707 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
83708 +
83709 + return 0;
83710 +}
83711 +#endif
83712 +
83713 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
83714 +{
83715 + if (!vma) {
83716 +#ifdef CONFIG_STACK_GROWSUP
83717 + if (addr > sysctl_heap_stack_gap)
83718 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
83719 + else
83720 + vma = find_vma(current->mm, 0);
83721 + if (vma && (vma->vm_flags & VM_GROWSUP))
83722 + return false;
83723 +#endif
83724 + return true;
83725 + }
83726 +
83727 + if (addr + len > vma->vm_start)
83728 + return false;
83729 +
83730 + if (vma->vm_flags & VM_GROWSDOWN)
83731 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
83732 +#ifdef CONFIG_STACK_GROWSUP
83733 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
83734 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
83735 +#endif
83736 + else if (offset)
83737 + return offset <= vma->vm_start - addr - len;
83738 +
83739 + return true;
83740 +}
83741 +
83742 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
83743 +{
83744 + if (vma->vm_start < len)
83745 + return -ENOMEM;
83746 +
83747 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
83748 + if (offset <= vma->vm_start - len)
83749 + return vma->vm_start - len - offset;
83750 + else
83751 + return -ENOMEM;
83752 + }
83753 +
83754 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
83755 + return vma->vm_start - len - sysctl_heap_stack_gap;
83756 + return -ENOMEM;
83757 +}
83758 +
83759 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
83760 {
83761 /*
83762 * We implement the search by looking for an rbtree node that
83763 @@ -1681,11 +1904,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
83764 }
83765 }
83766
83767 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
83768 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
83769 check_current:
83770 /* Check if current node has a suitable gap */
83771 if (gap_start > high_limit)
83772 return -ENOMEM;
83773 +
83774 + if (gap_end - gap_start > info->threadstack_offset)
83775 + gap_start += info->threadstack_offset;
83776 + else
83777 + gap_start = gap_end;
83778 +
83779 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
83780 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83781 + gap_start += sysctl_heap_stack_gap;
83782 + else
83783 + gap_start = gap_end;
83784 + }
83785 + if (vma->vm_flags & VM_GROWSDOWN) {
83786 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83787 + gap_end -= sysctl_heap_stack_gap;
83788 + else
83789 + gap_end = gap_start;
83790 + }
83791 if (gap_end >= low_limit && gap_end - gap_start >= length)
83792 goto found;
83793
83794 @@ -1735,7 +1976,7 @@ found:
83795 return gap_start;
83796 }
83797
83798 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
83799 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
83800 {
83801 struct mm_struct *mm = current->mm;
83802 struct vm_area_struct *vma;
83803 @@ -1789,6 +2030,24 @@ check_current:
83804 gap_end = vma->vm_start;
83805 if (gap_end < low_limit)
83806 return -ENOMEM;
83807 +
83808 + if (gap_end - gap_start > info->threadstack_offset)
83809 + gap_end -= info->threadstack_offset;
83810 + else
83811 + gap_end = gap_start;
83812 +
83813 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
83814 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83815 + gap_start += sysctl_heap_stack_gap;
83816 + else
83817 + gap_start = gap_end;
83818 + }
83819 + if (vma->vm_flags & VM_GROWSDOWN) {
83820 + if (gap_end - gap_start > sysctl_heap_stack_gap)
83821 + gap_end -= sysctl_heap_stack_gap;
83822 + else
83823 + gap_end = gap_start;
83824 + }
83825 if (gap_start <= high_limit && gap_end - gap_start >= length)
83826 goto found;
83827
83828 @@ -1852,6 +2111,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83829 struct mm_struct *mm = current->mm;
83830 struct vm_area_struct *vma;
83831 struct vm_unmapped_area_info info;
83832 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83833
83834 if (len > TASK_SIZE)
83835 return -ENOMEM;
83836 @@ -1859,29 +2119,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83837 if (flags & MAP_FIXED)
83838 return addr;
83839
83840 +#ifdef CONFIG_PAX_RANDMMAP
83841 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83842 +#endif
83843 +
83844 if (addr) {
83845 addr = PAGE_ALIGN(addr);
83846 vma = find_vma(mm, addr);
83847 - if (TASK_SIZE - len >= addr &&
83848 - (!vma || addr + len <= vma->vm_start))
83849 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83850 return addr;
83851 }
83852
83853 info.flags = 0;
83854 info.length = len;
83855 info.low_limit = TASK_UNMAPPED_BASE;
83856 +
83857 +#ifdef CONFIG_PAX_RANDMMAP
83858 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83859 + info.low_limit += mm->delta_mmap;
83860 +#endif
83861 +
83862 info.high_limit = TASK_SIZE;
83863 info.align_mask = 0;
83864 + info.threadstack_offset = offset;
83865 return vm_unmapped_area(&info);
83866 }
83867 #endif
83868
83869 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
83870 {
83871 +
83872 +#ifdef CONFIG_PAX_SEGMEXEC
83873 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83874 + return;
83875 +#endif
83876 +
83877 /*
83878 * Is this a new hole at the lowest possible address?
83879 */
83880 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
83881 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
83882 mm->free_area_cache = addr;
83883 }
83884
83885 @@ -1899,6 +2175,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83886 struct mm_struct *mm = current->mm;
83887 unsigned long addr = addr0;
83888 struct vm_unmapped_area_info info;
83889 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83890
83891 /* requested length too big for entire address space */
83892 if (len > TASK_SIZE)
83893 @@ -1907,12 +2184,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83894 if (flags & MAP_FIXED)
83895 return addr;
83896
83897 +#ifdef CONFIG_PAX_RANDMMAP
83898 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83899 +#endif
83900 +
83901 /* requesting a specific address */
83902 if (addr) {
83903 addr = PAGE_ALIGN(addr);
83904 vma = find_vma(mm, addr);
83905 - if (TASK_SIZE - len >= addr &&
83906 - (!vma || addr + len <= vma->vm_start))
83907 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83908 return addr;
83909 }
83910
83911 @@ -1921,6 +2201,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83912 info.low_limit = PAGE_SIZE;
83913 info.high_limit = mm->mmap_base;
83914 info.align_mask = 0;
83915 + info.threadstack_offset = offset;
83916 addr = vm_unmapped_area(&info);
83917
83918 /*
83919 @@ -1933,6 +2214,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83920 VM_BUG_ON(addr != -ENOMEM);
83921 info.flags = 0;
83922 info.low_limit = TASK_UNMAPPED_BASE;
83923 +
83924 +#ifdef CONFIG_PAX_RANDMMAP
83925 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83926 + info.low_limit += mm->delta_mmap;
83927 +#endif
83928 +
83929 info.high_limit = TASK_SIZE;
83930 addr = vm_unmapped_area(&info);
83931 }
83932 @@ -1943,6 +2230,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83933
83934 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83935 {
83936 +
83937 +#ifdef CONFIG_PAX_SEGMEXEC
83938 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83939 + return;
83940 +#endif
83941 +
83942 /*
83943 * Is this a new hole at the highest possible address?
83944 */
83945 @@ -1950,8 +2243,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83946 mm->free_area_cache = addr;
83947
83948 /* dont allow allocations above current base */
83949 - if (mm->free_area_cache > mm->mmap_base)
83950 + if (mm->free_area_cache > mm->mmap_base) {
83951 mm->free_area_cache = mm->mmap_base;
83952 + mm->cached_hole_size = ~0UL;
83953 + }
83954 }
83955
83956 unsigned long
83957 @@ -2047,6 +2342,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
83958 return vma;
83959 }
83960
83961 +#ifdef CONFIG_PAX_SEGMEXEC
83962 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
83963 +{
83964 + struct vm_area_struct *vma_m;
83965 +
83966 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
83967 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
83968 + BUG_ON(vma->vm_mirror);
83969 + return NULL;
83970 + }
83971 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
83972 + vma_m = vma->vm_mirror;
83973 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
83974 + BUG_ON(vma->vm_file != vma_m->vm_file);
83975 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
83976 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
83977 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
83978 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
83979 + return vma_m;
83980 +}
83981 +#endif
83982 +
83983 /*
83984 * Verify that the stack growth is acceptable and
83985 * update accounting. This is shared with both the
83986 @@ -2063,6 +2380,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83987 return -ENOMEM;
83988
83989 /* Stack limit test */
83990 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
83991 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
83992 return -ENOMEM;
83993
83994 @@ -2073,6 +2391,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83995 locked = mm->locked_vm + grow;
83996 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
83997 limit >>= PAGE_SHIFT;
83998 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
83999 if (locked > limit && !capable(CAP_IPC_LOCK))
84000 return -ENOMEM;
84001 }
84002 @@ -2102,37 +2421,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
84003 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
84004 * vma is the last one with address > vma->vm_end. Have to extend vma.
84005 */
84006 +#ifndef CONFIG_IA64
84007 +static
84008 +#endif
84009 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
84010 {
84011 int error;
84012 + bool locknext;
84013
84014 if (!(vma->vm_flags & VM_GROWSUP))
84015 return -EFAULT;
84016
84017 + /* Also guard against wrapping around to address 0. */
84018 + if (address < PAGE_ALIGN(address+1))
84019 + address = PAGE_ALIGN(address+1);
84020 + else
84021 + return -ENOMEM;
84022 +
84023 /*
84024 * We must make sure the anon_vma is allocated
84025 * so that the anon_vma locking is not a noop.
84026 */
84027 if (unlikely(anon_vma_prepare(vma)))
84028 return -ENOMEM;
84029 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
84030 + if (locknext && anon_vma_prepare(vma->vm_next))
84031 + return -ENOMEM;
84032 vma_lock_anon_vma(vma);
84033 + if (locknext)
84034 + vma_lock_anon_vma(vma->vm_next);
84035
84036 /*
84037 * vma->vm_start/vm_end cannot change under us because the caller
84038 * is required to hold the mmap_sem in read mode. We need the
84039 - * anon_vma lock to serialize against concurrent expand_stacks.
84040 - * Also guard against wrapping around to address 0.
84041 + * anon_vma locks to serialize against concurrent expand_stacks
84042 + * and expand_upwards.
84043 */
84044 - if (address < PAGE_ALIGN(address+4))
84045 - address = PAGE_ALIGN(address+4);
84046 - else {
84047 - vma_unlock_anon_vma(vma);
84048 - return -ENOMEM;
84049 - }
84050 error = 0;
84051
84052 /* Somebody else might have raced and expanded it already */
84053 - if (address > vma->vm_end) {
84054 + 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)
84055 + error = -ENOMEM;
84056 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
84057 unsigned long size, grow;
84058
84059 size = address - vma->vm_start;
84060 @@ -2167,6 +2497,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
84061 }
84062 }
84063 }
84064 + if (locknext)
84065 + vma_unlock_anon_vma(vma->vm_next);
84066 vma_unlock_anon_vma(vma);
84067 khugepaged_enter_vma_merge(vma);
84068 validate_mm(vma->vm_mm);
84069 @@ -2181,6 +2513,8 @@ int expand_downwards(struct vm_area_struct *vma,
84070 unsigned long address)
84071 {
84072 int error;
84073 + bool lockprev = false;
84074 + struct vm_area_struct *prev;
84075
84076 /*
84077 * We must make sure the anon_vma is allocated
84078 @@ -2194,6 +2528,15 @@ int expand_downwards(struct vm_area_struct *vma,
84079 if (error)
84080 return error;
84081
84082 + prev = vma->vm_prev;
84083 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
84084 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
84085 +#endif
84086 + if (lockprev && anon_vma_prepare(prev))
84087 + return -ENOMEM;
84088 + if (lockprev)
84089 + vma_lock_anon_vma(prev);
84090 +
84091 vma_lock_anon_vma(vma);
84092
84093 /*
84094 @@ -2203,9 +2546,17 @@ int expand_downwards(struct vm_area_struct *vma,
84095 */
84096
84097 /* Somebody else might have raced and expanded it already */
84098 - if (address < vma->vm_start) {
84099 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
84100 + error = -ENOMEM;
84101 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
84102 unsigned long size, grow;
84103
84104 +#ifdef CONFIG_PAX_SEGMEXEC
84105 + struct vm_area_struct *vma_m;
84106 +
84107 + vma_m = pax_find_mirror_vma(vma);
84108 +#endif
84109 +
84110 size = vma->vm_end - address;
84111 grow = (vma->vm_start - address) >> PAGE_SHIFT;
84112
84113 @@ -2230,13 +2581,27 @@ int expand_downwards(struct vm_area_struct *vma,
84114 vma->vm_pgoff -= grow;
84115 anon_vma_interval_tree_post_update_vma(vma);
84116 vma_gap_update(vma);
84117 +
84118 +#ifdef CONFIG_PAX_SEGMEXEC
84119 + if (vma_m) {
84120 + anon_vma_interval_tree_pre_update_vma(vma_m);
84121 + vma_m->vm_start -= grow << PAGE_SHIFT;
84122 + vma_m->vm_pgoff -= grow;
84123 + anon_vma_interval_tree_post_update_vma(vma_m);
84124 + vma_gap_update(vma_m);
84125 + }
84126 +#endif
84127 +
84128 spin_unlock(&vma->vm_mm->page_table_lock);
84129
84130 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
84131 perf_event_mmap(vma);
84132 }
84133 }
84134 }
84135 vma_unlock_anon_vma(vma);
84136 + if (lockprev)
84137 + vma_unlock_anon_vma(prev);
84138 khugepaged_enter_vma_merge(vma);
84139 validate_mm(vma->vm_mm);
84140 return error;
84141 @@ -2334,6 +2699,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
84142 do {
84143 long nrpages = vma_pages(vma);
84144
84145 +#ifdef CONFIG_PAX_SEGMEXEC
84146 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
84147 + vma = remove_vma(vma);
84148 + continue;
84149 + }
84150 +#endif
84151 +
84152 if (vma->vm_flags & VM_ACCOUNT)
84153 nr_accounted += nrpages;
84154 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
84155 @@ -2379,6 +2751,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
84156 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
84157 vma->vm_prev = NULL;
84158 do {
84159 +
84160 +#ifdef CONFIG_PAX_SEGMEXEC
84161 + if (vma->vm_mirror) {
84162 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
84163 + vma->vm_mirror->vm_mirror = NULL;
84164 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
84165 + vma->vm_mirror = NULL;
84166 + }
84167 +#endif
84168 +
84169 vma_rb_erase(vma, &mm->mm_rb);
84170 mm->map_count--;
84171 tail_vma = vma;
84172 @@ -2410,14 +2792,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84173 struct vm_area_struct *new;
84174 int err = -ENOMEM;
84175
84176 +#ifdef CONFIG_PAX_SEGMEXEC
84177 + struct vm_area_struct *vma_m, *new_m = NULL;
84178 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
84179 +#endif
84180 +
84181 if (is_vm_hugetlb_page(vma) && (addr &
84182 ~(huge_page_mask(hstate_vma(vma)))))
84183 return -EINVAL;
84184
84185 +#ifdef CONFIG_PAX_SEGMEXEC
84186 + vma_m = pax_find_mirror_vma(vma);
84187 +#endif
84188 +
84189 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
84190 if (!new)
84191 goto out_err;
84192
84193 +#ifdef CONFIG_PAX_SEGMEXEC
84194 + if (vma_m) {
84195 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
84196 + if (!new_m) {
84197 + kmem_cache_free(vm_area_cachep, new);
84198 + goto out_err;
84199 + }
84200 + }
84201 +#endif
84202 +
84203 /* most fields are the same, copy all, and then fixup */
84204 *new = *vma;
84205
84206 @@ -2430,6 +2831,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84207 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
84208 }
84209
84210 +#ifdef CONFIG_PAX_SEGMEXEC
84211 + if (vma_m) {
84212 + *new_m = *vma_m;
84213 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
84214 + new_m->vm_mirror = new;
84215 + new->vm_mirror = new_m;
84216 +
84217 + if (new_below)
84218 + new_m->vm_end = addr_m;
84219 + else {
84220 + new_m->vm_start = addr_m;
84221 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
84222 + }
84223 + }
84224 +#endif
84225 +
84226 pol = mpol_dup(vma_policy(vma));
84227 if (IS_ERR(pol)) {
84228 err = PTR_ERR(pol);
84229 @@ -2452,6 +2869,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84230 else
84231 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
84232
84233 +#ifdef CONFIG_PAX_SEGMEXEC
84234 + if (!err && vma_m) {
84235 + if (anon_vma_clone(new_m, vma_m))
84236 + goto out_free_mpol;
84237 +
84238 + mpol_get(pol);
84239 + vma_set_policy(new_m, pol);
84240 +
84241 + if (new_m->vm_file)
84242 + get_file(new_m->vm_file);
84243 +
84244 + if (new_m->vm_ops && new_m->vm_ops->open)
84245 + new_m->vm_ops->open(new_m);
84246 +
84247 + if (new_below)
84248 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
84249 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
84250 + else
84251 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
84252 +
84253 + if (err) {
84254 + if (new_m->vm_ops && new_m->vm_ops->close)
84255 + new_m->vm_ops->close(new_m);
84256 + if (new_m->vm_file)
84257 + fput(new_m->vm_file);
84258 + mpol_put(pol);
84259 + }
84260 + }
84261 +#endif
84262 +
84263 /* Success. */
84264 if (!err)
84265 return 0;
84266 @@ -2461,10 +2908,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84267 new->vm_ops->close(new);
84268 if (new->vm_file)
84269 fput(new->vm_file);
84270 - unlink_anon_vmas(new);
84271 out_free_mpol:
84272 mpol_put(pol);
84273 out_free_vma:
84274 +
84275 +#ifdef CONFIG_PAX_SEGMEXEC
84276 + if (new_m) {
84277 + unlink_anon_vmas(new_m);
84278 + kmem_cache_free(vm_area_cachep, new_m);
84279 + }
84280 +#endif
84281 +
84282 + unlink_anon_vmas(new);
84283 kmem_cache_free(vm_area_cachep, new);
84284 out_err:
84285 return err;
84286 @@ -2477,6 +2932,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
84287 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84288 unsigned long addr, int new_below)
84289 {
84290 +
84291 +#ifdef CONFIG_PAX_SEGMEXEC
84292 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
84293 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
84294 + if (mm->map_count >= sysctl_max_map_count-1)
84295 + return -ENOMEM;
84296 + } else
84297 +#endif
84298 +
84299 if (mm->map_count >= sysctl_max_map_count)
84300 return -ENOMEM;
84301
84302 @@ -2488,11 +2952,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84303 * work. This now handles partial unmappings.
84304 * Jeremy Fitzhardinge <jeremy@goop.org>
84305 */
84306 +#ifdef CONFIG_PAX_SEGMEXEC
84307 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
84308 {
84309 + int ret = __do_munmap(mm, start, len);
84310 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
84311 + return ret;
84312 +
84313 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
84314 +}
84315 +
84316 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
84317 +#else
84318 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
84319 +#endif
84320 +{
84321 unsigned long end;
84322 struct vm_area_struct *vma, *prev, *last;
84323
84324 + /*
84325 + * mm->mmap_sem is required to protect against another thread
84326 + * changing the mappings in case we sleep.
84327 + */
84328 + verify_mm_writelocked(mm);
84329 +
84330 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
84331 return -EINVAL;
84332
84333 @@ -2567,6 +3050,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
84334 /* Fix up all other VM information */
84335 remove_vma_list(mm, vma);
84336
84337 + track_exec_limit(mm, start, end, 0UL);
84338 +
84339 return 0;
84340 }
84341
84342 @@ -2575,6 +3060,13 @@ int vm_munmap(unsigned long start, size_t len)
84343 int ret;
84344 struct mm_struct *mm = current->mm;
84345
84346 +
84347 +#ifdef CONFIG_PAX_SEGMEXEC
84348 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
84349 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
84350 + return -EINVAL;
84351 +#endif
84352 +
84353 down_write(&mm->mmap_sem);
84354 ret = do_munmap(mm, start, len);
84355 up_write(&mm->mmap_sem);
84356 @@ -2588,16 +3080,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
84357 return vm_munmap(addr, len);
84358 }
84359
84360 -static inline void verify_mm_writelocked(struct mm_struct *mm)
84361 -{
84362 -#ifdef CONFIG_DEBUG_VM
84363 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
84364 - WARN_ON(1);
84365 - up_read(&mm->mmap_sem);
84366 - }
84367 -#endif
84368 -}
84369 -
84370 /*
84371 * this is really a simplified "do_mmap". it only handles
84372 * anonymous maps. eventually we may be able to do some
84373 @@ -2611,6 +3093,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84374 struct rb_node ** rb_link, * rb_parent;
84375 pgoff_t pgoff = addr >> PAGE_SHIFT;
84376 int error;
84377 + unsigned long charged;
84378
84379 len = PAGE_ALIGN(len);
84380 if (!len)
84381 @@ -2618,16 +3101,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84382
84383 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
84384
84385 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
84386 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
84387 + flags &= ~VM_EXEC;
84388 +
84389 +#ifdef CONFIG_PAX_MPROTECT
84390 + if (mm->pax_flags & MF_PAX_MPROTECT)
84391 + flags &= ~VM_MAYEXEC;
84392 +#endif
84393 +
84394 + }
84395 +#endif
84396 +
84397 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
84398 if (error & ~PAGE_MASK)
84399 return error;
84400
84401 + charged = len >> PAGE_SHIFT;
84402 +
84403 /*
84404 * mlock MCL_FUTURE?
84405 */
84406 if (mm->def_flags & VM_LOCKED) {
84407 unsigned long locked, lock_limit;
84408 - locked = len >> PAGE_SHIFT;
84409 + locked = charged;
84410 locked += mm->locked_vm;
84411 lock_limit = rlimit(RLIMIT_MEMLOCK);
84412 lock_limit >>= PAGE_SHIFT;
84413 @@ -2644,21 +3141,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84414 /*
84415 * Clear old maps. this also does some error checking for us
84416 */
84417 - munmap_back:
84418 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
84419 if (do_munmap(mm, addr, len))
84420 return -ENOMEM;
84421 - goto munmap_back;
84422 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
84423 }
84424
84425 /* Check against address space limits *after* clearing old maps... */
84426 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
84427 + if (!may_expand_vm(mm, charged))
84428 return -ENOMEM;
84429
84430 if (mm->map_count > sysctl_max_map_count)
84431 return -ENOMEM;
84432
84433 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
84434 + if (security_vm_enough_memory_mm(mm, charged))
84435 return -ENOMEM;
84436
84437 /* Can we just expand an old private anonymous mapping? */
84438 @@ -2672,7 +3168,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84439 */
84440 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
84441 if (!vma) {
84442 - vm_unacct_memory(len >> PAGE_SHIFT);
84443 + vm_unacct_memory(charged);
84444 return -ENOMEM;
84445 }
84446
84447 @@ -2686,9 +3182,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
84448 vma_link(mm, vma, prev, rb_link, rb_parent);
84449 out:
84450 perf_event_mmap(vma);
84451 - mm->total_vm += len >> PAGE_SHIFT;
84452 + mm->total_vm += charged;
84453 if (flags & VM_LOCKED)
84454 - mm->locked_vm += (len >> PAGE_SHIFT);
84455 + mm->locked_vm += charged;
84456 + track_exec_limit(mm, addr, addr + len, flags);
84457 return addr;
84458 }
84459
84460 @@ -2750,6 +3247,7 @@ void exit_mmap(struct mm_struct *mm)
84461 while (vma) {
84462 if (vma->vm_flags & VM_ACCOUNT)
84463 nr_accounted += vma_pages(vma);
84464 + vma->vm_mirror = NULL;
84465 vma = remove_vma(vma);
84466 }
84467 vm_unacct_memory(nr_accounted);
84468 @@ -2766,6 +3264,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
84469 struct vm_area_struct *prev;
84470 struct rb_node **rb_link, *rb_parent;
84471
84472 +#ifdef CONFIG_PAX_SEGMEXEC
84473 + struct vm_area_struct *vma_m = NULL;
84474 +#endif
84475 +
84476 + if (security_mmap_addr(vma->vm_start))
84477 + return -EPERM;
84478 +
84479 /*
84480 * The vm_pgoff of a purely anonymous vma should be irrelevant
84481 * until its first write fault, when page's anon_vma and index
84482 @@ -2789,7 +3294,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
84483 security_vm_enough_memory_mm(mm, vma_pages(vma)))
84484 return -ENOMEM;
84485
84486 +#ifdef CONFIG_PAX_SEGMEXEC
84487 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
84488 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
84489 + if (!vma_m)
84490 + return -ENOMEM;
84491 + }
84492 +#endif
84493 +
84494 vma_link(mm, vma, prev, rb_link, rb_parent);
84495 +
84496 +#ifdef CONFIG_PAX_SEGMEXEC
84497 + if (vma_m)
84498 + BUG_ON(pax_mirror_vma(vma_m, vma));
84499 +#endif
84500 +
84501 return 0;
84502 }
84503
84504 @@ -2809,6 +3328,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
84505 struct mempolicy *pol;
84506 bool faulted_in_anon_vma = true;
84507
84508 + BUG_ON(vma->vm_mirror);
84509 +
84510 /*
84511 * If anonymous vma has not yet been faulted, update new pgoff
84512 * to match new location, to increase its chance of merging.
84513 @@ -2875,6 +3396,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
84514 return NULL;
84515 }
84516
84517 +#ifdef CONFIG_PAX_SEGMEXEC
84518 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
84519 +{
84520 + struct vm_area_struct *prev_m;
84521 + struct rb_node **rb_link_m, *rb_parent_m;
84522 + struct mempolicy *pol_m;
84523 +
84524 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
84525 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
84526 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
84527 + *vma_m = *vma;
84528 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
84529 + if (anon_vma_clone(vma_m, vma))
84530 + return -ENOMEM;
84531 + pol_m = vma_policy(vma_m);
84532 + mpol_get(pol_m);
84533 + vma_set_policy(vma_m, pol_m);
84534 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
84535 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
84536 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
84537 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
84538 + if (vma_m->vm_file)
84539 + get_file(vma_m->vm_file);
84540 + if (vma_m->vm_ops && vma_m->vm_ops->open)
84541 + vma_m->vm_ops->open(vma_m);
84542 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
84543 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
84544 + vma_m->vm_mirror = vma;
84545 + vma->vm_mirror = vma_m;
84546 + return 0;
84547 +}
84548 +#endif
84549 +
84550 /*
84551 * Return true if the calling process may expand its vm space by the passed
84552 * number of pages
84553 @@ -2886,6 +3440,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
84554
84555 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
84556
84557 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
84558 if (cur + npages > lim)
84559 return 0;
84560 return 1;
84561 @@ -2956,6 +3511,22 @@ int install_special_mapping(struct mm_struct *mm,
84562 vma->vm_start = addr;
84563 vma->vm_end = addr + len;
84564
84565 +#ifdef CONFIG_PAX_MPROTECT
84566 + if (mm->pax_flags & MF_PAX_MPROTECT) {
84567 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
84568 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
84569 + return -EPERM;
84570 + if (!(vm_flags & VM_EXEC))
84571 + vm_flags &= ~VM_MAYEXEC;
84572 +#else
84573 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
84574 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
84575 +#endif
84576 + else
84577 + vm_flags &= ~VM_MAYWRITE;
84578 + }
84579 +#endif
84580 +
84581 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
84582 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
84583
84584 diff --git a/mm/mprotect.c b/mm/mprotect.c
84585 index 94722a4..e661e29 100644
84586 --- a/mm/mprotect.c
84587 +++ b/mm/mprotect.c
84588 @@ -23,10 +23,18 @@
84589 #include <linux/mmu_notifier.h>
84590 #include <linux/migrate.h>
84591 #include <linux/perf_event.h>
84592 +#include <linux/sched/sysctl.h>
84593 +
84594 +#ifdef CONFIG_PAX_MPROTECT
84595 +#include <linux/elf.h>
84596 +#include <linux/binfmts.h>
84597 +#endif
84598 +
84599 #include <asm/uaccess.h>
84600 #include <asm/pgtable.h>
84601 #include <asm/cacheflush.h>
84602 #include <asm/tlbflush.h>
84603 +#include <asm/mmu_context.h>
84604
84605 #ifndef pgprot_modify
84606 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
84607 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
84608 return pages;
84609 }
84610
84611 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
84612 +/* called while holding the mmap semaphor for writing except stack expansion */
84613 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
84614 +{
84615 + unsigned long oldlimit, newlimit = 0UL;
84616 +
84617 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
84618 + return;
84619 +
84620 + spin_lock(&mm->page_table_lock);
84621 + oldlimit = mm->context.user_cs_limit;
84622 + if ((prot & VM_EXEC) && oldlimit < end)
84623 + /* USER_CS limit moved up */
84624 + newlimit = end;
84625 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
84626 + /* USER_CS limit moved down */
84627 + newlimit = start;
84628 +
84629 + if (newlimit) {
84630 + mm->context.user_cs_limit = newlimit;
84631 +
84632 +#ifdef CONFIG_SMP
84633 + wmb();
84634 + cpus_clear(mm->context.cpu_user_cs_mask);
84635 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
84636 +#endif
84637 +
84638 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
84639 + }
84640 + spin_unlock(&mm->page_table_lock);
84641 + if (newlimit == end) {
84642 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
84643 +
84644 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
84645 + if (is_vm_hugetlb_page(vma))
84646 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
84647 + else
84648 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
84649 + }
84650 +}
84651 +#endif
84652 +
84653 int
84654 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
84655 unsigned long start, unsigned long end, unsigned long newflags)
84656 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
84657 int error;
84658 int dirty_accountable = 0;
84659
84660 +#ifdef CONFIG_PAX_SEGMEXEC
84661 + struct vm_area_struct *vma_m = NULL;
84662 + unsigned long start_m, end_m;
84663 +
84664 + start_m = start + SEGMEXEC_TASK_SIZE;
84665 + end_m = end + SEGMEXEC_TASK_SIZE;
84666 +#endif
84667 +
84668 if (newflags == oldflags) {
84669 *pprev = vma;
84670 return 0;
84671 }
84672
84673 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
84674 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
84675 +
84676 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
84677 + return -ENOMEM;
84678 +
84679 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
84680 + return -ENOMEM;
84681 + }
84682 +
84683 /*
84684 * If we make a private mapping writable we increase our commit;
84685 * but (without finer accounting) cannot reduce our commit if we
84686 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
84687 }
84688 }
84689
84690 +#ifdef CONFIG_PAX_SEGMEXEC
84691 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
84692 + if (start != vma->vm_start) {
84693 + error = split_vma(mm, vma, start, 1);
84694 + if (error)
84695 + goto fail;
84696 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
84697 + *pprev = (*pprev)->vm_next;
84698 + }
84699 +
84700 + if (end != vma->vm_end) {
84701 + error = split_vma(mm, vma, end, 0);
84702 + if (error)
84703 + goto fail;
84704 + }
84705 +
84706 + if (pax_find_mirror_vma(vma)) {
84707 + error = __do_munmap(mm, start_m, end_m - start_m);
84708 + if (error)
84709 + goto fail;
84710 + } else {
84711 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
84712 + if (!vma_m) {
84713 + error = -ENOMEM;
84714 + goto fail;
84715 + }
84716 + vma->vm_flags = newflags;
84717 + error = pax_mirror_vma(vma_m, vma);
84718 + if (error) {
84719 + vma->vm_flags = oldflags;
84720 + goto fail;
84721 + }
84722 + }
84723 + }
84724 +#endif
84725 +
84726 /*
84727 * First try to merge with previous and/or next vma.
84728 */
84729 @@ -296,9 +400,21 @@ success:
84730 * vm_flags and vm_page_prot are protected by the mmap_sem
84731 * held in write mode.
84732 */
84733 +
84734 +#ifdef CONFIG_PAX_SEGMEXEC
84735 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
84736 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
84737 +#endif
84738 +
84739 vma->vm_flags = newflags;
84740 +
84741 +#ifdef CONFIG_PAX_MPROTECT
84742 + if (mm->binfmt && mm->binfmt->handle_mprotect)
84743 + mm->binfmt->handle_mprotect(vma, newflags);
84744 +#endif
84745 +
84746 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
84747 - vm_get_page_prot(newflags));
84748 + vm_get_page_prot(vma->vm_flags));
84749
84750 if (vma_wants_writenotify(vma)) {
84751 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
84752 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84753 end = start + len;
84754 if (end <= start)
84755 return -ENOMEM;
84756 +
84757 +#ifdef CONFIG_PAX_SEGMEXEC
84758 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
84759 + if (end > SEGMEXEC_TASK_SIZE)
84760 + return -EINVAL;
84761 + } else
84762 +#endif
84763 +
84764 + if (end > TASK_SIZE)
84765 + return -EINVAL;
84766 +
84767 if (!arch_validate_prot(prot))
84768 return -EINVAL;
84769
84770 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84771 /*
84772 * Does the application expect PROT_READ to imply PROT_EXEC:
84773 */
84774 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
84775 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
84776 prot |= PROT_EXEC;
84777
84778 vm_flags = calc_vm_prot_bits(prot);
84779 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84780 if (start > vma->vm_start)
84781 prev = vma;
84782
84783 +#ifdef CONFIG_PAX_MPROTECT
84784 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
84785 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
84786 +#endif
84787 +
84788 for (nstart = start ; ; ) {
84789 unsigned long newflags;
84790
84791 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84792
84793 /* newflags >> 4 shift VM_MAY% in place of VM_% */
84794 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
84795 + if (prot & (PROT_WRITE | PROT_EXEC))
84796 + gr_log_rwxmprotect(vma);
84797 +
84798 + error = -EACCES;
84799 + goto out;
84800 + }
84801 +
84802 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
84803 error = -EACCES;
84804 goto out;
84805 }
84806 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84807 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
84808 if (error)
84809 goto out;
84810 +
84811 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
84812 +
84813 nstart = tmp;
84814
84815 if (nstart < prev->vm_end)
84816 diff --git a/mm/mremap.c b/mm/mremap.c
84817 index 463a257..c0c7a92 100644
84818 --- a/mm/mremap.c
84819 +++ b/mm/mremap.c
84820 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
84821 continue;
84822 pte = ptep_get_and_clear(mm, old_addr, old_pte);
84823 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
84824 +
84825 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
84826 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
84827 + pte = pte_exprotect(pte);
84828 +#endif
84829 +
84830 set_pte_at(mm, new_addr, new_pte, pte);
84831 }
84832
84833 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
84834 if (is_vm_hugetlb_page(vma))
84835 goto Einval;
84836
84837 +#ifdef CONFIG_PAX_SEGMEXEC
84838 + if (pax_find_mirror_vma(vma))
84839 + goto Einval;
84840 +#endif
84841 +
84842 /* We can't remap across vm area boundaries */
84843 if (old_len > vma->vm_end - addr)
84844 goto Efault;
84845 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
84846 unsigned long ret = -EINVAL;
84847 unsigned long charged = 0;
84848 unsigned long map_flags;
84849 + unsigned long pax_task_size = TASK_SIZE;
84850
84851 if (new_addr & ~PAGE_MASK)
84852 goto out;
84853
84854 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
84855 +#ifdef CONFIG_PAX_SEGMEXEC
84856 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84857 + pax_task_size = SEGMEXEC_TASK_SIZE;
84858 +#endif
84859 +
84860 + pax_task_size -= PAGE_SIZE;
84861 +
84862 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
84863 goto out;
84864
84865 /* Check if the location we're moving into overlaps the
84866 * old location at all, and fail if it does.
84867 */
84868 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
84869 - goto out;
84870 -
84871 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
84872 + if (addr + old_len > new_addr && new_addr + new_len > addr)
84873 goto out;
84874
84875 ret = do_munmap(mm, new_addr, new_len);
84876 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84877 unsigned long ret = -EINVAL;
84878 unsigned long charged = 0;
84879 bool locked = false;
84880 + unsigned long pax_task_size = TASK_SIZE;
84881
84882 down_write(&current->mm->mmap_sem);
84883
84884 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84885 if (!new_len)
84886 goto out;
84887
84888 +#ifdef CONFIG_PAX_SEGMEXEC
84889 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84890 + pax_task_size = SEGMEXEC_TASK_SIZE;
84891 +#endif
84892 +
84893 + pax_task_size -= PAGE_SIZE;
84894 +
84895 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
84896 + old_len > pax_task_size || addr > pax_task_size-old_len)
84897 + goto out;
84898 +
84899 if (flags & MREMAP_FIXED) {
84900 if (flags & MREMAP_MAYMOVE)
84901 ret = mremap_to(addr, old_len, new_addr, new_len,
84902 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84903 new_addr = addr;
84904 }
84905 ret = addr;
84906 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
84907 goto out;
84908 }
84909 }
84910 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84911 goto out;
84912 }
84913
84914 + map_flags = vma->vm_flags;
84915 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
84916 + if (!(ret & ~PAGE_MASK)) {
84917 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
84918 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
84919 + }
84920 }
84921 out:
84922 if (ret & ~PAGE_MASK)
84923 diff --git a/mm/nommu.c b/mm/nommu.c
84924 index 298884d..5f74980 100644
84925 --- a/mm/nommu.c
84926 +++ b/mm/nommu.c
84927 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
84928 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
84929 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
84930 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
84931 -int heap_stack_gap = 0;
84932
84933 atomic_long_t mmap_pages_allocated;
84934
84935 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
84936 EXPORT_SYMBOL(find_vma);
84937
84938 /*
84939 - * find a VMA
84940 - * - we don't extend stack VMAs under NOMMU conditions
84941 - */
84942 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
84943 -{
84944 - return find_vma(mm, addr);
84945 -}
84946 -
84947 -/*
84948 * expand a stack to a given address
84949 * - not supported under NOMMU conditions
84950 */
84951 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84952
84953 /* most fields are the same, copy all, and then fixup */
84954 *new = *vma;
84955 + INIT_LIST_HEAD(&new->anon_vma_chain);
84956 *region = *vma->vm_region;
84957 new->vm_region = region;
84958
84959 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
84960 }
84961 EXPORT_SYMBOL(generic_file_remap_pages);
84962
84963 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84964 - unsigned long addr, void *buf, int len, int write)
84965 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84966 + unsigned long addr, void *buf, size_t len, int write)
84967 {
84968 struct vm_area_struct *vma;
84969
84970 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84971 *
84972 * The caller must hold a reference on @mm.
84973 */
84974 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84975 - void *buf, int len, int write)
84976 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
84977 + void *buf, size_t len, int write)
84978 {
84979 return __access_remote_vm(NULL, mm, addr, buf, len, write);
84980 }
84981 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84982 * Access another process' address space.
84983 * - source/target buffer must be kernel space
84984 */
84985 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
84986 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
84987 {
84988 struct mm_struct *mm;
84989
84990 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
84991 index 4514ad7..92eaa1c 100644
84992 --- a/mm/page-writeback.c
84993 +++ b/mm/page-writeback.c
84994 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
84995 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
84996 * - the bdi dirty thresh drops quickly due to change of JBOD workload
84997 */
84998 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
84999 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
85000 unsigned long thresh,
85001 unsigned long bg_thresh,
85002 unsigned long dirty,
85003 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
85004 }
85005 }
85006
85007 -static struct notifier_block __cpuinitdata ratelimit_nb = {
85008 +static struct notifier_block ratelimit_nb = {
85009 .notifier_call = ratelimit_handler,
85010 .next = NULL,
85011 };
85012 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
85013 index 2ee0fd3..6e2edfb 100644
85014 --- a/mm/page_alloc.c
85015 +++ b/mm/page_alloc.c
85016 @@ -60,6 +60,7 @@
85017 #include <linux/page-debug-flags.h>
85018 #include <linux/hugetlb.h>
85019 #include <linux/sched/rt.h>
85020 +#include <linux/random.h>
85021
85022 #include <asm/tlbflush.h>
85023 #include <asm/div64.h>
85024 @@ -345,7 +346,7 @@ out:
85025 * This usage means that zero-order pages may not be compound.
85026 */
85027
85028 -static void free_compound_page(struct page *page)
85029 +void free_compound_page(struct page *page)
85030 {
85031 __free_pages_ok(page, compound_order(page));
85032 }
85033 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
85034 int i;
85035 int bad = 0;
85036
85037 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85038 + unsigned long index = 1UL << order;
85039 +#endif
85040 +
85041 trace_mm_page_free(page, order);
85042 kmemcheck_free_shadow(page, order);
85043
85044 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
85045 debug_check_no_obj_freed(page_address(page),
85046 PAGE_SIZE << order);
85047 }
85048 +
85049 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85050 + for (; index; --index)
85051 + sanitize_highpage(page + index - 1);
85052 +#endif
85053 +
85054 arch_free_page(page, order);
85055 kernel_map_pages(page, 1 << order, 0);
85056
85057 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
85058 local_irq_restore(flags);
85059 }
85060
85061 +#ifdef CONFIG_PAX_LATENT_ENTROPY
85062 +bool __meminitdata extra_latent_entropy;
85063 +
85064 +static int __init setup_pax_extra_latent_entropy(char *str)
85065 +{
85066 + extra_latent_entropy = true;
85067 + return 0;
85068 +}
85069 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
85070 +
85071 +volatile u64 latent_entropy;
85072 +#endif
85073 +
85074 /*
85075 * Read access to zone->managed_pages is safe because it's unsigned long,
85076 * but we still need to serialize writers. Currently all callers of
85077 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
85078 set_page_count(p, 0);
85079 }
85080
85081 +#ifdef CONFIG_PAX_LATENT_ENTROPY
85082 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
85083 + u64 hash = 0;
85084 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
85085 + const u64 *data = lowmem_page_address(page);
85086 +
85087 + for (index = 0; index < end; index++)
85088 + hash ^= hash + data[index];
85089 + latent_entropy ^= hash;
85090 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
85091 + }
85092 +#endif
85093 +
85094 page_zone(page)->managed_pages += 1 << order;
85095 set_page_refcounted(page);
85096 __free_pages(page, order);
85097 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
85098 arch_alloc_page(page, order);
85099 kernel_map_pages(page, 1 << order, 1);
85100
85101 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
85102 if (gfp_flags & __GFP_ZERO)
85103 prep_zero_page(page, order, gfp_flags);
85104 +#endif
85105
85106 if (order && (gfp_flags & __GFP_COMP))
85107 prep_compound_page(page, order);
85108 diff --git a/mm/page_io.c b/mm/page_io.c
85109 index a8a3ef4..7260a60 100644
85110 --- a/mm/page_io.c
85111 +++ b/mm/page_io.c
85112 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
85113 struct file *swap_file = sis->swap_file;
85114 struct address_space *mapping = swap_file->f_mapping;
85115 struct iovec iov = {
85116 - .iov_base = kmap(page),
85117 + .iov_base = (void __force_user *)kmap(page),
85118 .iov_len = PAGE_SIZE,
85119 };
85120
85121 diff --git a/mm/percpu.c b/mm/percpu.c
85122 index 8c8e08f..73a5cda 100644
85123 --- a/mm/percpu.c
85124 +++ b/mm/percpu.c
85125 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
85126 static unsigned int pcpu_high_unit_cpu __read_mostly;
85127
85128 /* the address of the first chunk which starts with the kernel static area */
85129 -void *pcpu_base_addr __read_mostly;
85130 +void *pcpu_base_addr __read_only;
85131 EXPORT_SYMBOL_GPL(pcpu_base_addr);
85132
85133 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
85134 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
85135 index fd26d04..0cea1b0 100644
85136 --- a/mm/process_vm_access.c
85137 +++ b/mm/process_vm_access.c
85138 @@ -13,6 +13,7 @@
85139 #include <linux/uio.h>
85140 #include <linux/sched.h>
85141 #include <linux/highmem.h>
85142 +#include <linux/security.h>
85143 #include <linux/ptrace.h>
85144 #include <linux/slab.h>
85145 #include <linux/syscalls.h>
85146 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
85147 size_t iov_l_curr_offset = 0;
85148 ssize_t iov_len;
85149
85150 + return -ENOSYS; // PaX: until properly audited
85151 +
85152 /*
85153 * Work out how many pages of struct pages we're going to need
85154 * when eventually calling get_user_pages
85155 */
85156 for (i = 0; i < riovcnt; i++) {
85157 iov_len = rvec[i].iov_len;
85158 - if (iov_len > 0) {
85159 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
85160 - + iov_len)
85161 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
85162 - / PAGE_SIZE + 1;
85163 - nr_pages = max(nr_pages, nr_pages_iov);
85164 - }
85165 + if (iov_len <= 0)
85166 + continue;
85167 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
85168 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
85169 + nr_pages = max(nr_pages, nr_pages_iov);
85170 }
85171
85172 if (nr_pages == 0)
85173 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
85174 goto free_proc_pages;
85175 }
85176
85177 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
85178 + rc = -EPERM;
85179 + goto put_task_struct;
85180 + }
85181 +
85182 mm = mm_access(task, PTRACE_MODE_ATTACH);
85183 if (!mm || IS_ERR(mm)) {
85184 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
85185 diff --git a/mm/rmap.c b/mm/rmap.c
85186 index 6280da8..b5c090e 100644
85187 --- a/mm/rmap.c
85188 +++ b/mm/rmap.c
85189 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
85190 struct anon_vma *anon_vma = vma->anon_vma;
85191 struct anon_vma_chain *avc;
85192
85193 +#ifdef CONFIG_PAX_SEGMEXEC
85194 + struct anon_vma_chain *avc_m = NULL;
85195 +#endif
85196 +
85197 might_sleep();
85198 if (unlikely(!anon_vma)) {
85199 struct mm_struct *mm = vma->vm_mm;
85200 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
85201 if (!avc)
85202 goto out_enomem;
85203
85204 +#ifdef CONFIG_PAX_SEGMEXEC
85205 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
85206 + if (!avc_m)
85207 + goto out_enomem_free_avc;
85208 +#endif
85209 +
85210 anon_vma = find_mergeable_anon_vma(vma);
85211 allocated = NULL;
85212 if (!anon_vma) {
85213 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
85214 /* page_table_lock to protect against threads */
85215 spin_lock(&mm->page_table_lock);
85216 if (likely(!vma->anon_vma)) {
85217 +
85218 +#ifdef CONFIG_PAX_SEGMEXEC
85219 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
85220 +
85221 + if (vma_m) {
85222 + BUG_ON(vma_m->anon_vma);
85223 + vma_m->anon_vma = anon_vma;
85224 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
85225 + avc_m = NULL;
85226 + }
85227 +#endif
85228 +
85229 vma->anon_vma = anon_vma;
85230 anon_vma_chain_link(vma, avc, anon_vma);
85231 allocated = NULL;
85232 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
85233
85234 if (unlikely(allocated))
85235 put_anon_vma(allocated);
85236 +
85237 +#ifdef CONFIG_PAX_SEGMEXEC
85238 + if (unlikely(avc_m))
85239 + anon_vma_chain_free(avc_m);
85240 +#endif
85241 +
85242 if (unlikely(avc))
85243 anon_vma_chain_free(avc);
85244 }
85245 return 0;
85246
85247 out_enomem_free_avc:
85248 +
85249 +#ifdef CONFIG_PAX_SEGMEXEC
85250 + if (avc_m)
85251 + anon_vma_chain_free(avc_m);
85252 +#endif
85253 +
85254 anon_vma_chain_free(avc);
85255 out_enomem:
85256 return -ENOMEM;
85257 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
85258 * Attach the anon_vmas from src to dst.
85259 * Returns 0 on success, -ENOMEM on failure.
85260 */
85261 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
85262 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
85263 {
85264 struct anon_vma_chain *avc, *pavc;
85265 struct anon_vma *root = NULL;
85266 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
85267 * the corresponding VMA in the parent process is attached to.
85268 * Returns 0 on success, non-zero on failure.
85269 */
85270 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
85271 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
85272 {
85273 struct anon_vma_chain *avc;
85274 struct anon_vma *anon_vma;
85275 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
85276 void __init anon_vma_init(void)
85277 {
85278 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
85279 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
85280 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
85281 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
85282 + anon_vma_ctor);
85283 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
85284 + SLAB_PANIC|SLAB_NO_SANITIZE);
85285 }
85286
85287 /*
85288 diff --git a/mm/shmem.c b/mm/shmem.c
85289 index 5e6a842..b41916e 100644
85290 --- a/mm/shmem.c
85291 +++ b/mm/shmem.c
85292 @@ -33,7 +33,7 @@
85293 #include <linux/swap.h>
85294 #include <linux/aio.h>
85295
85296 -static struct vfsmount *shm_mnt;
85297 +struct vfsmount *shm_mnt;
85298
85299 #ifdef CONFIG_SHMEM
85300 /*
85301 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
85302 #define BOGO_DIRENT_SIZE 20
85303
85304 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
85305 -#define SHORT_SYMLINK_LEN 128
85306 +#define SHORT_SYMLINK_LEN 64
85307
85308 /*
85309 * shmem_fallocate and shmem_writepage communicate via inode->i_private
85310 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
85311 static int shmem_xattr_validate(const char *name)
85312 {
85313 struct { const char *prefix; size_t len; } arr[] = {
85314 +
85315 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
85316 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
85317 +#endif
85318 +
85319 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
85320 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
85321 };
85322 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
85323 if (err)
85324 return err;
85325
85326 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
85327 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
85328 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
85329 + return -EOPNOTSUPP;
85330 + if (size > 8)
85331 + return -EINVAL;
85332 + }
85333 +#endif
85334 +
85335 return simple_xattr_set(&info->xattrs, name, value, size, flags);
85336 }
85337
85338 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
85339 int err = -ENOMEM;
85340
85341 /* Round up to L1_CACHE_BYTES to resist false sharing */
85342 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
85343 - L1_CACHE_BYTES), GFP_KERNEL);
85344 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
85345 if (!sbinfo)
85346 return -ENOMEM;
85347
85348 diff --git a/mm/slab.c b/mm/slab.c
85349 index bd88411..2d46fd6 100644
85350 --- a/mm/slab.c
85351 +++ b/mm/slab.c
85352 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
85353 if ((x)->max_freeable < i) \
85354 (x)->max_freeable = i; \
85355 } while (0)
85356 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
85357 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
85358 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
85359 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
85360 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
85361 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
85362 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
85363 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
85364 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
85365 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
85366 #else
85367 #define STATS_INC_ACTIVE(x) do { } while (0)
85368 #define STATS_DEC_ACTIVE(x) do { } while (0)
85369 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
85370 #define STATS_INC_ALLOCMISS(x) do { } while (0)
85371 #define STATS_INC_FREEHIT(x) do { } while (0)
85372 #define STATS_INC_FREEMISS(x) do { } while (0)
85373 +#define STATS_INC_SANITIZED(x) do { } while (0)
85374 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
85375 #endif
85376
85377 #if DEBUG
85378 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
85379 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
85380 */
85381 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
85382 - const struct slab *slab, void *obj)
85383 + const struct slab *slab, const void *obj)
85384 {
85385 u32 offset = (obj - slab->s_mem);
85386 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
85387 @@ -1384,7 +1388,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
85388 return notifier_from_errno(err);
85389 }
85390
85391 -static struct notifier_block __cpuinitdata cpucache_notifier = {
85392 +static struct notifier_block cpucache_notifier = {
85393 &cpuup_callback, NULL, 0
85394 };
85395
85396 @@ -1565,12 +1569,12 @@ void __init kmem_cache_init(void)
85397 */
85398
85399 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
85400 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
85401 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
85402
85403 if (INDEX_AC != INDEX_NODE)
85404 kmalloc_caches[INDEX_NODE] =
85405 create_kmalloc_cache("kmalloc-node",
85406 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
85407 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
85408
85409 slab_early_init = 0;
85410
85411 @@ -3583,6 +3587,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
85412 struct array_cache *ac = cpu_cache_get(cachep);
85413
85414 check_irq_off();
85415 +
85416 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85417 + if (pax_sanitize_slab) {
85418 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
85419 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
85420 +
85421 + if (cachep->ctor)
85422 + cachep->ctor(objp);
85423 +
85424 + STATS_INC_SANITIZED(cachep);
85425 + } else
85426 + STATS_INC_NOT_SANITIZED(cachep);
85427 + }
85428 +#endif
85429 +
85430 kmemleak_free_recursive(objp, cachep->flags);
85431 objp = cache_free_debugcheck(cachep, objp, caller);
85432
85433 @@ -3800,6 +3819,7 @@ void kfree(const void *objp)
85434
85435 if (unlikely(ZERO_OR_NULL_PTR(objp)))
85436 return;
85437 + VM_BUG_ON(!virt_addr_valid(objp));
85438 local_irq_save(flags);
85439 kfree_debugcheck(objp);
85440 c = virt_to_cache(objp);
85441 @@ -4241,14 +4261,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
85442 }
85443 /* cpu stats */
85444 {
85445 - unsigned long allochit = atomic_read(&cachep->allochit);
85446 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
85447 - unsigned long freehit = atomic_read(&cachep->freehit);
85448 - unsigned long freemiss = atomic_read(&cachep->freemiss);
85449 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
85450 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
85451 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
85452 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
85453
85454 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
85455 allochit, allocmiss, freehit, freemiss);
85456 }
85457 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85458 + {
85459 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
85460 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
85461 +
85462 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
85463 + }
85464 +#endif
85465 #endif
85466 }
85467
85468 @@ -4476,13 +4504,71 @@ static const struct file_operations proc_slabstats_operations = {
85469 static int __init slab_proc_init(void)
85470 {
85471 #ifdef CONFIG_DEBUG_SLAB_LEAK
85472 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
85473 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
85474 #endif
85475 return 0;
85476 }
85477 module_init(slab_proc_init);
85478 #endif
85479
85480 +bool is_usercopy_object(const void *ptr)
85481 +{
85482 + struct page *page;
85483 + struct kmem_cache *cachep;
85484 +
85485 + if (ZERO_OR_NULL_PTR(ptr))
85486 + return false;
85487 +
85488 + if (!slab_is_available())
85489 + return false;
85490 +
85491 + if (!virt_addr_valid(ptr))
85492 + return false;
85493 +
85494 + page = virt_to_head_page(ptr);
85495 +
85496 + if (!PageSlab(page))
85497 + return false;
85498 +
85499 + cachep = page->slab_cache;
85500 + return cachep->flags & SLAB_USERCOPY;
85501 +}
85502 +
85503 +#ifdef CONFIG_PAX_USERCOPY
85504 +const char *check_heap_object(const void *ptr, unsigned long n)
85505 +{
85506 + struct page *page;
85507 + struct kmem_cache *cachep;
85508 + struct slab *slabp;
85509 + unsigned int objnr;
85510 + unsigned long offset;
85511 +
85512 + if (ZERO_OR_NULL_PTR(ptr))
85513 + return "<null>";
85514 +
85515 + if (!virt_addr_valid(ptr))
85516 + return NULL;
85517 +
85518 + page = virt_to_head_page(ptr);
85519 +
85520 + if (!PageSlab(page))
85521 + return NULL;
85522 +
85523 + cachep = page->slab_cache;
85524 + if (!(cachep->flags & SLAB_USERCOPY))
85525 + return cachep->name;
85526 +
85527 + slabp = page->slab_page;
85528 + objnr = obj_to_index(cachep, slabp, ptr);
85529 + BUG_ON(objnr >= cachep->num);
85530 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
85531 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
85532 + return NULL;
85533 +
85534 + return cachep->name;
85535 +}
85536 +#endif
85537 +
85538 /**
85539 * ksize - get the actual amount of memory allocated for a given object
85540 * @objp: Pointer to the object
85541 diff --git a/mm/slab.h b/mm/slab.h
85542 index f96b49e..db1d204 100644
85543 --- a/mm/slab.h
85544 +++ b/mm/slab.h
85545 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
85546 /* The slab cache that manages slab cache information */
85547 extern struct kmem_cache *kmem_cache;
85548
85549 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85550 +#ifdef CONFIG_X86_64
85551 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
85552 +#else
85553 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
85554 +#endif
85555 +extern bool pax_sanitize_slab;
85556 +#endif
85557 +
85558 unsigned long calculate_alignment(unsigned long flags,
85559 unsigned long align, unsigned long size);
85560
85561 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85562
85563 /* Legal flag mask for kmem_cache_create(), for various configurations */
85564 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
85565 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
85566 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
85567 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
85568
85569 #if defined(CONFIG_DEBUG_SLAB)
85570 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
85571 @@ -229,6 +239,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
85572 return s;
85573
85574 page = virt_to_head_page(x);
85575 +
85576 + BUG_ON(!PageSlab(page));
85577 +
85578 cachep = page->slab_cache;
85579 if (slab_equal_or_root(cachep, s))
85580 return cachep;
85581 diff --git a/mm/slab_common.c b/mm/slab_common.c
85582 index 2d41450..4efe6ee 100644
85583 --- a/mm/slab_common.c
85584 +++ b/mm/slab_common.c
85585 @@ -22,11 +22,22 @@
85586
85587 #include "slab.h"
85588
85589 -enum slab_state slab_state;
85590 +enum slab_state slab_state __read_only;
85591 LIST_HEAD(slab_caches);
85592 DEFINE_MUTEX(slab_mutex);
85593 struct kmem_cache *kmem_cache;
85594
85595 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85596 +bool pax_sanitize_slab __read_only = true;
85597 +static int __init pax_sanitize_slab_setup(char *str)
85598 +{
85599 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
85600 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
85601 + return 1;
85602 +}
85603 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
85604 +#endif
85605 +
85606 #ifdef CONFIG_DEBUG_VM
85607 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
85608 size_t size)
85609 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
85610
85611 err = __kmem_cache_create(s, flags);
85612 if (!err) {
85613 - s->refcount = 1;
85614 + atomic_set(&s->refcount, 1);
85615 list_add(&s->list, &slab_caches);
85616 memcg_cache_list_add(memcg, s);
85617 } else {
85618 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
85619
85620 get_online_cpus();
85621 mutex_lock(&slab_mutex);
85622 - s->refcount--;
85623 - if (!s->refcount) {
85624 + if (atomic_dec_and_test(&s->refcount)) {
85625 list_del(&s->list);
85626
85627 if (!__kmem_cache_shutdown(s)) {
85628 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
85629 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
85630 name, size, err);
85631
85632 - s->refcount = -1; /* Exempt from merging for now */
85633 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
85634 }
85635
85636 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
85637 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
85638
85639 create_boot_cache(s, name, size, flags);
85640 list_add(&s->list, &slab_caches);
85641 - s->refcount = 1;
85642 + atomic_set(&s->refcount, 1);
85643 return s;
85644 }
85645
85646 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
85647 EXPORT_SYMBOL(kmalloc_dma_caches);
85648 #endif
85649
85650 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85651 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
85652 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
85653 +#endif
85654 +
85655 /*
85656 * Conversion table for small slabs sizes / 8 to the index in the
85657 * kmalloc array. This is necessary for slabs < 192 since we have non power
85658 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
85659 return kmalloc_dma_caches[index];
85660
85661 #endif
85662 +
85663 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85664 + if (unlikely((flags & GFP_USERCOPY)))
85665 + return kmalloc_usercopy_caches[index];
85666 +
85667 +#endif
85668 +
85669 return kmalloc_caches[index];
85670 }
85671
85672 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
85673 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
85674 if (!kmalloc_caches[i]) {
85675 kmalloc_caches[i] = create_kmalloc_cache(NULL,
85676 - 1 << i, flags);
85677 + 1 << i, SLAB_USERCOPY | flags);
85678 }
85679
85680 /*
85681 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
85682 * earlier power of two caches
85683 */
85684 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
85685 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
85686 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
85687
85688 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
85689 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
85690 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
85691 }
85692
85693 /* Kmalloc array is now usable */
85694 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
85695 }
85696 }
85697 #endif
85698 +
85699 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85700 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
85701 + struct kmem_cache *s = kmalloc_caches[i];
85702 +
85703 + if (s) {
85704 + int size = kmalloc_size(i);
85705 + char *n = kasprintf(GFP_NOWAIT,
85706 + "usercopy-kmalloc-%d", size);
85707 +
85708 + BUG_ON(!n);
85709 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
85710 + size, SLAB_USERCOPY | flags);
85711 + }
85712 + }
85713 +#endif
85714 +
85715 }
85716 #endif /* !CONFIG_SLOB */
85717
85718 @@ -516,6 +555,9 @@ void print_slabinfo_header(struct seq_file *m)
85719 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
85720 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
85721 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
85722 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85723 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
85724 +#endif
85725 #endif
85726 seq_putc(m, '\n');
85727 }
85728 diff --git a/mm/slob.c b/mm/slob.c
85729 index eeed4a0..bb0e9ab 100644
85730 --- a/mm/slob.c
85731 +++ b/mm/slob.c
85732 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
85733 /*
85734 * Return the size of a slob block.
85735 */
85736 -static slobidx_t slob_units(slob_t *s)
85737 +static slobidx_t slob_units(const slob_t *s)
85738 {
85739 if (s->units > 0)
85740 return s->units;
85741 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
85742 /*
85743 * Return the next free slob block pointer after this one.
85744 */
85745 -static slob_t *slob_next(slob_t *s)
85746 +static slob_t *slob_next(const slob_t *s)
85747 {
85748 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
85749 slobidx_t next;
85750 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
85751 /*
85752 * Returns true if s is the last free block in its page.
85753 */
85754 -static int slob_last(slob_t *s)
85755 +static int slob_last(const slob_t *s)
85756 {
85757 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
85758 }
85759
85760 -static void *slob_new_pages(gfp_t gfp, int order, int node)
85761 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
85762 {
85763 - void *page;
85764 + struct page *page;
85765
85766 #ifdef CONFIG_NUMA
85767 if (node != NUMA_NO_NODE)
85768 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
85769 if (!page)
85770 return NULL;
85771
85772 - return page_address(page);
85773 + __SetPageSlab(page);
85774 + return page;
85775 }
85776
85777 -static void slob_free_pages(void *b, int order)
85778 +static void slob_free_pages(struct page *sp, int order)
85779 {
85780 if (current->reclaim_state)
85781 current->reclaim_state->reclaimed_slab += 1 << order;
85782 - free_pages((unsigned long)b, order);
85783 + __ClearPageSlab(sp);
85784 + page_mapcount_reset(sp);
85785 + sp->private = 0;
85786 + __free_pages(sp, order);
85787 }
85788
85789 /*
85790 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
85791
85792 /* Not enough space: must allocate a new page */
85793 if (!b) {
85794 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
85795 - if (!b)
85796 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
85797 + if (!sp)
85798 return NULL;
85799 - sp = virt_to_page(b);
85800 - __SetPageSlab(sp);
85801 + b = page_address(sp);
85802
85803 spin_lock_irqsave(&slob_lock, flags);
85804 sp->units = SLOB_UNITS(PAGE_SIZE);
85805 sp->freelist = b;
85806 + sp->private = 0;
85807 INIT_LIST_HEAD(&sp->list);
85808 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
85809 set_slob_page_free(sp, slob_list);
85810 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
85811 if (slob_page_free(sp))
85812 clear_slob_page_free(sp);
85813 spin_unlock_irqrestore(&slob_lock, flags);
85814 - __ClearPageSlab(sp);
85815 - page_mapcount_reset(sp);
85816 - slob_free_pages(b, 0);
85817 + slob_free_pages(sp, 0);
85818 return;
85819 }
85820
85821 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
85822 + if (pax_sanitize_slab)
85823 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
85824 +#endif
85825 +
85826 if (!slob_page_free(sp)) {
85827 /* This slob page is about to become partially free. Easy! */
85828 sp->units = units;
85829 @@ -424,11 +431,10 @@ out:
85830 */
85831
85832 static __always_inline void *
85833 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85834 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
85835 {
85836 - unsigned int *m;
85837 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85838 - void *ret;
85839 + slob_t *m;
85840 + void *ret = NULL;
85841
85842 gfp &= gfp_allowed_mask;
85843
85844 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85845
85846 if (!m)
85847 return NULL;
85848 - *m = size;
85849 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
85850 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
85851 + m[0].units = size;
85852 + m[1].units = align;
85853 ret = (void *)m + align;
85854
85855 trace_kmalloc_node(caller, ret,
85856 size, size + align, gfp, node);
85857 } else {
85858 unsigned int order = get_order(size);
85859 + struct page *page;
85860
85861 if (likely(order))
85862 gfp |= __GFP_COMP;
85863 - ret = slob_new_pages(gfp, order, node);
85864 + page = slob_new_pages(gfp, order, node);
85865 + if (page) {
85866 + ret = page_address(page);
85867 + page->private = size;
85868 + }
85869
85870 trace_kmalloc_node(caller, ret,
85871 size, PAGE_SIZE << order, gfp, node);
85872 }
85873
85874 - kmemleak_alloc(ret, size, 1, gfp);
85875 + return ret;
85876 +}
85877 +
85878 +static __always_inline void *
85879 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85880 +{
85881 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85882 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
85883 +
85884 + if (!ZERO_OR_NULL_PTR(ret))
85885 + kmemleak_alloc(ret, size, 1, gfp);
85886 return ret;
85887 }
85888
85889 @@ -493,34 +517,112 @@ void kfree(const void *block)
85890 return;
85891 kmemleak_free(block);
85892
85893 + VM_BUG_ON(!virt_addr_valid(block));
85894 sp = virt_to_page(block);
85895 - if (PageSlab(sp)) {
85896 + VM_BUG_ON(!PageSlab(sp));
85897 + if (!sp->private) {
85898 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85899 - unsigned int *m = (unsigned int *)(block - align);
85900 - slob_free(m, *m + align);
85901 - } else
85902 + slob_t *m = (slob_t *)(block - align);
85903 + slob_free(m, m[0].units + align);
85904 + } else {
85905 + __ClearPageSlab(sp);
85906 + page_mapcount_reset(sp);
85907 + sp->private = 0;
85908 __free_pages(sp, compound_order(sp));
85909 + }
85910 }
85911 EXPORT_SYMBOL(kfree);
85912
85913 +bool is_usercopy_object(const void *ptr)
85914 +{
85915 + if (!slab_is_available())
85916 + return false;
85917 +
85918 + // PAX: TODO
85919 +
85920 + return false;
85921 +}
85922 +
85923 +#ifdef CONFIG_PAX_USERCOPY
85924 +const char *check_heap_object(const void *ptr, unsigned long n)
85925 +{
85926 + struct page *page;
85927 + const slob_t *free;
85928 + const void *base;
85929 + unsigned long flags;
85930 +
85931 + if (ZERO_OR_NULL_PTR(ptr))
85932 + return "<null>";
85933 +
85934 + if (!virt_addr_valid(ptr))
85935 + return NULL;
85936 +
85937 + page = virt_to_head_page(ptr);
85938 + if (!PageSlab(page))
85939 + return NULL;
85940 +
85941 + if (page->private) {
85942 + base = page;
85943 + if (base <= ptr && n <= page->private - (ptr - base))
85944 + return NULL;
85945 + return "<slob>";
85946 + }
85947 +
85948 + /* some tricky double walking to find the chunk */
85949 + spin_lock_irqsave(&slob_lock, flags);
85950 + base = (void *)((unsigned long)ptr & PAGE_MASK);
85951 + free = page->freelist;
85952 +
85953 + while (!slob_last(free) && (void *)free <= ptr) {
85954 + base = free + slob_units(free);
85955 + free = slob_next(free);
85956 + }
85957 +
85958 + while (base < (void *)free) {
85959 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
85960 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
85961 + int offset;
85962 +
85963 + if (ptr < base + align)
85964 + break;
85965 +
85966 + offset = ptr - base - align;
85967 + if (offset >= m) {
85968 + base += size;
85969 + continue;
85970 + }
85971 +
85972 + if (n > m - offset)
85973 + break;
85974 +
85975 + spin_unlock_irqrestore(&slob_lock, flags);
85976 + return NULL;
85977 + }
85978 +
85979 + spin_unlock_irqrestore(&slob_lock, flags);
85980 + return "<slob>";
85981 +}
85982 +#endif
85983 +
85984 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
85985 size_t ksize(const void *block)
85986 {
85987 struct page *sp;
85988 int align;
85989 - unsigned int *m;
85990 + slob_t *m;
85991
85992 BUG_ON(!block);
85993 if (unlikely(block == ZERO_SIZE_PTR))
85994 return 0;
85995
85996 sp = virt_to_page(block);
85997 - if (unlikely(!PageSlab(sp)))
85998 - return PAGE_SIZE << compound_order(sp);
85999 + VM_BUG_ON(!PageSlab(sp));
86000 + if (sp->private)
86001 + return sp->private;
86002
86003 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
86004 - m = (unsigned int *)(block - align);
86005 - return SLOB_UNITS(*m) * SLOB_UNIT;
86006 + m = (slob_t *)(block - align);
86007 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
86008 }
86009 EXPORT_SYMBOL(ksize);
86010
86011 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
86012
86013 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
86014 {
86015 - void *b;
86016 + void *b = NULL;
86017
86018 flags &= gfp_allowed_mask;
86019
86020 lockdep_trace_alloc(flags);
86021
86022 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86023 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
86024 +#else
86025 if (c->size < PAGE_SIZE) {
86026 b = slob_alloc(c->size, flags, c->align, node);
86027 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
86028 SLOB_UNITS(c->size) * SLOB_UNIT,
86029 flags, node);
86030 } else {
86031 - b = slob_new_pages(flags, get_order(c->size), node);
86032 + struct page *sp;
86033 +
86034 + sp = slob_new_pages(flags, get_order(c->size), node);
86035 + if (sp) {
86036 + b = page_address(sp);
86037 + sp->private = c->size;
86038 + }
86039 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
86040 PAGE_SIZE << get_order(c->size),
86041 flags, node);
86042 }
86043 +#endif
86044
86045 if (c->ctor)
86046 c->ctor(b);
86047 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
86048
86049 static void __kmem_cache_free(void *b, int size)
86050 {
86051 - if (size < PAGE_SIZE)
86052 + struct page *sp;
86053 +
86054 + sp = virt_to_page(b);
86055 + BUG_ON(!PageSlab(sp));
86056 + if (!sp->private)
86057 slob_free(b, size);
86058 else
86059 - slob_free_pages(b, get_order(size));
86060 + slob_free_pages(sp, get_order(size));
86061 }
86062
86063 static void kmem_rcu_free(struct rcu_head *head)
86064 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
86065
86066 void kmem_cache_free(struct kmem_cache *c, void *b)
86067 {
86068 + int size = c->size;
86069 +
86070 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86071 + if (size + c->align < PAGE_SIZE) {
86072 + size += c->align;
86073 + b -= c->align;
86074 + }
86075 +#endif
86076 +
86077 kmemleak_free_recursive(b, c->flags);
86078 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
86079 struct slob_rcu *slob_rcu;
86080 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
86081 - slob_rcu->size = c->size;
86082 + slob_rcu = b + (size - sizeof(struct slob_rcu));
86083 + slob_rcu->size = size;
86084 call_rcu(&slob_rcu->head, kmem_rcu_free);
86085 } else {
86086 - __kmem_cache_free(b, c->size);
86087 + __kmem_cache_free(b, size);
86088 }
86089
86090 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86091 + trace_kfree(_RET_IP_, b);
86092 +#else
86093 trace_kmem_cache_free(_RET_IP_, b);
86094 +#endif
86095 +
86096 }
86097 EXPORT_SYMBOL(kmem_cache_free);
86098
86099 diff --git a/mm/slub.c b/mm/slub.c
86100 index 57707f0..7857bd3 100644
86101 --- a/mm/slub.c
86102 +++ b/mm/slub.c
86103 @@ -198,7 +198,7 @@ struct track {
86104
86105 enum track_item { TRACK_ALLOC, TRACK_FREE };
86106
86107 -#ifdef CONFIG_SYSFS
86108 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86109 static int sysfs_slab_add(struct kmem_cache *);
86110 static int sysfs_slab_alias(struct kmem_cache *, const char *);
86111 static void sysfs_slab_remove(struct kmem_cache *);
86112 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
86113 if (!t->addr)
86114 return;
86115
86116 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
86117 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
86118 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
86119 #ifdef CONFIG_STACKTRACE
86120 {
86121 @@ -2594,6 +2594,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
86122
86123 slab_free_hook(s, x);
86124
86125 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
86126 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
86127 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
86128 + if (s->ctor)
86129 + s->ctor(x);
86130 + }
86131 +#endif
86132 +
86133 redo:
86134 /*
86135 * Determine the currently cpus per cpu slab.
86136 @@ -2661,7 +2669,7 @@ static int slub_min_objects;
86137 * Merge control. If this is set then no merging of slab caches will occur.
86138 * (Could be removed. This was introduced to pacify the merge skeptics.)
86139 */
86140 -static int slub_nomerge;
86141 +static int slub_nomerge = 1;
86142
86143 /*
86144 * Calculate the order of allocation given an slab object size.
86145 @@ -2938,6 +2946,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
86146 s->inuse = size;
86147
86148 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
86149 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
86150 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
86151 +#endif
86152 s->ctor)) {
86153 /*
86154 * Relocate free pointer after the object if it is not
86155 @@ -3283,6 +3294,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
86156 EXPORT_SYMBOL(__kmalloc_node);
86157 #endif
86158
86159 +bool is_usercopy_object(const void *ptr)
86160 +{
86161 + struct page *page;
86162 + struct kmem_cache *s;
86163 +
86164 + if (ZERO_OR_NULL_PTR(ptr))
86165 + return false;
86166 +
86167 + if (!slab_is_available())
86168 + return false;
86169 +
86170 + if (!virt_addr_valid(ptr))
86171 + return false;
86172 +
86173 + page = virt_to_head_page(ptr);
86174 +
86175 + if (!PageSlab(page))
86176 + return false;
86177 +
86178 + s = page->slab_cache;
86179 + return s->flags & SLAB_USERCOPY;
86180 +}
86181 +
86182 +#ifdef CONFIG_PAX_USERCOPY
86183 +const char *check_heap_object(const void *ptr, unsigned long n)
86184 +{
86185 + struct page *page;
86186 + struct kmem_cache *s;
86187 + unsigned long offset;
86188 +
86189 + if (ZERO_OR_NULL_PTR(ptr))
86190 + return "<null>";
86191 +
86192 + if (!virt_addr_valid(ptr))
86193 + return NULL;
86194 +
86195 + page = virt_to_head_page(ptr);
86196 +
86197 + if (!PageSlab(page))
86198 + return NULL;
86199 +
86200 + s = page->slab_cache;
86201 + if (!(s->flags & SLAB_USERCOPY))
86202 + return s->name;
86203 +
86204 + offset = (ptr - page_address(page)) % s->size;
86205 + if (offset <= s->object_size && n <= s->object_size - offset)
86206 + return NULL;
86207 +
86208 + return s->name;
86209 +}
86210 +#endif
86211 +
86212 size_t ksize(const void *object)
86213 {
86214 struct page *page;
86215 @@ -3347,6 +3411,7 @@ void kfree(const void *x)
86216 if (unlikely(ZERO_OR_NULL_PTR(x)))
86217 return;
86218
86219 + VM_BUG_ON(!virt_addr_valid(x));
86220 page = virt_to_head_page(x);
86221 if (unlikely(!PageSlab(page))) {
86222 BUG_ON(!PageCompound(page));
86223 @@ -3652,7 +3717,7 @@ static int slab_unmergeable(struct kmem_cache *s)
86224 /*
86225 * We may have set a slab to be unmergeable during bootstrap.
86226 */
86227 - if (s->refcount < 0)
86228 + if (atomic_read(&s->refcount) < 0)
86229 return 1;
86230
86231 return 0;
86232 @@ -3710,7 +3775,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
86233
86234 s = find_mergeable(memcg, size, align, flags, name, ctor);
86235 if (s) {
86236 - s->refcount++;
86237 + atomic_inc(&s->refcount);
86238 /*
86239 * Adjust the object sizes so that we clear
86240 * the complete object on kzalloc.
86241 @@ -3719,7 +3784,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
86242 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
86243
86244 if (sysfs_slab_alias(s, name)) {
86245 - s->refcount--;
86246 + atomic_dec(&s->refcount);
86247 s = NULL;
86248 }
86249 }
86250 @@ -3781,7 +3846,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
86251 return NOTIFY_OK;
86252 }
86253
86254 -static struct notifier_block __cpuinitdata slab_notifier = {
86255 +static struct notifier_block slab_notifier = {
86256 .notifier_call = slab_cpuup_callback
86257 };
86258
86259 @@ -3839,7 +3904,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
86260 }
86261 #endif
86262
86263 -#ifdef CONFIG_SYSFS
86264 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86265 static int count_inuse(struct page *page)
86266 {
86267 return page->inuse;
86268 @@ -4226,12 +4291,12 @@ static void resiliency_test(void)
86269 validate_slab_cache(kmalloc_caches[9]);
86270 }
86271 #else
86272 -#ifdef CONFIG_SYSFS
86273 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86274 static void resiliency_test(void) {};
86275 #endif
86276 #endif
86277
86278 -#ifdef CONFIG_SYSFS
86279 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86280 enum slab_stat_type {
86281 SL_ALL, /* All slabs */
86282 SL_PARTIAL, /* Only partially allocated slabs */
86283 @@ -4475,7 +4540,7 @@ SLAB_ATTR_RO(ctor);
86284
86285 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
86286 {
86287 - return sprintf(buf, "%d\n", s->refcount - 1);
86288 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
86289 }
86290 SLAB_ATTR_RO(aliases);
86291
86292 @@ -4563,6 +4628,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
86293 SLAB_ATTR_RO(cache_dma);
86294 #endif
86295
86296 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86297 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
86298 +{
86299 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
86300 +}
86301 +SLAB_ATTR_RO(usercopy);
86302 +#endif
86303 +
86304 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
86305 {
86306 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
86307 @@ -4897,6 +4970,9 @@ static struct attribute *slab_attrs[] = {
86308 #ifdef CONFIG_ZONE_DMA
86309 &cache_dma_attr.attr,
86310 #endif
86311 +#ifdef CONFIG_PAX_USERCOPY_SLABS
86312 + &usercopy_attr.attr,
86313 +#endif
86314 #ifdef CONFIG_NUMA
86315 &remote_node_defrag_ratio_attr.attr,
86316 #endif
86317 @@ -5128,6 +5204,7 @@ static char *create_unique_id(struct kmem_cache *s)
86318 return name;
86319 }
86320
86321 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86322 static int sysfs_slab_add(struct kmem_cache *s)
86323 {
86324 int err;
86325 @@ -5151,7 +5228,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
86326 }
86327
86328 s->kobj.kset = slab_kset;
86329 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
86330 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
86331 if (err) {
86332 kobject_put(&s->kobj);
86333 return err;
86334 @@ -5185,6 +5262,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
86335 kobject_del(&s->kobj);
86336 kobject_put(&s->kobj);
86337 }
86338 +#endif
86339
86340 /*
86341 * Need to buffer aliases during bootup until sysfs becomes
86342 @@ -5198,6 +5276,7 @@ struct saved_alias {
86343
86344 static struct saved_alias *alias_list;
86345
86346 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
86347 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
86348 {
86349 struct saved_alias *al;
86350 @@ -5220,6 +5299,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
86351 alias_list = al;
86352 return 0;
86353 }
86354 +#endif
86355
86356 static int __init slab_sysfs_init(void)
86357 {
86358 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
86359 index 27eeab3..7c3f7f2 100644
86360 --- a/mm/sparse-vmemmap.c
86361 +++ b/mm/sparse-vmemmap.c
86362 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
86363 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
86364 if (!p)
86365 return NULL;
86366 - pud_populate(&init_mm, pud, p);
86367 + pud_populate_kernel(&init_mm, pud, p);
86368 }
86369 return pud;
86370 }
86371 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
86372 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
86373 if (!p)
86374 return NULL;
86375 - pgd_populate(&init_mm, pgd, p);
86376 + pgd_populate_kernel(&init_mm, pgd, p);
86377 }
86378 return pgd;
86379 }
86380 diff --git a/mm/sparse.c b/mm/sparse.c
86381 index 1c91f0d3..485470a 100644
86382 --- a/mm/sparse.c
86383 +++ b/mm/sparse.c
86384 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
86385
86386 for (i = 0; i < PAGES_PER_SECTION; i++) {
86387 if (PageHWPoison(&memmap[i])) {
86388 - atomic_long_sub(1, &num_poisoned_pages);
86389 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
86390 ClearPageHWPoison(&memmap[i]);
86391 }
86392 }
86393 diff --git a/mm/swap.c b/mm/swap.c
86394 index dfd7d71..ccdf688 100644
86395 --- a/mm/swap.c
86396 +++ b/mm/swap.c
86397 @@ -31,6 +31,7 @@
86398 #include <linux/memcontrol.h>
86399 #include <linux/gfp.h>
86400 #include <linux/uio.h>
86401 +#include <linux/hugetlb.h>
86402
86403 #include "internal.h"
86404
86405 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
86406
86407 __page_cache_release(page);
86408 dtor = get_compound_page_dtor(page);
86409 + if (!PageHuge(page))
86410 + BUG_ON(dtor != free_compound_page);
86411 (*dtor)(page);
86412 }
86413
86414 diff --git a/mm/swapfile.c b/mm/swapfile.c
86415 index 746af55b..7ac94ae 100644
86416 --- a/mm/swapfile.c
86417 +++ b/mm/swapfile.c
86418 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
86419
86420 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
86421 /* Activity counter to indicate that a swapon or swapoff has occurred */
86422 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
86423 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
86424
86425 static inline unsigned char swap_count(unsigned char ent)
86426 {
86427 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
86428 }
86429 filp_close(swap_file, NULL);
86430 err = 0;
86431 - atomic_inc(&proc_poll_event);
86432 + atomic_inc_unchecked(&proc_poll_event);
86433 wake_up_interruptible(&proc_poll_wait);
86434
86435 out_dput:
86436 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
86437
86438 poll_wait(file, &proc_poll_wait, wait);
86439
86440 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
86441 - seq->poll_event = atomic_read(&proc_poll_event);
86442 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
86443 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
86444 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
86445 }
86446
86447 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
86448 return ret;
86449
86450 seq = file->private_data;
86451 - seq->poll_event = atomic_read(&proc_poll_event);
86452 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
86453 return 0;
86454 }
86455
86456 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
86457 (frontswap_map) ? "FS" : "");
86458
86459 mutex_unlock(&swapon_mutex);
86460 - atomic_inc(&proc_poll_event);
86461 + atomic_inc_unchecked(&proc_poll_event);
86462 wake_up_interruptible(&proc_poll_wait);
86463
86464 if (S_ISREG(inode->i_mode))
86465 diff --git a/mm/util.c b/mm/util.c
86466 index ab1424d..7c5bd5a 100644
86467 --- a/mm/util.c
86468 +++ b/mm/util.c
86469 @@ -294,6 +294,12 @@ done:
86470 void arch_pick_mmap_layout(struct mm_struct *mm)
86471 {
86472 mm->mmap_base = TASK_UNMAPPED_BASE;
86473 +
86474 +#ifdef CONFIG_PAX_RANDMMAP
86475 + if (mm->pax_flags & MF_PAX_RANDMMAP)
86476 + mm->mmap_base += mm->delta_mmap;
86477 +#endif
86478 +
86479 mm->get_unmapped_area = arch_get_unmapped_area;
86480 mm->unmap_area = arch_unmap_area;
86481 }
86482 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
86483 index d365724..6cae7c2 100644
86484 --- a/mm/vmalloc.c
86485 +++ b/mm/vmalloc.c
86486 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
86487
86488 pte = pte_offset_kernel(pmd, addr);
86489 do {
86490 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
86491 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
86492 +
86493 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86494 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
86495 + BUG_ON(!pte_exec(*pte));
86496 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
86497 + continue;
86498 + }
86499 +#endif
86500 +
86501 + {
86502 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
86503 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
86504 + }
86505 } while (pte++, addr += PAGE_SIZE, addr != end);
86506 }
86507
86508 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
86509 pte = pte_alloc_kernel(pmd, addr);
86510 if (!pte)
86511 return -ENOMEM;
86512 +
86513 + pax_open_kernel();
86514 do {
86515 struct page *page = pages[*nr];
86516
86517 - if (WARN_ON(!pte_none(*pte)))
86518 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86519 + if (pgprot_val(prot) & _PAGE_NX)
86520 +#endif
86521 +
86522 + if (!pte_none(*pte)) {
86523 + pax_close_kernel();
86524 + WARN_ON(1);
86525 return -EBUSY;
86526 - if (WARN_ON(!page))
86527 + }
86528 + if (!page) {
86529 + pax_close_kernel();
86530 + WARN_ON(1);
86531 return -ENOMEM;
86532 + }
86533 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
86534 (*nr)++;
86535 } while (pte++, addr += PAGE_SIZE, addr != end);
86536 + pax_close_kernel();
86537 return 0;
86538 }
86539
86540 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
86541 pmd_t *pmd;
86542 unsigned long next;
86543
86544 - pmd = pmd_alloc(&init_mm, pud, addr);
86545 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
86546 if (!pmd)
86547 return -ENOMEM;
86548 do {
86549 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
86550 pud_t *pud;
86551 unsigned long next;
86552
86553 - pud = pud_alloc(&init_mm, pgd, addr);
86554 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
86555 if (!pud)
86556 return -ENOMEM;
86557 do {
86558 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
86559 if (addr >= MODULES_VADDR && addr < MODULES_END)
86560 return 1;
86561 #endif
86562 +
86563 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
86564 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
86565 + return 1;
86566 +#endif
86567 +
86568 return is_vmalloc_addr(x);
86569 }
86570
86571 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
86572
86573 if (!pgd_none(*pgd)) {
86574 pud_t *pud = pud_offset(pgd, addr);
86575 +#ifdef CONFIG_X86
86576 + if (!pud_large(*pud))
86577 +#endif
86578 if (!pud_none(*pud)) {
86579 pmd_t *pmd = pmd_offset(pud, addr);
86580 +#ifdef CONFIG_X86
86581 + if (!pmd_large(*pmd))
86582 +#endif
86583 if (!pmd_none(*pmd)) {
86584 pte_t *ptep, pte;
86585
86586 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
86587 * Allocate a region of KVA of the specified size and alignment, within the
86588 * vstart and vend.
86589 */
86590 -static struct vmap_area *alloc_vmap_area(unsigned long size,
86591 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
86592 unsigned long align,
86593 unsigned long vstart, unsigned long vend,
86594 int node, gfp_t gfp_mask)
86595 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
86596 struct vm_struct *area;
86597
86598 BUG_ON(in_interrupt());
86599 +
86600 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
86601 + if (flags & VM_KERNEXEC) {
86602 + if (start != VMALLOC_START || end != VMALLOC_END)
86603 + return NULL;
86604 + start = (unsigned long)MODULES_EXEC_VADDR;
86605 + end = (unsigned long)MODULES_EXEC_END;
86606 + }
86607 +#endif
86608 +
86609 if (flags & VM_IOREMAP) {
86610 int bit = fls(size);
86611
86612 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
86613 if (count > totalram_pages)
86614 return NULL;
86615
86616 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
86617 + if (!(pgprot_val(prot) & _PAGE_NX))
86618 + flags |= VM_KERNEXEC;
86619 +#endif
86620 +
86621 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
86622 __builtin_return_address(0));
86623 if (!area)
86624 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
86625 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
86626 goto fail;
86627
86628 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
86629 + if (!(pgprot_val(prot) & _PAGE_NX))
86630 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
86631 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
86632 + else
86633 +#endif
86634 +
86635 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
86636 start, end, node, gfp_mask, caller);
86637 if (!area)
86638 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
86639 * For tight control over page level allocator and protection flags
86640 * use __vmalloc() instead.
86641 */
86642 -
86643 void *vmalloc_exec(unsigned long size)
86644 {
86645 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
86646 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
86647 NUMA_NO_NODE, __builtin_return_address(0));
86648 }
86649
86650 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
86651 unsigned long uaddr = vma->vm_start;
86652 unsigned long usize = vma->vm_end - vma->vm_start;
86653
86654 + BUG_ON(vma->vm_mirror);
86655 +
86656 if ((PAGE_SIZE-1) & (unsigned long)addr)
86657 return -EINVAL;
86658
86659 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
86660 v->addr, v->addr + v->size, v->size);
86661
86662 if (v->caller)
86663 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86664 + seq_printf(m, " %pK", v->caller);
86665 +#else
86666 seq_printf(m, " %pS", v->caller);
86667 +#endif
86668
86669 if (v->nr_pages)
86670 seq_printf(m, " pages=%d", v->nr_pages);
86671 diff --git a/mm/vmstat.c b/mm/vmstat.c
86672 index f42745e..62f8346 100644
86673 --- a/mm/vmstat.c
86674 +++ b/mm/vmstat.c
86675 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
86676 *
86677 * vm_stat contains the global counters
86678 */
86679 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
86680 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
86681 EXPORT_SYMBOL(vm_stat);
86682
86683 #ifdef CONFIG_SMP
86684 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
86685 v = p->vm_stat_diff[i];
86686 p->vm_stat_diff[i] = 0;
86687 local_irq_restore(flags);
86688 - atomic_long_add(v, &zone->vm_stat[i]);
86689 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
86690 global_diff[i] += v;
86691 #ifdef CONFIG_NUMA
86692 /* 3 seconds idle till flush */
86693 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
86694
86695 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
86696 if (global_diff[i])
86697 - atomic_long_add(global_diff[i], &vm_stat[i]);
86698 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
86699 }
86700
86701 /*
86702 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
86703 if (pset->vm_stat_diff[i]) {
86704 int v = pset->vm_stat_diff[i];
86705 pset->vm_stat_diff[i] = 0;
86706 - atomic_long_add(v, &zone->vm_stat[i]);
86707 - atomic_long_add(v, &vm_stat[i]);
86708 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
86709 + atomic_long_add_unchecked(v, &vm_stat[i]);
86710 }
86711 }
86712 #endif
86713 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
86714 return NOTIFY_OK;
86715 }
86716
86717 -static struct notifier_block __cpuinitdata vmstat_notifier =
86718 +static struct notifier_block vmstat_notifier =
86719 { &vmstat_cpuup_callback, NULL, 0 };
86720 #endif
86721
86722 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
86723 start_cpu_timer(cpu);
86724 #endif
86725 #ifdef CONFIG_PROC_FS
86726 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
86727 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
86728 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
86729 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
86730 + {
86731 + mode_t gr_mode = S_IRUGO;
86732 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86733 + gr_mode = S_IRUSR;
86734 +#endif
86735 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
86736 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
86737 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
86738 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
86739 +#else
86740 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
86741 +#endif
86742 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
86743 + }
86744 #endif
86745 return 0;
86746 }
86747 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
86748 index 9424f37..6aabf19 100644
86749 --- a/net/8021q/vlan.c
86750 +++ b/net/8021q/vlan.c
86751 @@ -469,7 +469,7 @@ out:
86752 return NOTIFY_DONE;
86753 }
86754
86755 -static struct notifier_block vlan_notifier_block __read_mostly = {
86756 +static struct notifier_block vlan_notifier_block = {
86757 .notifier_call = vlan_device_event,
86758 };
86759
86760 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
86761 err = -EPERM;
86762 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
86763 break;
86764 - if ((args.u.name_type >= 0) &&
86765 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
86766 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
86767 struct vlan_net *vn;
86768
86769 vn = net_generic(net, vlan_net_id);
86770 diff --git a/net/9p/mod.c b/net/9p/mod.c
86771 index 6ab36ae..6f1841b 100644
86772 --- a/net/9p/mod.c
86773 +++ b/net/9p/mod.c
86774 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
86775 void v9fs_register_trans(struct p9_trans_module *m)
86776 {
86777 spin_lock(&v9fs_trans_lock);
86778 - list_add_tail(&m->list, &v9fs_trans_list);
86779 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
86780 spin_unlock(&v9fs_trans_lock);
86781 }
86782 EXPORT_SYMBOL(v9fs_register_trans);
86783 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
86784 void v9fs_unregister_trans(struct p9_trans_module *m)
86785 {
86786 spin_lock(&v9fs_trans_lock);
86787 - list_del_init(&m->list);
86788 + pax_list_del_init((struct list_head *)&m->list);
86789 spin_unlock(&v9fs_trans_lock);
86790 }
86791 EXPORT_SYMBOL(v9fs_unregister_trans);
86792 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
86793 index 02efb25..41541a9 100644
86794 --- a/net/9p/trans_fd.c
86795 +++ b/net/9p/trans_fd.c
86796 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
86797 oldfs = get_fs();
86798 set_fs(get_ds());
86799 /* The cast to a user pointer is valid due to the set_fs() */
86800 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
86801 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
86802 set_fs(oldfs);
86803
86804 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
86805 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
86806 index 876fbe8..8bbea9f 100644
86807 --- a/net/atm/atm_misc.c
86808 +++ b/net/atm/atm_misc.c
86809 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
86810 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
86811 return 1;
86812 atm_return(vcc, truesize);
86813 - atomic_inc(&vcc->stats->rx_drop);
86814 + atomic_inc_unchecked(&vcc->stats->rx_drop);
86815 return 0;
86816 }
86817 EXPORT_SYMBOL(atm_charge);
86818 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
86819 }
86820 }
86821 atm_return(vcc, guess);
86822 - atomic_inc(&vcc->stats->rx_drop);
86823 + atomic_inc_unchecked(&vcc->stats->rx_drop);
86824 return NULL;
86825 }
86826 EXPORT_SYMBOL(atm_alloc_charge);
86827 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
86828
86829 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
86830 {
86831 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
86832 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
86833 __SONET_ITEMS
86834 #undef __HANDLE_ITEM
86835 }
86836 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
86837
86838 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
86839 {
86840 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
86841 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
86842 __SONET_ITEMS
86843 #undef __HANDLE_ITEM
86844 }
86845 diff --git a/net/atm/lec.h b/net/atm/lec.h
86846 index 4149db1..f2ab682 100644
86847 --- a/net/atm/lec.h
86848 +++ b/net/atm/lec.h
86849 @@ -48,7 +48,7 @@ struct lane2_ops {
86850 const u8 *tlvs, u32 sizeoftlvs);
86851 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
86852 const u8 *tlvs, u32 sizeoftlvs);
86853 -};
86854 +} __no_const;
86855
86856 /*
86857 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
86858 diff --git a/net/atm/proc.c b/net/atm/proc.c
86859 index bbb6461..cf04016 100644
86860 --- a/net/atm/proc.c
86861 +++ b/net/atm/proc.c
86862 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
86863 const struct k_atm_aal_stats *stats)
86864 {
86865 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
86866 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
86867 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
86868 - atomic_read(&stats->rx_drop));
86869 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
86870 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
86871 + atomic_read_unchecked(&stats->rx_drop));
86872 }
86873
86874 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
86875 diff --git a/net/atm/resources.c b/net/atm/resources.c
86876 index 0447d5d..3cf4728 100644
86877 --- a/net/atm/resources.c
86878 +++ b/net/atm/resources.c
86879 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
86880 static void copy_aal_stats(struct k_atm_aal_stats *from,
86881 struct atm_aal_stats *to)
86882 {
86883 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
86884 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
86885 __AAL_STAT_ITEMS
86886 #undef __HANDLE_ITEM
86887 }
86888 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
86889 static void subtract_aal_stats(struct k_atm_aal_stats *from,
86890 struct atm_aal_stats *to)
86891 {
86892 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
86893 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
86894 __AAL_STAT_ITEMS
86895 #undef __HANDLE_ITEM
86896 }
86897 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
86898 index d5744b7..506bae3 100644
86899 --- a/net/ax25/sysctl_net_ax25.c
86900 +++ b/net/ax25/sysctl_net_ax25.c
86901 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
86902 {
86903 char path[sizeof("net/ax25/") + IFNAMSIZ];
86904 int k;
86905 - struct ctl_table *table;
86906 + ctl_table_no_const *table;
86907
86908 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
86909 if (!table)
86910 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
86911 index f680ee1..97e3542 100644
86912 --- a/net/batman-adv/bat_iv_ogm.c
86913 +++ b/net/batman-adv/bat_iv_ogm.c
86914 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
86915
86916 /* randomize initial seqno to avoid collision */
86917 get_random_bytes(&random_seqno, sizeof(random_seqno));
86918 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86919 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86920
86921 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
86922 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
86923 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
86924 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
86925
86926 /* change sequence number to network order */
86927 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
86928 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
86929 batadv_ogm_packet->seqno = htonl(seqno);
86930 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
86931 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
86932
86933 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
86934 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
86935 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
86936 return;
86937
86938 /* could be changed by schedule_own_packet() */
86939 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
86940 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
86941
86942 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
86943 has_directlink_flag = 1;
86944 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
86945 index 522243a..b48c0ef 100644
86946 --- a/net/batman-adv/hard-interface.c
86947 +++ b/net/batman-adv/hard-interface.c
86948 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
86949 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
86950 dev_add_pack(&hard_iface->batman_adv_ptype);
86951
86952 - atomic_set(&hard_iface->frag_seqno, 1);
86953 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
86954 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
86955 hard_iface->net_dev->name);
86956
86957 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
86958 /* This can't be called via a bat_priv callback because
86959 * we have no bat_priv yet.
86960 */
86961 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
86962 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
86963 hard_iface->bat_iv.ogm_buff = NULL;
86964
86965 return hard_iface;
86966 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
86967 index 819dfb0..9a672d1 100644
86968 --- a/net/batman-adv/soft-interface.c
86969 +++ b/net/batman-adv/soft-interface.c
86970 @@ -253,7 +253,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
86971 primary_if->net_dev->dev_addr, ETH_ALEN);
86972
86973 /* set broadcast sequence number */
86974 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
86975 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
86976 bcast_packet->seqno = htonl(seqno);
86977
86978 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
86979 @@ -472,7 +472,7 @@ static int batadv_softif_init_late(struct net_device *dev)
86980 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
86981
86982 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
86983 - atomic_set(&bat_priv->bcast_seqno, 1);
86984 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
86985 atomic_set(&bat_priv->tt.vn, 0);
86986 atomic_set(&bat_priv->tt.local_changes, 0);
86987 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
86988 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
86989 index aba8364..50fcbb8 100644
86990 --- a/net/batman-adv/types.h
86991 +++ b/net/batman-adv/types.h
86992 @@ -51,7 +51,7 @@
86993 struct batadv_hard_iface_bat_iv {
86994 unsigned char *ogm_buff;
86995 int ogm_buff_len;
86996 - atomic_t ogm_seqno;
86997 + atomic_unchecked_t ogm_seqno;
86998 };
86999
87000 /**
87001 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
87002 int16_t if_num;
87003 char if_status;
87004 struct net_device *net_dev;
87005 - atomic_t frag_seqno;
87006 + atomic_unchecked_t frag_seqno;
87007 struct kobject *hardif_obj;
87008 atomic_t refcount;
87009 struct packet_type batman_adv_ptype;
87010 @@ -558,7 +558,7 @@ struct batadv_priv {
87011 #ifdef CONFIG_BATMAN_ADV_DEBUG
87012 atomic_t log_level;
87013 #endif
87014 - atomic_t bcast_seqno;
87015 + atomic_unchecked_t bcast_seqno;
87016 atomic_t bcast_queue_left;
87017 atomic_t batman_queue_left;
87018 char num_ifaces;
87019 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
87020 index 0bb3b59..ffcbf2f 100644
87021 --- a/net/batman-adv/unicast.c
87022 +++ b/net/batman-adv/unicast.c
87023 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
87024 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
87025 frag2->flags = large_tail;
87026
87027 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
87028 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
87029 frag1->seqno = htons(seqno - 1);
87030 frag2->seqno = htons(seqno);
87031
87032 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
87033 index ace5e55..a65a1c0 100644
87034 --- a/net/bluetooth/hci_core.c
87035 +++ b/net/bluetooth/hci_core.c
87036 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
87037 list_add(&hdev->list, &hci_dev_list);
87038 write_unlock(&hci_dev_list_lock);
87039
87040 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
87041 - WQ_MEM_RECLAIM, 1);
87042 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
87043 + WQ_MEM_RECLAIM, 1, hdev->name);
87044 if (!hdev->workqueue) {
87045 error = -ENOMEM;
87046 goto err;
87047 }
87048
87049 - hdev->req_workqueue = alloc_workqueue(hdev->name,
87050 + hdev->req_workqueue = alloc_workqueue("%s",
87051 WQ_HIGHPRI | WQ_UNBOUND |
87052 - WQ_MEM_RECLAIM, 1);
87053 + WQ_MEM_RECLAIM, 1, hdev->name);
87054 if (!hdev->req_workqueue) {
87055 destroy_workqueue(hdev->workqueue);
87056 error = -ENOMEM;
87057 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
87058 index 9bd7d95..6c4884f 100644
87059 --- a/net/bluetooth/hci_sock.c
87060 +++ b/net/bluetooth/hci_sock.c
87061 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
87062 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
87063 }
87064
87065 - len = min_t(unsigned int, len, sizeof(uf));
87066 + len = min((size_t)len, sizeof(uf));
87067 if (copy_from_user(&uf, optval, len)) {
87068 err = -EFAULT;
87069 break;
87070 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
87071 index 68843a2..30e9342 100644
87072 --- a/net/bluetooth/l2cap_core.c
87073 +++ b/net/bluetooth/l2cap_core.c
87074 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
87075 break;
87076
87077 case L2CAP_CONF_RFC:
87078 - if (olen == sizeof(rfc))
87079 - memcpy(&rfc, (void *)val, olen);
87080 + if (olen != sizeof(rfc))
87081 + break;
87082 +
87083 + memcpy(&rfc, (void *)val, olen);
87084
87085 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
87086 rfc.mode != chan->mode)
87087 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
87088 index 36fed40..be2eeb2 100644
87089 --- a/net/bluetooth/l2cap_sock.c
87090 +++ b/net/bluetooth/l2cap_sock.c
87091 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
87092 struct sock *sk = sock->sk;
87093 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
87094 struct l2cap_options opts;
87095 - int len, err = 0;
87096 + int err = 0;
87097 + size_t len = optlen;
87098 u32 opt;
87099
87100 BT_DBG("sk %p", sk);
87101 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
87102 opts.max_tx = chan->max_tx;
87103 opts.txwin_size = chan->tx_win;
87104
87105 - len = min_t(unsigned int, sizeof(opts), optlen);
87106 + len = min(sizeof(opts), len);
87107 if (copy_from_user((char *) &opts, optval, len)) {
87108 err = -EFAULT;
87109 break;
87110 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
87111 struct bt_security sec;
87112 struct bt_power pwr;
87113 struct l2cap_conn *conn;
87114 - int len, err = 0;
87115 + int err = 0;
87116 + size_t len = optlen;
87117 u32 opt;
87118
87119 BT_DBG("sk %p", sk);
87120 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
87121
87122 sec.level = BT_SECURITY_LOW;
87123
87124 - len = min_t(unsigned int, sizeof(sec), optlen);
87125 + len = min(sizeof(sec), len);
87126 if (copy_from_user((char *) &sec, optval, len)) {
87127 err = -EFAULT;
87128 break;
87129 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
87130
87131 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
87132
87133 - len = min_t(unsigned int, sizeof(pwr), optlen);
87134 + len = min(sizeof(pwr), len);
87135 if (copy_from_user((char *) &pwr, optval, len)) {
87136 err = -EFAULT;
87137 break;
87138 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
87139 index 30b3721..c1bd0a0 100644
87140 --- a/net/bluetooth/rfcomm/sock.c
87141 +++ b/net/bluetooth/rfcomm/sock.c
87142 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
87143 struct sock *sk = sock->sk;
87144 struct bt_security sec;
87145 int err = 0;
87146 - size_t len;
87147 + size_t len = optlen;
87148 u32 opt;
87149
87150 BT_DBG("sk %p", sk);
87151 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
87152
87153 sec.level = BT_SECURITY_LOW;
87154
87155 - len = min_t(unsigned int, sizeof(sec), optlen);
87156 + len = min(sizeof(sec), len);
87157 if (copy_from_user((char *) &sec, optval, len)) {
87158 err = -EFAULT;
87159 break;
87160 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
87161 index b6e44ad..5b0d514 100644
87162 --- a/net/bluetooth/rfcomm/tty.c
87163 +++ b/net/bluetooth/rfcomm/tty.c
87164 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
87165 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
87166
87167 spin_lock_irqsave(&dev->port.lock, flags);
87168 - if (dev->port.count > 0) {
87169 + if (atomic_read(&dev->port.count) > 0) {
87170 spin_unlock_irqrestore(&dev->port.lock, flags);
87171 return;
87172 }
87173 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
87174 return -ENODEV;
87175
87176 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
87177 - dev->channel, dev->port.count);
87178 + dev->channel, atomic_read(&dev->port.count));
87179
87180 spin_lock_irqsave(&dev->port.lock, flags);
87181 - if (++dev->port.count > 1) {
87182 + if (atomic_inc_return(&dev->port.count) > 1) {
87183 spin_unlock_irqrestore(&dev->port.lock, flags);
87184 return 0;
87185 }
87186 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
87187 return;
87188
87189 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
87190 - dev->port.count);
87191 + atomic_read(&dev->port.count));
87192
87193 spin_lock_irqsave(&dev->port.lock, flags);
87194 - if (!--dev->port.count) {
87195 + if (!atomic_dec_return(&dev->port.count)) {
87196 spin_unlock_irqrestore(&dev->port.lock, flags);
87197 if (dev->tty_dev->parent)
87198 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
87199 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
87200 index 3d110c4..4e1b2eb 100644
87201 --- a/net/bridge/netfilter/ebtables.c
87202 +++ b/net/bridge/netfilter/ebtables.c
87203 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87204 tmp.valid_hooks = t->table->valid_hooks;
87205 }
87206 mutex_unlock(&ebt_mutex);
87207 - if (copy_to_user(user, &tmp, *len) != 0){
87208 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
87209 BUGPRINT("c2u Didn't work\n");
87210 ret = -EFAULT;
87211 break;
87212 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
87213 goto out;
87214 tmp.valid_hooks = t->valid_hooks;
87215
87216 - if (copy_to_user(user, &tmp, *len) != 0) {
87217 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
87218 ret = -EFAULT;
87219 break;
87220 }
87221 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
87222 tmp.entries_size = t->table->entries_size;
87223 tmp.valid_hooks = t->table->valid_hooks;
87224
87225 - if (copy_to_user(user, &tmp, *len) != 0) {
87226 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
87227 ret = -EFAULT;
87228 break;
87229 }
87230 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
87231 index 2bd4b58..0dc30a1 100644
87232 --- a/net/caif/cfctrl.c
87233 +++ b/net/caif/cfctrl.c
87234 @@ -10,6 +10,7 @@
87235 #include <linux/spinlock.h>
87236 #include <linux/slab.h>
87237 #include <linux/pkt_sched.h>
87238 +#include <linux/sched.h>
87239 #include <net/caif/caif_layer.h>
87240 #include <net/caif/cfpkt.h>
87241 #include <net/caif/cfctrl.h>
87242 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
87243 memset(&dev_info, 0, sizeof(dev_info));
87244 dev_info.id = 0xff;
87245 cfsrvl_init(&this->serv, 0, &dev_info, false);
87246 - atomic_set(&this->req_seq_no, 1);
87247 - atomic_set(&this->rsp_seq_no, 1);
87248 + atomic_set_unchecked(&this->req_seq_no, 1);
87249 + atomic_set_unchecked(&this->rsp_seq_no, 1);
87250 this->serv.layer.receive = cfctrl_recv;
87251 sprintf(this->serv.layer.name, "ctrl");
87252 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
87253 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
87254 struct cfctrl_request_info *req)
87255 {
87256 spin_lock_bh(&ctrl->info_list_lock);
87257 - atomic_inc(&ctrl->req_seq_no);
87258 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
87259 + atomic_inc_unchecked(&ctrl->req_seq_no);
87260 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
87261 list_add_tail(&req->list, &ctrl->list);
87262 spin_unlock_bh(&ctrl->info_list_lock);
87263 }
87264 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
87265 if (p != first)
87266 pr_warn("Requests are not received in order\n");
87267
87268 - atomic_set(&ctrl->rsp_seq_no,
87269 + atomic_set_unchecked(&ctrl->rsp_seq_no,
87270 p->sequence_no);
87271 list_del(&p->list);
87272 goto out;
87273 diff --git a/net/can/af_can.c b/net/can/af_can.c
87274 index c4e5085..aa9efdf 100644
87275 --- a/net/can/af_can.c
87276 +++ b/net/can/af_can.c
87277 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
87278 };
87279
87280 /* notifier block for netdevice event */
87281 -static struct notifier_block can_netdev_notifier __read_mostly = {
87282 +static struct notifier_block can_netdev_notifier = {
87283 .notifier_call = can_notifier,
87284 };
87285
87286 diff --git a/net/can/gw.c b/net/can/gw.c
87287 index 3ee690e..00d581b 100644
87288 --- a/net/can/gw.c
87289 +++ b/net/can/gw.c
87290 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
87291 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
87292
87293 static HLIST_HEAD(cgw_list);
87294 -static struct notifier_block notifier;
87295
87296 static struct kmem_cache *cgw_cache __read_mostly;
87297
87298 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
87299 return err;
87300 }
87301
87302 +static struct notifier_block notifier = {
87303 + .notifier_call = cgw_notifier
87304 +};
87305 +
87306 static __init int cgw_module_init(void)
87307 {
87308 /* sanitize given module parameter */
87309 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
87310 return -ENOMEM;
87311
87312 /* set notifier */
87313 - notifier.notifier_call = cgw_notifier;
87314 register_netdevice_notifier(&notifier);
87315
87316 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
87317 diff --git a/net/compat.c b/net/compat.c
87318 index f0a1ba6..0541331 100644
87319 --- a/net/compat.c
87320 +++ b/net/compat.c
87321 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
87322 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
87323 __get_user(kmsg->msg_flags, &umsg->msg_flags))
87324 return -EFAULT;
87325 - kmsg->msg_name = compat_ptr(tmp1);
87326 - kmsg->msg_iov = compat_ptr(tmp2);
87327 - kmsg->msg_control = compat_ptr(tmp3);
87328 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
87329 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
87330 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
87331 return 0;
87332 }
87333
87334 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
87335
87336 if (kern_msg->msg_namelen) {
87337 if (mode == VERIFY_READ) {
87338 - int err = move_addr_to_kernel(kern_msg->msg_name,
87339 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
87340 kern_msg->msg_namelen,
87341 kern_address);
87342 if (err < 0)
87343 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
87344 kern_msg->msg_name = NULL;
87345
87346 tot_len = iov_from_user_compat_to_kern(kern_iov,
87347 - (struct compat_iovec __user *)kern_msg->msg_iov,
87348 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
87349 kern_msg->msg_iovlen);
87350 if (tot_len >= 0)
87351 kern_msg->msg_iov = kern_iov;
87352 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
87353
87354 #define CMSG_COMPAT_FIRSTHDR(msg) \
87355 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
87356 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
87357 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
87358 (struct compat_cmsghdr __user *)NULL)
87359
87360 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
87361 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
87362 (ucmlen) <= (unsigned long) \
87363 ((mhdr)->msg_controllen - \
87364 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
87365 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
87366
87367 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
87368 struct compat_cmsghdr __user *cmsg, int cmsg_len)
87369 {
87370 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
87371 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
87372 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
87373 msg->msg_controllen)
87374 return NULL;
87375 return (struct compat_cmsghdr __user *)ptr;
87376 @@ -219,7 +219,7 @@ Efault:
87377
87378 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
87379 {
87380 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
87381 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
87382 struct compat_cmsghdr cmhdr;
87383 struct compat_timeval ctv;
87384 struct compat_timespec cts[3];
87385 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
87386
87387 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
87388 {
87389 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
87390 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
87391 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
87392 int fdnum = scm->fp->count;
87393 struct file **fp = scm->fp->fp;
87394 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
87395 return -EFAULT;
87396 old_fs = get_fs();
87397 set_fs(KERNEL_DS);
87398 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
87399 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
87400 set_fs(old_fs);
87401
87402 return err;
87403 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
87404 len = sizeof(ktime);
87405 old_fs = get_fs();
87406 set_fs(KERNEL_DS);
87407 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
87408 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
87409 set_fs(old_fs);
87410
87411 if (!err) {
87412 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
87413 case MCAST_JOIN_GROUP:
87414 case MCAST_LEAVE_GROUP:
87415 {
87416 - struct compat_group_req __user *gr32 = (void *)optval;
87417 + struct compat_group_req __user *gr32 = (void __user *)optval;
87418 struct group_req __user *kgr =
87419 compat_alloc_user_space(sizeof(struct group_req));
87420 u32 interface;
87421 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
87422 case MCAST_BLOCK_SOURCE:
87423 case MCAST_UNBLOCK_SOURCE:
87424 {
87425 - struct compat_group_source_req __user *gsr32 = (void *)optval;
87426 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
87427 struct group_source_req __user *kgsr = compat_alloc_user_space(
87428 sizeof(struct group_source_req));
87429 u32 interface;
87430 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
87431 }
87432 case MCAST_MSFILTER:
87433 {
87434 - struct compat_group_filter __user *gf32 = (void *)optval;
87435 + struct compat_group_filter __user *gf32 = (void __user *)optval;
87436 struct group_filter __user *kgf;
87437 u32 interface, fmode, numsrc;
87438
87439 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
87440 char __user *optval, int __user *optlen,
87441 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
87442 {
87443 - struct compat_group_filter __user *gf32 = (void *)optval;
87444 + struct compat_group_filter __user *gf32 = (void __user *)optval;
87445 struct group_filter __user *kgf;
87446 int __user *koptlen;
87447 u32 interface, fmode, numsrc;
87448 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
87449
87450 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
87451 return -EINVAL;
87452 - if (copy_from_user(a, args, nas[call]))
87453 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
87454 return -EFAULT;
87455 a0 = a[0];
87456 a1 = a[1];
87457 diff --git a/net/core/datagram.c b/net/core/datagram.c
87458 index b71423d..0360434 100644
87459 --- a/net/core/datagram.c
87460 +++ b/net/core/datagram.c
87461 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
87462 }
87463
87464 kfree_skb(skb);
87465 - atomic_inc(&sk->sk_drops);
87466 + atomic_inc_unchecked(&sk->sk_drops);
87467 sk_mem_reclaim_partial(sk);
87468
87469 return err;
87470 diff --git a/net/core/dev.c b/net/core/dev.c
87471 index 7ddbb31..3902452 100644
87472 --- a/net/core/dev.c
87473 +++ b/net/core/dev.c
87474 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
87475 {
87476 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
87477 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
87478 - atomic_long_inc(&dev->rx_dropped);
87479 + atomic_long_inc_unchecked(&dev->rx_dropped);
87480 kfree_skb(skb);
87481 return NET_RX_DROP;
87482 }
87483 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
87484 skb_orphan(skb);
87485
87486 if (unlikely(!is_skb_forwardable(dev, skb))) {
87487 - atomic_long_inc(&dev->rx_dropped);
87488 + atomic_long_inc_unchecked(&dev->rx_dropped);
87489 kfree_skb(skb);
87490 return NET_RX_DROP;
87491 }
87492 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
87493
87494 struct dev_gso_cb {
87495 void (*destructor)(struct sk_buff *skb);
87496 -};
87497 +} __no_const;
87498
87499 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
87500
87501 @@ -3139,7 +3139,7 @@ enqueue:
87502
87503 local_irq_restore(flags);
87504
87505 - atomic_long_inc(&skb->dev->rx_dropped);
87506 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
87507 kfree_skb(skb);
87508 return NET_RX_DROP;
87509 }
87510 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
87511 }
87512 EXPORT_SYMBOL(netif_rx_ni);
87513
87514 -static void net_tx_action(struct softirq_action *h)
87515 +static void net_tx_action(void)
87516 {
87517 struct softnet_data *sd = &__get_cpu_var(softnet_data);
87518
87519 @@ -3545,7 +3545,7 @@ ncls:
87520 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
87521 } else {
87522 drop:
87523 - atomic_long_inc(&skb->dev->rx_dropped);
87524 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
87525 kfree_skb(skb);
87526 /* Jamal, now you will not able to escape explaining
87527 * me how you were going to use this. :-)
87528 @@ -4153,7 +4153,7 @@ void netif_napi_del(struct napi_struct *napi)
87529 }
87530 EXPORT_SYMBOL(netif_napi_del);
87531
87532 -static void net_rx_action(struct softirq_action *h)
87533 +static void net_rx_action(void)
87534 {
87535 struct softnet_data *sd = &__get_cpu_var(softnet_data);
87536 unsigned long time_limit = jiffies + 2;
87537 @@ -5590,7 +5590,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
87538 } else {
87539 netdev_stats_to_stats64(storage, &dev->stats);
87540 }
87541 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
87542 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
87543 return storage;
87544 }
87545 EXPORT_SYMBOL(dev_get_stats);
87546 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
87547 index 5b7d0e1..cb960fc 100644
87548 --- a/net/core/dev_ioctl.c
87549 +++ b/net/core/dev_ioctl.c
87550 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
87551 if (no_module && capable(CAP_NET_ADMIN))
87552 no_module = request_module("netdev-%s", name);
87553 if (no_module && capable(CAP_SYS_MODULE)) {
87554 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
87555 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
87556 +#else
87557 if (!request_module("%s", name))
87558 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
87559 name);
87560 +#endif
87561 }
87562 }
87563 EXPORT_SYMBOL(dev_load);
87564 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
87565 index ce91766..3b71cdb 100644
87566 --- a/net/core/ethtool.c
87567 +++ b/net/core/ethtool.c
87568 @@ -1319,10 +1319,19 @@ static int ethtool_get_dump_data(struct net_device *dev,
87569 if (ret)
87570 return ret;
87571
87572 - len = (tmp.len > dump.len) ? dump.len : tmp.len;
87573 + len = min(tmp.len, dump.len);
87574 if (!len)
87575 return -EFAULT;
87576
87577 + /* Don't ever let the driver think there's more space available
87578 + * than it requested with .get_dump_flag().
87579 + */
87580 + dump.len = len;
87581 +
87582 + /* Always allocate enough space to hold the whole thing so that the
87583 + * driver does not need to check the length and bother with partial
87584 + * dumping.
87585 + */
87586 data = vzalloc(tmp.len);
87587 if (!data)
87588 return -ENOMEM;
87589 @@ -1330,6 +1339,16 @@ static int ethtool_get_dump_data(struct net_device *dev,
87590 if (ret)
87591 goto out;
87592
87593 + /* There are two sane possibilities:
87594 + * 1. The driver's .get_dump_data() does not touch dump.len.
87595 + * 2. Or it may set dump.len to how much it really writes, which
87596 + * should be tmp.len (or len if it can do a partial dump).
87597 + * In any case respond to userspace with the actual length of data
87598 + * it's receiving.
87599 + */
87600 + WARN_ON(dump.len != len && dump.len != tmp.len);
87601 + dump.len = len;
87602 +
87603 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
87604 ret = -EFAULT;
87605 goto out;
87606 diff --git a/net/core/flow.c b/net/core/flow.c
87607 index 7102f16..146b4bd 100644
87608 --- a/net/core/flow.c
87609 +++ b/net/core/flow.c
87610 @@ -61,7 +61,7 @@ struct flow_cache {
87611 struct timer_list rnd_timer;
87612 };
87613
87614 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
87615 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
87616 EXPORT_SYMBOL(flow_cache_genid);
87617 static struct flow_cache flow_cache_global;
87618 static struct kmem_cache *flow_cachep __read_mostly;
87619 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
87620
87621 static int flow_entry_valid(struct flow_cache_entry *fle)
87622 {
87623 - if (atomic_read(&flow_cache_genid) != fle->genid)
87624 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
87625 return 0;
87626 if (fle->object && !fle->object->ops->check(fle->object))
87627 return 0;
87628 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
87629 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
87630 fcp->hash_count++;
87631 }
87632 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
87633 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
87634 flo = fle->object;
87635 if (!flo)
87636 goto ret_object;
87637 @@ -279,7 +279,7 @@ nocache:
87638 }
87639 flo = resolver(net, key, family, dir, flo, ctx);
87640 if (fle) {
87641 - fle->genid = atomic_read(&flow_cache_genid);
87642 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
87643 if (!IS_ERR(flo))
87644 fle->object = flo;
87645 else
87646 diff --git a/net/core/iovec.c b/net/core/iovec.c
87647 index de178e4..1dabd8b 100644
87648 --- a/net/core/iovec.c
87649 +++ b/net/core/iovec.c
87650 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
87651 if (m->msg_namelen) {
87652 if (mode == VERIFY_READ) {
87653 void __user *namep;
87654 - namep = (void __user __force *) m->msg_name;
87655 + namep = (void __force_user *) m->msg_name;
87656 err = move_addr_to_kernel(namep, m->msg_namelen,
87657 address);
87658 if (err < 0)
87659 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
87660 }
87661
87662 size = m->msg_iovlen * sizeof(struct iovec);
87663 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
87664 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
87665 return -EFAULT;
87666
87667 m->msg_iov = iov;
87668 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
87669 index ce90b02..8752627 100644
87670 --- a/net/core/neighbour.c
87671 +++ b/net/core/neighbour.c
87672 @@ -2771,7 +2771,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
87673 size_t *lenp, loff_t *ppos)
87674 {
87675 int size, ret;
87676 - ctl_table tmp = *ctl;
87677 + ctl_table_no_const tmp = *ctl;
87678
87679 tmp.extra1 = &zero;
87680 tmp.extra2 = &unres_qlen_max;
87681 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
87682 index 569d355..79cf2d0 100644
87683 --- a/net/core/net-procfs.c
87684 +++ b/net/core/net-procfs.c
87685 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
87686 else
87687 seq_printf(seq, "%04x", ntohs(pt->type));
87688
87689 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87690 + seq_printf(seq, " %-8s %pf\n",
87691 + pt->dev ? pt->dev->name : "", NULL);
87692 +#else
87693 seq_printf(seq, " %-8s %pf\n",
87694 pt->dev ? pt->dev->name : "", pt->func);
87695 +#endif
87696 }
87697
87698 return 0;
87699 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
87700 index 981fed3..536af34 100644
87701 --- a/net/core/net-sysfs.c
87702 +++ b/net/core/net-sysfs.c
87703 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
87704 }
87705 EXPORT_SYMBOL(netdev_class_remove_file);
87706
87707 -int netdev_kobject_init(void)
87708 +int __init netdev_kobject_init(void)
87709 {
87710 kobj_ns_type_register(&net_ns_type_operations);
87711 return class_register(&net_class);
87712 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
87713 index f9765203..9feaef8 100644
87714 --- a/net/core/net_namespace.c
87715 +++ b/net/core/net_namespace.c
87716 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
87717 int error;
87718 LIST_HEAD(net_exit_list);
87719
87720 - list_add_tail(&ops->list, list);
87721 + pax_list_add_tail((struct list_head *)&ops->list, list);
87722 if (ops->init || (ops->id && ops->size)) {
87723 for_each_net(net) {
87724 error = ops_init(ops, net);
87725 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
87726
87727 out_undo:
87728 /* If I have an error cleanup all namespaces I initialized */
87729 - list_del(&ops->list);
87730 + pax_list_del((struct list_head *)&ops->list);
87731 ops_exit_list(ops, &net_exit_list);
87732 ops_free_list(ops, &net_exit_list);
87733 return error;
87734 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
87735 struct net *net;
87736 LIST_HEAD(net_exit_list);
87737
87738 - list_del(&ops->list);
87739 + pax_list_del((struct list_head *)&ops->list);
87740 for_each_net(net)
87741 list_add_tail(&net->exit_list, &net_exit_list);
87742 ops_exit_list(ops, &net_exit_list);
87743 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
87744 mutex_lock(&net_mutex);
87745 error = register_pernet_operations(&pernet_list, ops);
87746 if (!error && (first_device == &pernet_list))
87747 - first_device = &ops->list;
87748 + first_device = (struct list_head *)&ops->list;
87749 mutex_unlock(&net_mutex);
87750 return error;
87751 }
87752 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
87753 index a08bd2b..4e8f43c 100644
87754 --- a/net/core/rtnetlink.c
87755 +++ b/net/core/rtnetlink.c
87756 @@ -58,7 +58,7 @@ struct rtnl_link {
87757 rtnl_doit_func doit;
87758 rtnl_dumpit_func dumpit;
87759 rtnl_calcit_func calcit;
87760 -};
87761 +} __no_const;
87762
87763 static DEFINE_MUTEX(rtnl_mutex);
87764
87765 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
87766 if (rtnl_link_ops_get(ops->kind))
87767 return -EEXIST;
87768
87769 - if (!ops->dellink)
87770 - ops->dellink = unregister_netdevice_queue;
87771 + if (!ops->dellink) {
87772 + pax_open_kernel();
87773 + *(void **)&ops->dellink = unregister_netdevice_queue;
87774 + pax_close_kernel();
87775 + }
87776
87777 - list_add_tail(&ops->list, &link_ops);
87778 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
87779 return 0;
87780 }
87781 EXPORT_SYMBOL_GPL(__rtnl_link_register);
87782 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
87783 for_each_net(net) {
87784 __rtnl_kill_links(net, ops);
87785 }
87786 - list_del(&ops->list);
87787 + pax_list_del((struct list_head *)&ops->list);
87788 }
87789 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
87790
87791 diff --git a/net/core/scm.c b/net/core/scm.c
87792 index 03795d0..eaf7368 100644
87793 --- a/net/core/scm.c
87794 +++ b/net/core/scm.c
87795 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
87796 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
87797 {
87798 struct cmsghdr __user *cm
87799 - = (__force struct cmsghdr __user *)msg->msg_control;
87800 + = (struct cmsghdr __force_user *)msg->msg_control;
87801 struct cmsghdr cmhdr;
87802 int cmlen = CMSG_LEN(len);
87803 int err;
87804 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
87805 err = -EFAULT;
87806 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
87807 goto out;
87808 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
87809 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
87810 goto out;
87811 cmlen = CMSG_SPACE(len);
87812 if (msg->msg_controllen < cmlen)
87813 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
87814 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
87815 {
87816 struct cmsghdr __user *cm
87817 - = (__force struct cmsghdr __user*)msg->msg_control;
87818 + = (struct cmsghdr __force_user *)msg->msg_control;
87819
87820 int fdmax = 0;
87821 int fdnum = scm->fp->count;
87822 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
87823 if (fdnum < fdmax)
87824 fdmax = fdnum;
87825
87826 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
87827 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
87828 i++, cmfptr++)
87829 {
87830 struct socket *sock;
87831 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
87832 index 1c1738c..4cab7f0 100644
87833 --- a/net/core/skbuff.c
87834 +++ b/net/core/skbuff.c
87835 @@ -3087,13 +3087,15 @@ void __init skb_init(void)
87836 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
87837 sizeof(struct sk_buff),
87838 0,
87839 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
87840 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
87841 + SLAB_NO_SANITIZE,
87842 NULL);
87843 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
87844 (2*sizeof(struct sk_buff)) +
87845 sizeof(atomic_t),
87846 0,
87847 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
87848 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
87849 + SLAB_NO_SANITIZE,
87850 NULL);
87851 }
87852
87853 diff --git a/net/core/sock.c b/net/core/sock.c
87854 index d6d024c..6ea7ab4 100644
87855 --- a/net/core/sock.c
87856 +++ b/net/core/sock.c
87857 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87858 struct sk_buff_head *list = &sk->sk_receive_queue;
87859
87860 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
87861 - atomic_inc(&sk->sk_drops);
87862 + atomic_inc_unchecked(&sk->sk_drops);
87863 trace_sock_rcvqueue_full(sk, skb);
87864 return -ENOMEM;
87865 }
87866 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87867 return err;
87868
87869 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
87870 - atomic_inc(&sk->sk_drops);
87871 + atomic_inc_unchecked(&sk->sk_drops);
87872 return -ENOBUFS;
87873 }
87874
87875 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87876 skb_dst_force(skb);
87877
87878 spin_lock_irqsave(&list->lock, flags);
87879 - skb->dropcount = atomic_read(&sk->sk_drops);
87880 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
87881 __skb_queue_tail(list, skb);
87882 spin_unlock_irqrestore(&list->lock, flags);
87883
87884 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
87885 skb->dev = NULL;
87886
87887 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
87888 - atomic_inc(&sk->sk_drops);
87889 + atomic_inc_unchecked(&sk->sk_drops);
87890 goto discard_and_relse;
87891 }
87892 if (nested)
87893 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
87894 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
87895 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
87896 bh_unlock_sock(sk);
87897 - atomic_inc(&sk->sk_drops);
87898 + atomic_inc_unchecked(&sk->sk_drops);
87899 goto discard_and_relse;
87900 }
87901
87902 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87903 struct timeval tm;
87904 } v;
87905
87906 - int lv = sizeof(int);
87907 - int len;
87908 + unsigned int lv = sizeof(int);
87909 + unsigned int len;
87910
87911 if (get_user(len, optlen))
87912 return -EFAULT;
87913 - if (len < 0)
87914 + if (len > INT_MAX)
87915 return -EINVAL;
87916
87917 memset(&v, 0, sizeof(v));
87918 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87919
87920 case SO_PEERNAME:
87921 {
87922 - char address[128];
87923 + char address[_K_SS_MAXSIZE];
87924
87925 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
87926 return -ENOTCONN;
87927 - if (lv < len)
87928 + if (lv < len || sizeof address < len)
87929 return -EINVAL;
87930 if (copy_to_user(optval, address, len))
87931 return -EFAULT;
87932 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87933
87934 if (len > lv)
87935 len = lv;
87936 - if (copy_to_user(optval, &v, len))
87937 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
87938 return -EFAULT;
87939 lenout:
87940 if (put_user(len, optlen))
87941 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
87942 */
87943 smp_wmb();
87944 atomic_set(&sk->sk_refcnt, 1);
87945 - atomic_set(&sk->sk_drops, 0);
87946 + atomic_set_unchecked(&sk->sk_drops, 0);
87947 }
87948 EXPORT_SYMBOL(sock_init_data);
87949
87950 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
87951 index a0e9cf6..ef7f9ed 100644
87952 --- a/net/core/sock_diag.c
87953 +++ b/net/core/sock_diag.c
87954 @@ -9,26 +9,33 @@
87955 #include <linux/inet_diag.h>
87956 #include <linux/sock_diag.h>
87957
87958 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
87959 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
87960 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
87961 static DEFINE_MUTEX(sock_diag_table_mutex);
87962
87963 int sock_diag_check_cookie(void *sk, __u32 *cookie)
87964 {
87965 +#ifndef CONFIG_GRKERNSEC_HIDESYM
87966 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
87967 cookie[1] != INET_DIAG_NOCOOKIE) &&
87968 ((u32)(unsigned long)sk != cookie[0] ||
87969 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
87970 return -ESTALE;
87971 else
87972 +#endif
87973 return 0;
87974 }
87975 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
87976
87977 void sock_diag_save_cookie(void *sk, __u32 *cookie)
87978 {
87979 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87980 + cookie[0] = 0;
87981 + cookie[1] = 0;
87982 +#else
87983 cookie[0] = (u32)(unsigned long)sk;
87984 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
87985 +#endif
87986 }
87987 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
87988
87989 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
87990 mutex_lock(&sock_diag_table_mutex);
87991 if (sock_diag_handlers[hndl->family])
87992 err = -EBUSY;
87993 - else
87994 + else {
87995 + pax_open_kernel();
87996 sock_diag_handlers[hndl->family] = hndl;
87997 + pax_close_kernel();
87998 + }
87999 mutex_unlock(&sock_diag_table_mutex);
88000
88001 return err;
88002 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
88003
88004 mutex_lock(&sock_diag_table_mutex);
88005 BUG_ON(sock_diag_handlers[family] != hnld);
88006 + pax_open_kernel();
88007 sock_diag_handlers[family] = NULL;
88008 + pax_close_kernel();
88009 mutex_unlock(&sock_diag_table_mutex);
88010 }
88011 EXPORT_SYMBOL_GPL(sock_diag_unregister);
88012 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
88013 index cfdb46a..cef55e1 100644
88014 --- a/net/core/sysctl_net_core.c
88015 +++ b/net/core/sysctl_net_core.c
88016 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
88017 {
88018 unsigned int orig_size, size;
88019 int ret, i;
88020 - ctl_table tmp = {
88021 + ctl_table_no_const tmp = {
88022 .data = &size,
88023 .maxlen = sizeof(size),
88024 .mode = table->mode
88025 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
88026
88027 static __net_init int sysctl_core_net_init(struct net *net)
88028 {
88029 - struct ctl_table *tbl;
88030 + ctl_table_no_const *tbl = NULL;
88031
88032 net->core.sysctl_somaxconn = SOMAXCONN;
88033
88034 - tbl = netns_core_table;
88035 if (!net_eq(net, &init_net)) {
88036 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
88037 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
88038 if (tbl == NULL)
88039 goto err_dup;
88040
88041 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
88042 if (net->user_ns != &init_user_ns) {
88043 tbl[0].procname = NULL;
88044 }
88045 - }
88046 -
88047 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
88048 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
88049 + } else
88050 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
88051 if (net->core.sysctl_hdr == NULL)
88052 goto err_reg;
88053
88054 return 0;
88055
88056 err_reg:
88057 - if (tbl != netns_core_table)
88058 - kfree(tbl);
88059 + kfree(tbl);
88060 err_dup:
88061 return -ENOMEM;
88062 }
88063 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
88064 kfree(tbl);
88065 }
88066
88067 -static __net_initdata struct pernet_operations sysctl_core_ops = {
88068 +static __net_initconst struct pernet_operations sysctl_core_ops = {
88069 .init = sysctl_core_net_init,
88070 .exit = sysctl_core_net_exit,
88071 };
88072 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
88073 index c21f200..bc4565b 100644
88074 --- a/net/decnet/af_decnet.c
88075 +++ b/net/decnet/af_decnet.c
88076 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
88077 .sysctl_rmem = sysctl_decnet_rmem,
88078 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
88079 .obj_size = sizeof(struct dn_sock),
88080 + .slab_flags = SLAB_USERCOPY,
88081 };
88082
88083 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
88084 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
88085 index a55eecc..dd8428c 100644
88086 --- a/net/decnet/sysctl_net_decnet.c
88087 +++ b/net/decnet/sysctl_net_decnet.c
88088 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
88089
88090 if (len > *lenp) len = *lenp;
88091
88092 - if (copy_to_user(buffer, addr, len))
88093 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
88094 return -EFAULT;
88095
88096 *lenp = len;
88097 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
88098
88099 if (len > *lenp) len = *lenp;
88100
88101 - if (copy_to_user(buffer, devname, len))
88102 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
88103 return -EFAULT;
88104
88105 *lenp = len;
88106 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
88107 index d01be2a..8976537 100644
88108 --- a/net/ipv4/af_inet.c
88109 +++ b/net/ipv4/af_inet.c
88110 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
88111
88112 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
88113
88114 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
88115 - if (!sysctl_local_reserved_ports)
88116 - goto out;
88117 -
88118 rc = proto_register(&tcp_prot, 1);
88119 if (rc)
88120 - goto out_free_reserved_ports;
88121 + goto out;
88122
88123 rc = proto_register(&udp_prot, 1);
88124 if (rc)
88125 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
88126 proto_unregister(&udp_prot);
88127 out_unregister_tcp_proto:
88128 proto_unregister(&tcp_prot);
88129 -out_free_reserved_ports:
88130 - kfree(sysctl_local_reserved_ports);
88131 goto out;
88132 }
88133
88134 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
88135 index 2e7f194..0fa4d6d 100644
88136 --- a/net/ipv4/ah4.c
88137 +++ b/net/ipv4/ah4.c
88138 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
88139 return;
88140
88141 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
88142 - atomic_inc(&flow_cache_genid);
88143 + atomic_inc_unchecked(&flow_cache_genid);
88144 rt_genid_bump(net);
88145
88146 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
88147 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
88148 index dfc39d4..0b82c4d 100644
88149 --- a/net/ipv4/devinet.c
88150 +++ b/net/ipv4/devinet.c
88151 @@ -1529,7 +1529,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
88152 idx = 0;
88153 head = &net->dev_index_head[h];
88154 rcu_read_lock();
88155 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
88156 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
88157 net->dev_base_seq;
88158 hlist_for_each_entry_rcu(dev, head, index_hlist) {
88159 if (idx < s_idx)
88160 @@ -1840,7 +1840,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
88161 idx = 0;
88162 head = &net->dev_index_head[h];
88163 rcu_read_lock();
88164 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
88165 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
88166 net->dev_base_seq;
88167 hlist_for_each_entry_rcu(dev, head, index_hlist) {
88168 if (idx < s_idx)
88169 @@ -2065,7 +2065,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
88170 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
88171 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
88172
88173 -static struct devinet_sysctl_table {
88174 +static const struct devinet_sysctl_table {
88175 struct ctl_table_header *sysctl_header;
88176 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
88177 } devinet_sysctl = {
88178 @@ -2183,7 +2183,7 @@ static __net_init int devinet_init_net(struct net *net)
88179 int err;
88180 struct ipv4_devconf *all, *dflt;
88181 #ifdef CONFIG_SYSCTL
88182 - struct ctl_table *tbl = ctl_forward_entry;
88183 + ctl_table_no_const *tbl = NULL;
88184 struct ctl_table_header *forw_hdr;
88185 #endif
88186
88187 @@ -2201,7 +2201,7 @@ static __net_init int devinet_init_net(struct net *net)
88188 goto err_alloc_dflt;
88189
88190 #ifdef CONFIG_SYSCTL
88191 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
88192 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
88193 if (tbl == NULL)
88194 goto err_alloc_ctl;
88195
88196 @@ -2221,7 +2221,10 @@ static __net_init int devinet_init_net(struct net *net)
88197 goto err_reg_dflt;
88198
88199 err = -ENOMEM;
88200 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
88201 + if (!net_eq(net, &init_net))
88202 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
88203 + else
88204 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
88205 if (forw_hdr == NULL)
88206 goto err_reg_ctl;
88207 net->ipv4.forw_hdr = forw_hdr;
88208 @@ -2237,8 +2240,7 @@ err_reg_ctl:
88209 err_reg_dflt:
88210 __devinet_sysctl_unregister(all);
88211 err_reg_all:
88212 - if (tbl != ctl_forward_entry)
88213 - kfree(tbl);
88214 + kfree(tbl);
88215 err_alloc_ctl:
88216 #endif
88217 if (dflt != &ipv4_devconf_dflt)
88218 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
88219 index 4cfe34d..a6ba66e 100644
88220 --- a/net/ipv4/esp4.c
88221 +++ b/net/ipv4/esp4.c
88222 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
88223 return;
88224
88225 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
88226 - atomic_inc(&flow_cache_genid);
88227 + atomic_inc_unchecked(&flow_cache_genid);
88228 rt_genid_bump(net);
88229
88230 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
88231 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
88232 index c7629a2..b62d139 100644
88233 --- a/net/ipv4/fib_frontend.c
88234 +++ b/net/ipv4/fib_frontend.c
88235 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
88236 #ifdef CONFIG_IP_ROUTE_MULTIPATH
88237 fib_sync_up(dev);
88238 #endif
88239 - atomic_inc(&net->ipv4.dev_addr_genid);
88240 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
88241 rt_cache_flush(dev_net(dev));
88242 break;
88243 case NETDEV_DOWN:
88244 fib_del_ifaddr(ifa, NULL);
88245 - atomic_inc(&net->ipv4.dev_addr_genid);
88246 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
88247 if (ifa->ifa_dev->ifa_list == NULL) {
88248 /* Last address was deleted from this interface.
88249 * Disable IP.
88250 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
88251 #ifdef CONFIG_IP_ROUTE_MULTIPATH
88252 fib_sync_up(dev);
88253 #endif
88254 - atomic_inc(&net->ipv4.dev_addr_genid);
88255 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
88256 rt_cache_flush(net);
88257 break;
88258 case NETDEV_DOWN:
88259 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
88260 index 8f6cb7a..34507f9 100644
88261 --- a/net/ipv4/fib_semantics.c
88262 +++ b/net/ipv4/fib_semantics.c
88263 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
88264 nh->nh_saddr = inet_select_addr(nh->nh_dev,
88265 nh->nh_gw,
88266 nh->nh_parent->fib_scope);
88267 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
88268 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
88269
88270 return nh->nh_saddr;
88271 }
88272 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
88273 index 6acb541..9ea617d 100644
88274 --- a/net/ipv4/inet_connection_sock.c
88275 +++ b/net/ipv4/inet_connection_sock.c
88276 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
88277 .range = { 32768, 61000 },
88278 };
88279
88280 -unsigned long *sysctl_local_reserved_ports;
88281 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
88282 EXPORT_SYMBOL(sysctl_local_reserved_ports);
88283
88284 void inet_get_local_port_range(int *low, int *high)
88285 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
88286 index 6af375a..c493c74 100644
88287 --- a/net/ipv4/inet_hashtables.c
88288 +++ b/net/ipv4/inet_hashtables.c
88289 @@ -18,12 +18,15 @@
88290 #include <linux/sched.h>
88291 #include <linux/slab.h>
88292 #include <linux/wait.h>
88293 +#include <linux/security.h>
88294
88295 #include <net/inet_connection_sock.h>
88296 #include <net/inet_hashtables.h>
88297 #include <net/secure_seq.h>
88298 #include <net/ip.h>
88299
88300 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
88301 +
88302 /*
88303 * Allocate and initialize a new local port bind bucket.
88304 * The bindhash mutex for snum's hash chain must be held here.
88305 @@ -554,6 +557,8 @@ ok:
88306 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
88307 spin_unlock(&head->lock);
88308
88309 + gr_update_task_in_ip_table(current, inet_sk(sk));
88310 +
88311 if (tw) {
88312 inet_twsk_deschedule(tw, death_row);
88313 while (twrefcnt) {
88314 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
88315 index 000e3d2..5472da3 100644
88316 --- a/net/ipv4/inetpeer.c
88317 +++ b/net/ipv4/inetpeer.c
88318 @@ -503,8 +503,8 @@ relookup:
88319 if (p) {
88320 p->daddr = *daddr;
88321 atomic_set(&p->refcnt, 1);
88322 - atomic_set(&p->rid, 0);
88323 - atomic_set(&p->ip_id_count,
88324 + atomic_set_unchecked(&p->rid, 0);
88325 + atomic_set_unchecked(&p->ip_id_count,
88326 (daddr->family == AF_INET) ?
88327 secure_ip_id(daddr->addr.a4) :
88328 secure_ipv6_id(daddr->addr.a6));
88329 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
88330 index b66910a..cfe416e 100644
88331 --- a/net/ipv4/ip_fragment.c
88332 +++ b/net/ipv4/ip_fragment.c
88333 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
88334 return 0;
88335
88336 start = qp->rid;
88337 - end = atomic_inc_return(&peer->rid);
88338 + end = atomic_inc_return_unchecked(&peer->rid);
88339 qp->rid = end;
88340
88341 rc = qp->q.fragments && (end - start) > max;
88342 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
88343
88344 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
88345 {
88346 - struct ctl_table *table;
88347 + ctl_table_no_const *table = NULL;
88348 struct ctl_table_header *hdr;
88349
88350 - table = ip4_frags_ns_ctl_table;
88351 if (!net_eq(net, &init_net)) {
88352 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
88353 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
88354 if (table == NULL)
88355 goto err_alloc;
88356
88357 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
88358 /* Don't export sysctls to unprivileged users */
88359 if (net->user_ns != &init_user_ns)
88360 table[0].procname = NULL;
88361 - }
88362 + hdr = register_net_sysctl(net, "net/ipv4", table);
88363 + } else
88364 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
88365
88366 - hdr = register_net_sysctl(net, "net/ipv4", table);
88367 if (hdr == NULL)
88368 goto err_reg;
88369
88370 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
88371 return 0;
88372
88373 err_reg:
88374 - if (!net_eq(net, &init_net))
88375 - kfree(table);
88376 + kfree(table);
88377 err_alloc:
88378 return -ENOMEM;
88379 }
88380 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
88381 index 855004f..68e7458 100644
88382 --- a/net/ipv4/ip_gre.c
88383 +++ b/net/ipv4/ip_gre.c
88384 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
88385 module_param(log_ecn_error, bool, 0644);
88386 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88387
88388 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
88389 +static struct rtnl_link_ops ipgre_link_ops;
88390 static int ipgre_tunnel_init(struct net_device *dev);
88391
88392 static int ipgre_net_id __read_mostly;
88393 @@ -919,7 +919,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
88394 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
88395 };
88396
88397 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
88398 +static struct rtnl_link_ops ipgre_link_ops = {
88399 .kind = "gre",
88400 .maxtype = IFLA_GRE_MAX,
88401 .policy = ipgre_policy,
88402 @@ -933,7 +933,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
88403 .fill_info = ipgre_fill_info,
88404 };
88405
88406 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
88407 +static struct rtnl_link_ops ipgre_tap_ops = {
88408 .kind = "gretap",
88409 .maxtype = IFLA_GRE_MAX,
88410 .policy = ipgre_policy,
88411 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
88412 index d9c4f11..02b82dbc 100644
88413 --- a/net/ipv4/ip_sockglue.c
88414 +++ b/net/ipv4/ip_sockglue.c
88415 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
88416 len = min_t(unsigned int, len, opt->optlen);
88417 if (put_user(len, optlen))
88418 return -EFAULT;
88419 - if (copy_to_user(optval, opt->__data, len))
88420 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
88421 + copy_to_user(optval, opt->__data, len))
88422 return -EFAULT;
88423 return 0;
88424 }
88425 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
88426 if (sk->sk_type != SOCK_STREAM)
88427 return -ENOPROTOOPT;
88428
88429 - msg.msg_control = optval;
88430 + msg.msg_control = (void __force_kernel *)optval;
88431 msg.msg_controllen = len;
88432 msg.msg_flags = flags;
88433
88434 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
88435 index 17cc0ff..63856c4 100644
88436 --- a/net/ipv4/ip_vti.c
88437 +++ b/net/ipv4/ip_vti.c
88438 @@ -47,7 +47,7 @@
88439 #define HASH_SIZE 16
88440 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
88441
88442 -static struct rtnl_link_ops vti_link_ops __read_mostly;
88443 +static struct rtnl_link_ops vti_link_ops;
88444
88445 static int vti_net_id __read_mostly;
88446 struct vti_net {
88447 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
88448 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
88449 };
88450
88451 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
88452 +static struct rtnl_link_ops vti_link_ops = {
88453 .kind = "vti",
88454 .maxtype = IFLA_VTI_MAX,
88455 .policy = vti_policy,
88456 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
88457 index 59cb8c7..a72160c 100644
88458 --- a/net/ipv4/ipcomp.c
88459 +++ b/net/ipv4/ipcomp.c
88460 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
88461 return;
88462
88463 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
88464 - atomic_inc(&flow_cache_genid);
88465 + atomic_inc_unchecked(&flow_cache_genid);
88466 rt_genid_bump(net);
88467
88468 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
88469 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
88470 index efa1138..20dbba0 100644
88471 --- a/net/ipv4/ipconfig.c
88472 +++ b/net/ipv4/ipconfig.c
88473 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
88474
88475 mm_segment_t oldfs = get_fs();
88476 set_fs(get_ds());
88477 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
88478 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
88479 set_fs(oldfs);
88480 return res;
88481 }
88482 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
88483
88484 mm_segment_t oldfs = get_fs();
88485 set_fs(get_ds());
88486 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
88487 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
88488 set_fs(oldfs);
88489 return res;
88490 }
88491 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
88492
88493 mm_segment_t oldfs = get_fs();
88494 set_fs(get_ds());
88495 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
88496 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
88497 set_fs(oldfs);
88498 return res;
88499 }
88500 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
88501 index 7cfc456..e726868 100644
88502 --- a/net/ipv4/ipip.c
88503 +++ b/net/ipv4/ipip.c
88504 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88505 static int ipip_net_id __read_mostly;
88506
88507 static int ipip_tunnel_init(struct net_device *dev);
88508 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
88509 +static struct rtnl_link_ops ipip_link_ops;
88510
88511 static int ipip_err(struct sk_buff *skb, u32 info)
88512 {
88513 @@ -406,7 +406,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
88514 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
88515 };
88516
88517 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
88518 +static struct rtnl_link_ops ipip_link_ops = {
88519 .kind = "ipip",
88520 .maxtype = IFLA_IPTUN_MAX,
88521 .policy = ipip_policy,
88522 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
88523 index 85a4f21..1beb1f5 100644
88524 --- a/net/ipv4/netfilter/arp_tables.c
88525 +++ b/net/ipv4/netfilter/arp_tables.c
88526 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
88527 #endif
88528
88529 static int get_info(struct net *net, void __user *user,
88530 - const int *len, int compat)
88531 + int len, int compat)
88532 {
88533 char name[XT_TABLE_MAXNAMELEN];
88534 struct xt_table *t;
88535 int ret;
88536
88537 - if (*len != sizeof(struct arpt_getinfo)) {
88538 - duprintf("length %u != %Zu\n", *len,
88539 + if (len != sizeof(struct arpt_getinfo)) {
88540 + duprintf("length %u != %Zu\n", len,
88541 sizeof(struct arpt_getinfo));
88542 return -EINVAL;
88543 }
88544 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
88545 info.size = private->size;
88546 strcpy(info.name, name);
88547
88548 - if (copy_to_user(user, &info, *len) != 0)
88549 + if (copy_to_user(user, &info, len) != 0)
88550 ret = -EFAULT;
88551 else
88552 ret = 0;
88553 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
88554
88555 switch (cmd) {
88556 case ARPT_SO_GET_INFO:
88557 - ret = get_info(sock_net(sk), user, len, 1);
88558 + ret = get_info(sock_net(sk), user, *len, 1);
88559 break;
88560 case ARPT_SO_GET_ENTRIES:
88561 ret = compat_get_entries(sock_net(sk), user, len);
88562 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
88563
88564 switch (cmd) {
88565 case ARPT_SO_GET_INFO:
88566 - ret = get_info(sock_net(sk), user, len, 0);
88567 + ret = get_info(sock_net(sk), user, *len, 0);
88568 break;
88569
88570 case ARPT_SO_GET_ENTRIES:
88571 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
88572 index d23118d..6ad7277 100644
88573 --- a/net/ipv4/netfilter/ip_tables.c
88574 +++ b/net/ipv4/netfilter/ip_tables.c
88575 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
88576 #endif
88577
88578 static int get_info(struct net *net, void __user *user,
88579 - const int *len, int compat)
88580 + int len, int compat)
88581 {
88582 char name[XT_TABLE_MAXNAMELEN];
88583 struct xt_table *t;
88584 int ret;
88585
88586 - if (*len != sizeof(struct ipt_getinfo)) {
88587 - duprintf("length %u != %zu\n", *len,
88588 + if (len != sizeof(struct ipt_getinfo)) {
88589 + duprintf("length %u != %zu\n", len,
88590 sizeof(struct ipt_getinfo));
88591 return -EINVAL;
88592 }
88593 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
88594 info.size = private->size;
88595 strcpy(info.name, name);
88596
88597 - if (copy_to_user(user, &info, *len) != 0)
88598 + if (copy_to_user(user, &info, len) != 0)
88599 ret = -EFAULT;
88600 else
88601 ret = 0;
88602 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88603
88604 switch (cmd) {
88605 case IPT_SO_GET_INFO:
88606 - ret = get_info(sock_net(sk), user, len, 1);
88607 + ret = get_info(sock_net(sk), user, *len, 1);
88608 break;
88609 case IPT_SO_GET_ENTRIES:
88610 ret = compat_get_entries(sock_net(sk), user, len);
88611 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88612
88613 switch (cmd) {
88614 case IPT_SO_GET_INFO:
88615 - ret = get_info(sock_net(sk), user, len, 0);
88616 + ret = get_info(sock_net(sk), user, *len, 0);
88617 break;
88618
88619 case IPT_SO_GET_ENTRIES:
88620 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
88621 index 7d93d62..cbbf2a3 100644
88622 --- a/net/ipv4/ping.c
88623 +++ b/net/ipv4/ping.c
88624 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
88625 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
88626 0, sock_i_ino(sp),
88627 atomic_read(&sp->sk_refcnt), sp,
88628 - atomic_read(&sp->sk_drops), len);
88629 + atomic_read_unchecked(&sp->sk_drops), len);
88630 }
88631
88632 static int ping_seq_show(struct seq_file *seq, void *v)
88633 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
88634 index dd44e0a..06dcca4 100644
88635 --- a/net/ipv4/raw.c
88636 +++ b/net/ipv4/raw.c
88637 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
88638 int raw_rcv(struct sock *sk, struct sk_buff *skb)
88639 {
88640 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
88641 - atomic_inc(&sk->sk_drops);
88642 + atomic_inc_unchecked(&sk->sk_drops);
88643 kfree_skb(skb);
88644 return NET_RX_DROP;
88645 }
88646 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
88647
88648 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
88649 {
88650 + struct icmp_filter filter;
88651 +
88652 if (optlen > sizeof(struct icmp_filter))
88653 optlen = sizeof(struct icmp_filter);
88654 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
88655 + if (copy_from_user(&filter, optval, optlen))
88656 return -EFAULT;
88657 + raw_sk(sk)->filter = filter;
88658 return 0;
88659 }
88660
88661 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
88662 {
88663 int len, ret = -EFAULT;
88664 + struct icmp_filter filter;
88665
88666 if (get_user(len, optlen))
88667 goto out;
88668 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
88669 if (len > sizeof(struct icmp_filter))
88670 len = sizeof(struct icmp_filter);
88671 ret = -EFAULT;
88672 - if (put_user(len, optlen) ||
88673 - copy_to_user(optval, &raw_sk(sk)->filter, len))
88674 + filter = raw_sk(sk)->filter;
88675 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
88676 goto out;
88677 ret = 0;
88678 out: return ret;
88679 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88680 0, 0L, 0,
88681 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88682 0, sock_i_ino(sp),
88683 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88684 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88685 }
88686
88687 static int raw_seq_show(struct seq_file *seq, void *v)
88688 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
88689 index d35bbf0..faa3ab8 100644
88690 --- a/net/ipv4/route.c
88691 +++ b/net/ipv4/route.c
88692 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
88693 .maxlen = sizeof(int),
88694 .mode = 0200,
88695 .proc_handler = ipv4_sysctl_rtcache_flush,
88696 + .extra1 = &init_net,
88697 },
88698 { },
88699 };
88700
88701 static __net_init int sysctl_route_net_init(struct net *net)
88702 {
88703 - struct ctl_table *tbl;
88704 + ctl_table_no_const *tbl = NULL;
88705
88706 - tbl = ipv4_route_flush_table;
88707 if (!net_eq(net, &init_net)) {
88708 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
88709 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
88710 if (tbl == NULL)
88711 goto err_dup;
88712
88713 /* Don't export sysctls to unprivileged users */
88714 if (net->user_ns != &init_user_ns)
88715 tbl[0].procname = NULL;
88716 - }
88717 - tbl[0].extra1 = net;
88718 + tbl[0].extra1 = net;
88719 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
88720 + } else
88721 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
88722
88723 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
88724 if (net->ipv4.route_hdr == NULL)
88725 goto err_reg;
88726 return 0;
88727
88728 err_reg:
88729 - if (tbl != ipv4_route_flush_table)
88730 - kfree(tbl);
88731 + kfree(tbl);
88732 err_dup:
88733 return -ENOMEM;
88734 }
88735 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
88736
88737 static __net_init int rt_genid_init(struct net *net)
88738 {
88739 - atomic_set(&net->rt_genid, 0);
88740 + atomic_set_unchecked(&net->rt_genid, 0);
88741 get_random_bytes(&net->ipv4.dev_addr_genid,
88742 sizeof(net->ipv4.dev_addr_genid));
88743 return 0;
88744 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
88745 index fa2f63f..6554815 100644
88746 --- a/net/ipv4/sysctl_net_ipv4.c
88747 +++ b/net/ipv4/sysctl_net_ipv4.c
88748 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
88749 {
88750 int ret;
88751 int range[2];
88752 - ctl_table tmp = {
88753 + ctl_table_no_const tmp = {
88754 .data = &range,
88755 .maxlen = sizeof(range),
88756 .mode = table->mode,
88757 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
88758 int ret;
88759 gid_t urange[2];
88760 kgid_t low, high;
88761 - ctl_table tmp = {
88762 + ctl_table_no_const tmp = {
88763 .data = &urange,
88764 .maxlen = sizeof(urange),
88765 .mode = table->mode,
88766 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
88767 void __user *buffer, size_t *lenp, loff_t *ppos)
88768 {
88769 char val[TCP_CA_NAME_MAX];
88770 - ctl_table tbl = {
88771 + ctl_table_no_const tbl = {
88772 .data = val,
88773 .maxlen = TCP_CA_NAME_MAX,
88774 };
88775 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
88776 void __user *buffer, size_t *lenp,
88777 loff_t *ppos)
88778 {
88779 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
88780 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
88781 int ret;
88782
88783 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
88784 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
88785 void __user *buffer, size_t *lenp,
88786 loff_t *ppos)
88787 {
88788 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
88789 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
88790 int ret;
88791
88792 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
88793 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
88794 struct mem_cgroup *memcg;
88795 #endif
88796
88797 - ctl_table tmp = {
88798 + ctl_table_no_const tmp = {
88799 .data = &vec,
88800 .maxlen = sizeof(vec),
88801 .mode = ctl->mode,
88802 };
88803
88804 if (!write) {
88805 - ctl->data = &net->ipv4.sysctl_tcp_mem;
88806 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
88807 + ctl_table_no_const tcp_mem = *ctl;
88808 +
88809 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
88810 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
88811 }
88812
88813 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
88814 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
88815 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
88816 size_t *lenp, loff_t *ppos)
88817 {
88818 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
88819 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
88820 struct tcp_fastopen_context *ctxt;
88821 int ret;
88822 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
88823 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
88824 },
88825 {
88826 .procname = "ip_local_reserved_ports",
88827 - .data = NULL, /* initialized in sysctl_ipv4_init */
88828 + .data = sysctl_local_reserved_ports,
88829 .maxlen = 65536,
88830 .mode = 0644,
88831 .proc_handler = proc_do_large_bitmap,
88832 @@ -842,11 +844,10 @@ static struct ctl_table ipv4_net_table[] = {
88833
88834 static __net_init int ipv4_sysctl_init_net(struct net *net)
88835 {
88836 - struct ctl_table *table;
88837 + ctl_table_no_const *table = NULL;
88838
88839 - table = ipv4_net_table;
88840 if (!net_eq(net, &init_net)) {
88841 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
88842 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
88843 if (table == NULL)
88844 goto err_alloc;
88845
88846 @@ -881,15 +882,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
88847
88848 tcp_init_mem(net);
88849
88850 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
88851 + if (!net_eq(net, &init_net))
88852 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
88853 + else
88854 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
88855 if (net->ipv4.ipv4_hdr == NULL)
88856 goto err_reg;
88857
88858 return 0;
88859
88860 err_reg:
88861 - if (!net_eq(net, &init_net))
88862 - kfree(table);
88863 + kfree(table);
88864 err_alloc:
88865 return -ENOMEM;
88866 }
88867 @@ -911,16 +914,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
88868 static __init int sysctl_ipv4_init(void)
88869 {
88870 struct ctl_table_header *hdr;
88871 - struct ctl_table *i;
88872 -
88873 - for (i = ipv4_table; i->procname; i++) {
88874 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
88875 - i->data = sysctl_local_reserved_ports;
88876 - break;
88877 - }
88878 - }
88879 - if (!i->procname)
88880 - return -EINVAL;
88881
88882 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
88883 if (hdr == NULL)
88884 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
88885 index 9c62257..651cc27 100644
88886 --- a/net/ipv4/tcp_input.c
88887 +++ b/net/ipv4/tcp_input.c
88888 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
88889 * simplifies code)
88890 */
88891 static void
88892 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88893 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88894 struct sk_buff *head, struct sk_buff *tail,
88895 u32 start, u32 end)
88896 {
88897 @@ -5522,6 +5522,7 @@ discard:
88898 tcp_paws_reject(&tp->rx_opt, 0))
88899 goto discard_and_undo;
88900
88901 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
88902 if (th->syn) {
88903 /* We see SYN without ACK. It is attempt of
88904 * simultaneous connect with crossed SYNs.
88905 @@ -5572,6 +5573,7 @@ discard:
88906 goto discard;
88907 #endif
88908 }
88909 +#endif
88910 /* "fifth, if neither of the SYN or RST bits is set then
88911 * drop the segment and return."
88912 */
88913 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
88914 goto discard;
88915
88916 if (th->syn) {
88917 - if (th->fin)
88918 + if (th->fin || th->urg || th->psh)
88919 goto discard;
88920 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
88921 return 1;
88922 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
88923 index 7999fc5..c812f42 100644
88924 --- a/net/ipv4/tcp_ipv4.c
88925 +++ b/net/ipv4/tcp_ipv4.c
88926 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
88927 EXPORT_SYMBOL(sysctl_tcp_low_latency);
88928
88929
88930 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88931 +extern int grsec_enable_blackhole;
88932 +#endif
88933 +
88934 #ifdef CONFIG_TCP_MD5SIG
88935 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
88936 __be32 daddr, __be32 saddr, const struct tcphdr *th);
88937 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
88938 return 0;
88939
88940 reset:
88941 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88942 + if (!grsec_enable_blackhole)
88943 +#endif
88944 tcp_v4_send_reset(rsk, skb);
88945 discard:
88946 kfree_skb(skb);
88947 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
88948 TCP_SKB_CB(skb)->sacked = 0;
88949
88950 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88951 - if (!sk)
88952 + if (!sk) {
88953 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88954 + ret = 1;
88955 +#endif
88956 goto no_tcp_socket;
88957 -
88958 + }
88959 process:
88960 - if (sk->sk_state == TCP_TIME_WAIT)
88961 + if (sk->sk_state == TCP_TIME_WAIT) {
88962 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88963 + ret = 2;
88964 +#endif
88965 goto do_time_wait;
88966 + }
88967
88968 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
88969 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88970 @@ -2058,6 +2072,10 @@ csum_error:
88971 bad_packet:
88972 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88973 } else {
88974 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88975 + if (!grsec_enable_blackhole || (ret == 1 &&
88976 + (skb->dev->flags & IFF_LOOPBACK)))
88977 +#endif
88978 tcp_v4_send_reset(NULL, skb);
88979 }
88980
88981 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
88982 index 0f01788..d52a859 100644
88983 --- a/net/ipv4/tcp_minisocks.c
88984 +++ b/net/ipv4/tcp_minisocks.c
88985 @@ -27,6 +27,10 @@
88986 #include <net/inet_common.h>
88987 #include <net/xfrm.h>
88988
88989 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88990 +extern int grsec_enable_blackhole;
88991 +#endif
88992 +
88993 int sysctl_tcp_syncookies __read_mostly = 1;
88994 EXPORT_SYMBOL(sysctl_tcp_syncookies);
88995
88996 @@ -717,7 +721,10 @@ embryonic_reset:
88997 * avoid becoming vulnerable to outside attack aiming at
88998 * resetting legit local connections.
88999 */
89000 - req->rsk_ops->send_reset(sk, skb);
89001 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89002 + if (!grsec_enable_blackhole)
89003 +#endif
89004 + req->rsk_ops->send_reset(sk, skb);
89005 } else if (fastopen) { /* received a valid RST pkt */
89006 reqsk_fastopen_remove(sk, req, true);
89007 tcp_reset(sk);
89008 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
89009 index d4943f6..e7a74a5 100644
89010 --- a/net/ipv4/tcp_probe.c
89011 +++ b/net/ipv4/tcp_probe.c
89012 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
89013 if (cnt + width >= len)
89014 break;
89015
89016 - if (copy_to_user(buf + cnt, tbuf, width))
89017 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
89018 return -EFAULT;
89019 cnt += width;
89020 }
89021 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
89022 index 4b85e6f..22f9ac9 100644
89023 --- a/net/ipv4/tcp_timer.c
89024 +++ b/net/ipv4/tcp_timer.c
89025 @@ -22,6 +22,10 @@
89026 #include <linux/gfp.h>
89027 #include <net/tcp.h>
89028
89029 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89030 +extern int grsec_lastack_retries;
89031 +#endif
89032 +
89033 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
89034 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
89035 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
89036 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
89037 }
89038 }
89039
89040 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89041 + if ((sk->sk_state == TCP_LAST_ACK) &&
89042 + (grsec_lastack_retries > 0) &&
89043 + (grsec_lastack_retries < retry_until))
89044 + retry_until = grsec_lastack_retries;
89045 +#endif
89046 +
89047 if (retransmits_timed_out(sk, retry_until,
89048 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
89049 /* Has it gone just too far? */
89050 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
89051 index 93b731d..5a2dd92 100644
89052 --- a/net/ipv4/udp.c
89053 +++ b/net/ipv4/udp.c
89054 @@ -87,6 +87,7 @@
89055 #include <linux/types.h>
89056 #include <linux/fcntl.h>
89057 #include <linux/module.h>
89058 +#include <linux/security.h>
89059 #include <linux/socket.h>
89060 #include <linux/sockios.h>
89061 #include <linux/igmp.h>
89062 @@ -111,6 +112,10 @@
89063 #include <trace/events/skb.h>
89064 #include "udp_impl.h"
89065
89066 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89067 +extern int grsec_enable_blackhole;
89068 +#endif
89069 +
89070 struct udp_table udp_table __read_mostly;
89071 EXPORT_SYMBOL(udp_table);
89072
89073 @@ -594,6 +599,9 @@ found:
89074 return s;
89075 }
89076
89077 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
89078 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
89079 +
89080 /*
89081 * This routine is called by the ICMP module when it gets some
89082 * sort of error condition. If err < 0 then the socket should
89083 @@ -890,9 +898,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
89084 dport = usin->sin_port;
89085 if (dport == 0)
89086 return -EINVAL;
89087 +
89088 + err = gr_search_udp_sendmsg(sk, usin);
89089 + if (err)
89090 + return err;
89091 } else {
89092 if (sk->sk_state != TCP_ESTABLISHED)
89093 return -EDESTADDRREQ;
89094 +
89095 + err = gr_search_udp_sendmsg(sk, NULL);
89096 + if (err)
89097 + return err;
89098 +
89099 daddr = inet->inet_daddr;
89100 dport = inet->inet_dport;
89101 /* Open fast path for connected socket.
89102 @@ -1136,7 +1153,7 @@ static unsigned int first_packet_length(struct sock *sk)
89103 IS_UDPLITE(sk));
89104 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
89105 IS_UDPLITE(sk));
89106 - atomic_inc(&sk->sk_drops);
89107 + atomic_inc_unchecked(&sk->sk_drops);
89108 __skb_unlink(skb, rcvq);
89109 __skb_queue_tail(&list_kill, skb);
89110 }
89111 @@ -1222,6 +1239,10 @@ try_again:
89112 if (!skb)
89113 goto out;
89114
89115 + err = gr_search_udp_recvmsg(sk, skb);
89116 + if (err)
89117 + goto out_free;
89118 +
89119 ulen = skb->len - sizeof(struct udphdr);
89120 copied = len;
89121 if (copied > ulen)
89122 @@ -1255,7 +1276,7 @@ try_again:
89123 if (unlikely(err)) {
89124 trace_kfree_skb(skb, udp_recvmsg);
89125 if (!peeked) {
89126 - atomic_inc(&sk->sk_drops);
89127 + atomic_inc_unchecked(&sk->sk_drops);
89128 UDP_INC_STATS_USER(sock_net(sk),
89129 UDP_MIB_INERRORS, is_udplite);
89130 }
89131 @@ -1542,7 +1563,7 @@ csum_error:
89132 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
89133 drop:
89134 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
89135 - atomic_inc(&sk->sk_drops);
89136 + atomic_inc_unchecked(&sk->sk_drops);
89137 kfree_skb(skb);
89138 return -1;
89139 }
89140 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
89141 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
89142
89143 if (!skb1) {
89144 - atomic_inc(&sk->sk_drops);
89145 + atomic_inc_unchecked(&sk->sk_drops);
89146 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
89147 IS_UDPLITE(sk));
89148 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
89149 @@ -1730,6 +1751,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
89150 goto csum_error;
89151
89152 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
89153 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89154 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
89155 +#endif
89156 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
89157
89158 /*
89159 @@ -2160,7 +2184,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
89160 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
89161 0, sock_i_ino(sp),
89162 atomic_read(&sp->sk_refcnt), sp,
89163 - atomic_read(&sp->sk_drops), len);
89164 + atomic_read_unchecked(&sp->sk_drops), len);
89165 }
89166
89167 int udp4_seq_show(struct seq_file *seq, void *v)
89168 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
89169 index 9a459be..086b866 100644
89170 --- a/net/ipv4/xfrm4_policy.c
89171 +++ b/net/ipv4/xfrm4_policy.c
89172 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
89173
89174 static int __net_init xfrm4_net_init(struct net *net)
89175 {
89176 - struct ctl_table *table;
89177 + ctl_table_no_const *table = NULL;
89178 struct ctl_table_header *hdr;
89179
89180 - table = xfrm4_policy_table;
89181 if (!net_eq(net, &init_net)) {
89182 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
89183 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
89184 if (!table)
89185 goto err_alloc;
89186
89187 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
89188 - }
89189 -
89190 - hdr = register_net_sysctl(net, "net/ipv4", table);
89191 + hdr = register_net_sysctl(net, "net/ipv4", table);
89192 + } else
89193 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
89194 if (!hdr)
89195 goto err_reg;
89196
89197 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
89198 return 0;
89199
89200 err_reg:
89201 - if (!net_eq(net, &init_net))
89202 - kfree(table);
89203 + kfree(table);
89204 err_alloc:
89205 return -ENOMEM;
89206 }
89207 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
89208 index fb8c94c..fb18024 100644
89209 --- a/net/ipv6/addrconf.c
89210 +++ b/net/ipv6/addrconf.c
89211 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
89212 idx = 0;
89213 head = &net->dev_index_head[h];
89214 rcu_read_lock();
89215 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
89216 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
89217 net->dev_base_seq;
89218 hlist_for_each_entry_rcu(dev, head, index_hlist) {
89219 if (idx < s_idx)
89220 @@ -2380,7 +2380,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
89221 p.iph.ihl = 5;
89222 p.iph.protocol = IPPROTO_IPV6;
89223 p.iph.ttl = 64;
89224 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
89225 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
89226
89227 if (ops->ndo_do_ioctl) {
89228 mm_segment_t oldfs = get_fs();
89229 @@ -4002,7 +4002,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
89230 s_ip_idx = ip_idx = cb->args[2];
89231
89232 rcu_read_lock();
89233 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
89234 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
89235 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
89236 idx = 0;
89237 head = &net->dev_index_head[h];
89238 @@ -4587,7 +4587,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
89239 dst_free(&ifp->rt->dst);
89240 break;
89241 }
89242 - atomic_inc(&net->ipv6.dev_addr_genid);
89243 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
89244 }
89245
89246 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
89247 @@ -4607,7 +4607,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
89248 int *valp = ctl->data;
89249 int val = *valp;
89250 loff_t pos = *ppos;
89251 - ctl_table lctl;
89252 + ctl_table_no_const lctl;
89253 int ret;
89254
89255 /*
89256 @@ -4689,7 +4689,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
89257 int *valp = ctl->data;
89258 int val = *valp;
89259 loff_t pos = *ppos;
89260 - ctl_table lctl;
89261 + ctl_table_no_const lctl;
89262 int ret;
89263
89264 /*
89265 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
89266 index b4ff0a4..db9b764 100644
89267 --- a/net/ipv6/icmp.c
89268 +++ b/net/ipv6/icmp.c
89269 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
89270
89271 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
89272 {
89273 - struct ctl_table *table;
89274 + ctl_table_no_const *table;
89275
89276 table = kmemdup(ipv6_icmp_table_template,
89277 sizeof(ipv6_icmp_table_template),
89278 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
89279 index ecd6073..58162ae 100644
89280 --- a/net/ipv6/ip6_gre.c
89281 +++ b/net/ipv6/ip6_gre.c
89282 @@ -74,7 +74,7 @@ struct ip6gre_net {
89283 struct net_device *fb_tunnel_dev;
89284 };
89285
89286 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
89287 +static struct rtnl_link_ops ip6gre_link_ops;
89288 static int ip6gre_tunnel_init(struct net_device *dev);
89289 static void ip6gre_tunnel_setup(struct net_device *dev);
89290 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
89291 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
89292 }
89293
89294
89295 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
89296 +static struct inet6_protocol ip6gre_protocol = {
89297 .handler = ip6gre_rcv,
89298 .err_handler = ip6gre_err,
89299 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
89300 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
89301 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
89302 };
89303
89304 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
89305 +static struct rtnl_link_ops ip6gre_link_ops = {
89306 .kind = "ip6gre",
89307 .maxtype = IFLA_GRE_MAX,
89308 .policy = ip6gre_policy,
89309 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
89310 .fill_info = ip6gre_fill_info,
89311 };
89312
89313 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
89314 +static struct rtnl_link_ops ip6gre_tap_ops = {
89315 .kind = "ip6gretap",
89316 .maxtype = IFLA_GRE_MAX,
89317 .policy = ip6gre_policy,
89318 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
89319 index 1e55866..b398dab 100644
89320 --- a/net/ipv6/ip6_tunnel.c
89321 +++ b/net/ipv6/ip6_tunnel.c
89322 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
89323
89324 static int ip6_tnl_dev_init(struct net_device *dev);
89325 static void ip6_tnl_dev_setup(struct net_device *dev);
89326 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
89327 +static struct rtnl_link_ops ip6_link_ops;
89328
89329 static int ip6_tnl_net_id __read_mostly;
89330 struct ip6_tnl_net {
89331 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
89332 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
89333 };
89334
89335 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
89336 +static struct rtnl_link_ops ip6_link_ops = {
89337 .kind = "ip6tnl",
89338 .maxtype = IFLA_IPTUN_MAX,
89339 .policy = ip6_tnl_policy,
89340 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
89341 index d1e2e8e..51c19ae 100644
89342 --- a/net/ipv6/ipv6_sockglue.c
89343 +++ b/net/ipv6/ipv6_sockglue.c
89344 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
89345 if (sk->sk_type != SOCK_STREAM)
89346 return -ENOPROTOOPT;
89347
89348 - msg.msg_control = optval;
89349 + msg.msg_control = (void __force_kernel *)optval;
89350 msg.msg_controllen = len;
89351 msg.msg_flags = flags;
89352
89353 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
89354 index 44400c2..8e11f52 100644
89355 --- a/net/ipv6/netfilter/ip6_tables.c
89356 +++ b/net/ipv6/netfilter/ip6_tables.c
89357 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
89358 #endif
89359
89360 static int get_info(struct net *net, void __user *user,
89361 - const int *len, int compat)
89362 + int len, int compat)
89363 {
89364 char name[XT_TABLE_MAXNAMELEN];
89365 struct xt_table *t;
89366 int ret;
89367
89368 - if (*len != sizeof(struct ip6t_getinfo)) {
89369 - duprintf("length %u != %zu\n", *len,
89370 + if (len != sizeof(struct ip6t_getinfo)) {
89371 + duprintf("length %u != %zu\n", len,
89372 sizeof(struct ip6t_getinfo));
89373 return -EINVAL;
89374 }
89375 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
89376 info.size = private->size;
89377 strcpy(info.name, name);
89378
89379 - if (copy_to_user(user, &info, *len) != 0)
89380 + if (copy_to_user(user, &info, len) != 0)
89381 ret = -EFAULT;
89382 else
89383 ret = 0;
89384 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
89385
89386 switch (cmd) {
89387 case IP6T_SO_GET_INFO:
89388 - ret = get_info(sock_net(sk), user, len, 1);
89389 + ret = get_info(sock_net(sk), user, *len, 1);
89390 break;
89391 case IP6T_SO_GET_ENTRIES:
89392 ret = compat_get_entries(sock_net(sk), user, len);
89393 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
89394
89395 switch (cmd) {
89396 case IP6T_SO_GET_INFO:
89397 - ret = get_info(sock_net(sk), user, len, 0);
89398 + ret = get_info(sock_net(sk), user, *len, 0);
89399 break;
89400
89401 case IP6T_SO_GET_ENTRIES:
89402 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
89403 index dffdc1a..ccc6678 100644
89404 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
89405 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
89406 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
89407
89408 static int nf_ct_frag6_sysctl_register(struct net *net)
89409 {
89410 - struct ctl_table *table;
89411 + ctl_table_no_const *table = NULL;
89412 struct ctl_table_header *hdr;
89413
89414 - table = nf_ct_frag6_sysctl_table;
89415 if (!net_eq(net, &init_net)) {
89416 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
89417 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
89418 GFP_KERNEL);
89419 if (table == NULL)
89420 goto err_alloc;
89421 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
89422 table[0].data = &net->nf_frag.frags.timeout;
89423 table[1].data = &net->nf_frag.frags.low_thresh;
89424 table[2].data = &net->nf_frag.frags.high_thresh;
89425 - }
89426 -
89427 - hdr = register_net_sysctl(net, "net/netfilter", table);
89428 + hdr = register_net_sysctl(net, "net/netfilter", table);
89429 + } else
89430 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
89431 if (hdr == NULL)
89432 goto err_reg;
89433
89434 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
89435 return 0;
89436
89437 err_reg:
89438 - if (!net_eq(net, &init_net))
89439 - kfree(table);
89440 + kfree(table);
89441 err_alloc:
89442 return -ENOMEM;
89443 }
89444 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
89445 index eedff8c..6e13a47 100644
89446 --- a/net/ipv6/raw.c
89447 +++ b/net/ipv6/raw.c
89448 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
89449 {
89450 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
89451 skb_checksum_complete(skb)) {
89452 - atomic_inc(&sk->sk_drops);
89453 + atomic_inc_unchecked(&sk->sk_drops);
89454 kfree_skb(skb);
89455 return NET_RX_DROP;
89456 }
89457 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
89458 struct raw6_sock *rp = raw6_sk(sk);
89459
89460 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
89461 - atomic_inc(&sk->sk_drops);
89462 + atomic_inc_unchecked(&sk->sk_drops);
89463 kfree_skb(skb);
89464 return NET_RX_DROP;
89465 }
89466 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
89467
89468 if (inet->hdrincl) {
89469 if (skb_checksum_complete(skb)) {
89470 - atomic_inc(&sk->sk_drops);
89471 + atomic_inc_unchecked(&sk->sk_drops);
89472 kfree_skb(skb);
89473 return NET_RX_DROP;
89474 }
89475 @@ -602,7 +602,7 @@ out:
89476 return err;
89477 }
89478
89479 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
89480 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
89481 struct flowi6 *fl6, struct dst_entry **dstp,
89482 unsigned int flags)
89483 {
89484 @@ -914,12 +914,15 @@ do_confirm:
89485 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
89486 char __user *optval, int optlen)
89487 {
89488 + struct icmp6_filter filter;
89489 +
89490 switch (optname) {
89491 case ICMPV6_FILTER:
89492 if (optlen > sizeof(struct icmp6_filter))
89493 optlen = sizeof(struct icmp6_filter);
89494 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
89495 + if (copy_from_user(&filter, optval, optlen))
89496 return -EFAULT;
89497 + raw6_sk(sk)->filter = filter;
89498 return 0;
89499 default:
89500 return -ENOPROTOOPT;
89501 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
89502 char __user *optval, int __user *optlen)
89503 {
89504 int len;
89505 + struct icmp6_filter filter;
89506
89507 switch (optname) {
89508 case ICMPV6_FILTER:
89509 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
89510 len = sizeof(struct icmp6_filter);
89511 if (put_user(len, optlen))
89512 return -EFAULT;
89513 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
89514 + filter = raw6_sk(sk)->filter;
89515 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
89516 return -EFAULT;
89517 return 0;
89518 default:
89519 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
89520 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
89521 0,
89522 sock_i_ino(sp),
89523 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
89524 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
89525 }
89526
89527 static int raw6_seq_show(struct seq_file *seq, void *v)
89528 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
89529 index 790d9f4..68ae078 100644
89530 --- a/net/ipv6/reassembly.c
89531 +++ b/net/ipv6/reassembly.c
89532 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
89533
89534 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
89535 {
89536 - struct ctl_table *table;
89537 + ctl_table_no_const *table = NULL;
89538 struct ctl_table_header *hdr;
89539
89540 - table = ip6_frags_ns_ctl_table;
89541 if (!net_eq(net, &init_net)) {
89542 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
89543 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
89544 if (table == NULL)
89545 goto err_alloc;
89546
89547 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
89548 /* Don't export sysctls to unprivileged users */
89549 if (net->user_ns != &init_user_ns)
89550 table[0].procname = NULL;
89551 - }
89552 + hdr = register_net_sysctl(net, "net/ipv6", table);
89553 + } else
89554 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
89555
89556 - hdr = register_net_sysctl(net, "net/ipv6", table);
89557 if (hdr == NULL)
89558 goto err_reg;
89559
89560 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
89561 return 0;
89562
89563 err_reg:
89564 - if (!net_eq(net, &init_net))
89565 - kfree(table);
89566 + kfree(table);
89567 err_alloc:
89568 return -ENOMEM;
89569 }
89570 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
89571 index bacce6c..9d1741a 100644
89572 --- a/net/ipv6/route.c
89573 +++ b/net/ipv6/route.c
89574 @@ -2903,7 +2903,7 @@ ctl_table ipv6_route_table_template[] = {
89575
89576 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
89577 {
89578 - struct ctl_table *table;
89579 + ctl_table_no_const *table;
89580
89581 table = kmemdup(ipv6_route_table_template,
89582 sizeof(ipv6_route_table_template),
89583 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
89584 index 60df36d..f3ab7c8 100644
89585 --- a/net/ipv6/sit.c
89586 +++ b/net/ipv6/sit.c
89587 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
89588 static void ipip6_dev_free(struct net_device *dev);
89589 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
89590 __be32 *v4dst);
89591 -static struct rtnl_link_ops sit_link_ops __read_mostly;
89592 +static struct rtnl_link_ops sit_link_ops;
89593
89594 static int sit_net_id __read_mostly;
89595 struct sit_net {
89596 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
89597 #endif
89598 };
89599
89600 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
89601 +static struct rtnl_link_ops sit_link_ops = {
89602 .kind = "sit",
89603 .maxtype = IFLA_IPTUN_MAX,
89604 .policy = ipip6_policy,
89605 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
89606 index e85c48b..b8268d3 100644
89607 --- a/net/ipv6/sysctl_net_ipv6.c
89608 +++ b/net/ipv6/sysctl_net_ipv6.c
89609 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
89610
89611 static int __net_init ipv6_sysctl_net_init(struct net *net)
89612 {
89613 - struct ctl_table *ipv6_table;
89614 + ctl_table_no_const *ipv6_table;
89615 struct ctl_table *ipv6_route_table;
89616 struct ctl_table *ipv6_icmp_table;
89617 int err;
89618 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
89619 index 0a17ed9..2526cc3 100644
89620 --- a/net/ipv6/tcp_ipv6.c
89621 +++ b/net/ipv6/tcp_ipv6.c
89622 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
89623 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
89624 }
89625
89626 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89627 +extern int grsec_enable_blackhole;
89628 +#endif
89629 +
89630 static void tcp_v6_hash(struct sock *sk)
89631 {
89632 if (sk->sk_state != TCP_CLOSE) {
89633 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
89634 return 0;
89635
89636 reset:
89637 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89638 + if (!grsec_enable_blackhole)
89639 +#endif
89640 tcp_v6_send_reset(sk, skb);
89641 discard:
89642 if (opt_skb)
89643 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
89644 TCP_SKB_CB(skb)->sacked = 0;
89645
89646 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
89647 - if (!sk)
89648 + if (!sk) {
89649 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89650 + ret = 1;
89651 +#endif
89652 goto no_tcp_socket;
89653 + }
89654
89655 process:
89656 - if (sk->sk_state == TCP_TIME_WAIT)
89657 + if (sk->sk_state == TCP_TIME_WAIT) {
89658 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89659 + ret = 2;
89660 +#endif
89661 goto do_time_wait;
89662 + }
89663
89664 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
89665 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
89666 @@ -1536,6 +1551,10 @@ csum_error:
89667 bad_packet:
89668 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
89669 } else {
89670 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89671 + if (!grsec_enable_blackhole || (ret == 1 &&
89672 + (skb->dev->flags & IFF_LOOPBACK)))
89673 +#endif
89674 tcp_v6_send_reset(NULL, skb);
89675 }
89676
89677 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
89678 index e7b28f9..d09c290 100644
89679 --- a/net/ipv6/udp.c
89680 +++ b/net/ipv6/udp.c
89681 @@ -52,6 +52,10 @@
89682 #include <trace/events/skb.h>
89683 #include "udp_impl.h"
89684
89685 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89686 +extern int grsec_enable_blackhole;
89687 +#endif
89688 +
89689 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
89690 {
89691 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
89692 @@ -419,7 +423,7 @@ try_again:
89693 if (unlikely(err)) {
89694 trace_kfree_skb(skb, udpv6_recvmsg);
89695 if (!peeked) {
89696 - atomic_inc(&sk->sk_drops);
89697 + atomic_inc_unchecked(&sk->sk_drops);
89698 if (is_udp4)
89699 UDP_INC_STATS_USER(sock_net(sk),
89700 UDP_MIB_INERRORS,
89701 @@ -665,7 +669,7 @@ csum_error:
89702 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
89703 drop:
89704 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
89705 - atomic_inc(&sk->sk_drops);
89706 + atomic_inc_unchecked(&sk->sk_drops);
89707 kfree_skb(skb);
89708 return -1;
89709 }
89710 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
89711 if (likely(skb1 == NULL))
89712 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
89713 if (!skb1) {
89714 - atomic_inc(&sk->sk_drops);
89715 + atomic_inc_unchecked(&sk->sk_drops);
89716 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
89717 IS_UDPLITE(sk));
89718 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
89719 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
89720 goto csum_error;
89721
89722 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
89723 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
89724 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
89725 +#endif
89726 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
89727
89728 kfree_skb(skb);
89729 @@ -1392,7 +1399,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
89730 0,
89731 sock_i_ino(sp),
89732 atomic_read(&sp->sk_refcnt), sp,
89733 - atomic_read(&sp->sk_drops));
89734 + atomic_read_unchecked(&sp->sk_drops));
89735 }
89736
89737 int udp6_seq_show(struct seq_file *seq, void *v)
89738 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
89739 index 23ed03d..465a71d 100644
89740 --- a/net/ipv6/xfrm6_policy.c
89741 +++ b/net/ipv6/xfrm6_policy.c
89742 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
89743
89744 static int __net_init xfrm6_net_init(struct net *net)
89745 {
89746 - struct ctl_table *table;
89747 + ctl_table_no_const *table = NULL;
89748 struct ctl_table_header *hdr;
89749
89750 - table = xfrm6_policy_table;
89751 if (!net_eq(net, &init_net)) {
89752 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
89753 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
89754 if (!table)
89755 goto err_alloc;
89756
89757 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
89758 - }
89759 + hdr = register_net_sysctl(net, "net/ipv6", table);
89760 + } else
89761 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
89762
89763 - hdr = register_net_sysctl(net, "net/ipv6", table);
89764 if (!hdr)
89765 goto err_reg;
89766
89767 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
89768 return 0;
89769
89770 err_reg:
89771 - if (!net_eq(net, &init_net))
89772 - kfree(table);
89773 + kfree(table);
89774 err_alloc:
89775 return -ENOMEM;
89776 }
89777 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
89778 index 41ac7938..75e3bb1 100644
89779 --- a/net/irda/ircomm/ircomm_tty.c
89780 +++ b/net/irda/ircomm/ircomm_tty.c
89781 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89782 add_wait_queue(&port->open_wait, &wait);
89783
89784 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
89785 - __FILE__, __LINE__, tty->driver->name, port->count);
89786 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89787
89788 spin_lock_irqsave(&port->lock, flags);
89789 if (!tty_hung_up_p(filp))
89790 - port->count--;
89791 + atomic_dec(&port->count);
89792 port->blocked_open++;
89793 spin_unlock_irqrestore(&port->lock, flags);
89794
89795 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89796 }
89797
89798 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
89799 - __FILE__, __LINE__, tty->driver->name, port->count);
89800 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89801
89802 schedule();
89803 }
89804 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
89805
89806 spin_lock_irqsave(&port->lock, flags);
89807 if (!tty_hung_up_p(filp))
89808 - port->count++;
89809 + atomic_inc(&port->count);
89810 port->blocked_open--;
89811 spin_unlock_irqrestore(&port->lock, flags);
89812
89813 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
89814 - __FILE__, __LINE__, tty->driver->name, port->count);
89815 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
89816
89817 if (!retval)
89818 port->flags |= ASYNC_NORMAL_ACTIVE;
89819 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
89820
89821 /* ++ is not atomic, so this should be protected - Jean II */
89822 spin_lock_irqsave(&self->port.lock, flags);
89823 - self->port.count++;
89824 + atomic_inc(&self->port.count);
89825 spin_unlock_irqrestore(&self->port.lock, flags);
89826 tty_port_tty_set(&self->port, tty);
89827
89828 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
89829 - self->line, self->port.count);
89830 + self->line, atomic_read(&self->port.count));
89831
89832 /* Not really used by us, but lets do it anyway */
89833 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
89834 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
89835 tty_kref_put(port->tty);
89836 }
89837 port->tty = NULL;
89838 - port->count = 0;
89839 + atomic_set(&port->count, 0);
89840 spin_unlock_irqrestore(&port->lock, flags);
89841
89842 wake_up_interruptible(&port->open_wait);
89843 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
89844 seq_putc(m, '\n');
89845
89846 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
89847 - seq_printf(m, "Open count: %d\n", self->port.count);
89848 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
89849 seq_printf(m, "Max data size: %d\n", self->max_data_size);
89850 seq_printf(m, "Max header size: %d\n", self->max_header_size);
89851
89852 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
89853 index ae69165..c8b82d8 100644
89854 --- a/net/iucv/af_iucv.c
89855 +++ b/net/iucv/af_iucv.c
89856 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
89857
89858 write_lock_bh(&iucv_sk_list.lock);
89859
89860 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
89861 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
89862 while (__iucv_get_sock_by_name(name)) {
89863 sprintf(name, "%08x",
89864 - atomic_inc_return(&iucv_sk_list.autobind_name));
89865 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
89866 }
89867
89868 write_unlock_bh(&iucv_sk_list.lock);
89869 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
89870 index 4fe76ff..426a904 100644
89871 --- a/net/iucv/iucv.c
89872 +++ b/net/iucv/iucv.c
89873 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
89874 return NOTIFY_OK;
89875 }
89876
89877 -static struct notifier_block __refdata iucv_cpu_notifier = {
89878 +static struct notifier_block iucv_cpu_notifier = {
89879 .notifier_call = iucv_cpu_notify,
89880 };
89881
89882 diff --git a/net/key/af_key.c b/net/key/af_key.c
89883 index 9da8620..97070ad 100644
89884 --- a/net/key/af_key.c
89885 +++ b/net/key/af_key.c
89886 @@ -3047,10 +3047,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
89887 static u32 get_acqseq(void)
89888 {
89889 u32 res;
89890 - static atomic_t acqseq;
89891 + static atomic_unchecked_t acqseq;
89892
89893 do {
89894 - res = atomic_inc_return(&acqseq);
89895 + res = atomic_inc_return_unchecked(&acqseq);
89896 } while (!res);
89897 return res;
89898 }
89899 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
89900 index 4fdb306e..920086a 100644
89901 --- a/net/mac80211/cfg.c
89902 +++ b/net/mac80211/cfg.c
89903 @@ -804,7 +804,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
89904 ret = ieee80211_vif_use_channel(sdata, chandef,
89905 IEEE80211_CHANCTX_EXCLUSIVE);
89906 }
89907 - } else if (local->open_count == local->monitors) {
89908 + } else if (local_read(&local->open_count) == local->monitors) {
89909 local->_oper_chandef = *chandef;
89910 ieee80211_hw_config(local, 0);
89911 }
89912 @@ -2920,7 +2920,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
89913 else
89914 local->probe_req_reg--;
89915
89916 - if (!local->open_count)
89917 + if (!local_read(&local->open_count))
89918 break;
89919
89920 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
89921 @@ -3383,8 +3383,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
89922 if (chanctx_conf) {
89923 *chandef = chanctx_conf->def;
89924 ret = 0;
89925 - } else if (local->open_count > 0 &&
89926 - local->open_count == local->monitors &&
89927 + } else if (local_read(&local->open_count) > 0 &&
89928 + local_read(&local->open_count) == local->monitors &&
89929 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
89930 if (local->use_chanctx)
89931 *chandef = local->monitor_chandef;
89932 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
89933 index 9ca8e32..48e4a9b 100644
89934 --- a/net/mac80211/ieee80211_i.h
89935 +++ b/net/mac80211/ieee80211_i.h
89936 @@ -28,6 +28,7 @@
89937 #include <net/ieee80211_radiotap.h>
89938 #include <net/cfg80211.h>
89939 #include <net/mac80211.h>
89940 +#include <asm/local.h>
89941 #include "key.h"
89942 #include "sta_info.h"
89943 #include "debug.h"
89944 @@ -891,7 +892,7 @@ struct ieee80211_local {
89945 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
89946 spinlock_t queue_stop_reason_lock;
89947
89948 - int open_count;
89949 + local_t open_count;
89950 int monitors, cooked_mntrs;
89951 /* number of interfaces with corresponding FIF_ flags */
89952 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
89953 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
89954 index 514e90f..56f22bf 100644
89955 --- a/net/mac80211/iface.c
89956 +++ b/net/mac80211/iface.c
89957 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89958 break;
89959 }
89960
89961 - if (local->open_count == 0) {
89962 + if (local_read(&local->open_count) == 0) {
89963 res = drv_start(local);
89964 if (res)
89965 goto err_del_bss;
89966 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89967 break;
89968 }
89969
89970 - if (local->monitors == 0 && local->open_count == 0) {
89971 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
89972 res = ieee80211_add_virtual_monitor(local);
89973 if (res)
89974 goto err_stop;
89975 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89976 atomic_inc(&local->iff_promiscs);
89977
89978 if (coming_up)
89979 - local->open_count++;
89980 + local_inc(&local->open_count);
89981
89982 if (hw_reconf_flags)
89983 ieee80211_hw_config(local, hw_reconf_flags);
89984 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89985 err_del_interface:
89986 drv_remove_interface(local, sdata);
89987 err_stop:
89988 - if (!local->open_count)
89989 + if (!local_read(&local->open_count))
89990 drv_stop(local);
89991 err_del_bss:
89992 sdata->bss = NULL;
89993 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89994 }
89995
89996 if (going_down)
89997 - local->open_count--;
89998 + local_dec(&local->open_count);
89999
90000 switch (sdata->vif.type) {
90001 case NL80211_IFTYPE_AP_VLAN:
90002 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
90003 }
90004 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
90005
90006 - if (local->open_count == 0)
90007 + if (local_read(&local->open_count) == 0)
90008 ieee80211_clear_tx_pending(local);
90009
90010 /*
90011 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
90012
90013 ieee80211_recalc_ps(local, -1);
90014
90015 - if (local->open_count == 0) {
90016 + if (local_read(&local->open_count) == 0) {
90017 ieee80211_stop_device(local);
90018
90019 /* no reconfiguring after stop! */
90020 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
90021 ieee80211_configure_filter(local);
90022 ieee80211_hw_config(local, hw_reconf_flags);
90023
90024 - if (local->monitors == local->open_count)
90025 + if (local->monitors == local_read(&local->open_count))
90026 ieee80211_add_virtual_monitor(local);
90027 }
90028
90029 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
90030 index 8a7bfc4..4407cd0 100644
90031 --- a/net/mac80211/main.c
90032 +++ b/net/mac80211/main.c
90033 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
90034 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
90035 IEEE80211_CONF_CHANGE_POWER);
90036
90037 - if (changed && local->open_count) {
90038 + if (changed && local_read(&local->open_count)) {
90039 ret = drv_config(local, changed);
90040 /*
90041 * Goal:
90042 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
90043 index 7fc5d0d..07ea536 100644
90044 --- a/net/mac80211/pm.c
90045 +++ b/net/mac80211/pm.c
90046 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
90047 struct ieee80211_sub_if_data *sdata;
90048 struct sta_info *sta;
90049
90050 - if (!local->open_count)
90051 + if (!local_read(&local->open_count))
90052 goto suspend;
90053
90054 ieee80211_scan_cancel(local);
90055 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
90056 cancel_work_sync(&local->dynamic_ps_enable_work);
90057 del_timer_sync(&local->dynamic_ps_timer);
90058
90059 - local->wowlan = wowlan && local->open_count;
90060 + local->wowlan = wowlan && local_read(&local->open_count);
90061 if (local->wowlan) {
90062 int err = drv_suspend(local, wowlan);
90063 if (err < 0) {
90064 @@ -113,7 +113,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
90065 WARN_ON(!list_empty(&local->chanctx_list));
90066
90067 /* stop hardware - this must stop RX */
90068 - if (local->open_count)
90069 + if (local_read(&local->open_count))
90070 ieee80211_stop_device(local);
90071
90072 suspend:
90073 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
90074 index a02bef3..f2f38dd 100644
90075 --- a/net/mac80211/rate.c
90076 +++ b/net/mac80211/rate.c
90077 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
90078
90079 ASSERT_RTNL();
90080
90081 - if (local->open_count)
90082 + if (local_read(&local->open_count))
90083 return -EBUSY;
90084
90085 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
90086 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
90087 index c97a065..ff61928 100644
90088 --- a/net/mac80211/rc80211_pid_debugfs.c
90089 +++ b/net/mac80211/rc80211_pid_debugfs.c
90090 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
90091
90092 spin_unlock_irqrestore(&events->lock, status);
90093
90094 - if (copy_to_user(buf, pb, p))
90095 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
90096 return -EFAULT;
90097
90098 return p;
90099 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
90100 index 72e6292..e6319eb 100644
90101 --- a/net/mac80211/util.c
90102 +++ b/net/mac80211/util.c
90103 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
90104 }
90105 #endif
90106 /* everything else happens only if HW was up & running */
90107 - if (!local->open_count)
90108 + if (!local_read(&local->open_count))
90109 goto wake_up;
90110
90111 /*
90112 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
90113 local->in_reconfig = false;
90114 barrier();
90115
90116 - if (local->monitors == local->open_count && local->monitors > 0)
90117 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
90118 ieee80211_add_virtual_monitor(local);
90119
90120 /*
90121 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
90122 index 56d22ca..87c778f 100644
90123 --- a/net/netfilter/Kconfig
90124 +++ b/net/netfilter/Kconfig
90125 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
90126
90127 To compile it as a module, choose M here. If unsure, say N.
90128
90129 +config NETFILTER_XT_MATCH_GRADM
90130 + tristate '"gradm" match support'
90131 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
90132 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
90133 + ---help---
90134 + The gradm match allows to match on grsecurity RBAC being enabled.
90135 + It is useful when iptables rules are applied early on bootup to
90136 + prevent connections to the machine (except from a trusted host)
90137 + while the RBAC system is disabled.
90138 +
90139 config NETFILTER_XT_MATCH_HASHLIMIT
90140 tristate '"hashlimit" match support'
90141 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
90142 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
90143 index a1abf87..dbcb7ee 100644
90144 --- a/net/netfilter/Makefile
90145 +++ b/net/netfilter/Makefile
90146 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
90147 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
90148 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
90149 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
90150 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
90151 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
90152 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
90153 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
90154 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
90155 index f771390..145b765 100644
90156 --- a/net/netfilter/ipset/ip_set_core.c
90157 +++ b/net/netfilter/ipset/ip_set_core.c
90158 @@ -1820,7 +1820,7 @@ done:
90159 return ret;
90160 }
90161
90162 -static struct nf_sockopt_ops so_set __read_mostly = {
90163 +static struct nf_sockopt_ops so_set = {
90164 .pf = PF_INET,
90165 .get_optmin = SO_IP_SET,
90166 .get_optmax = SO_IP_SET + 1,
90167 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
90168 index a083bda..da661c3 100644
90169 --- a/net/netfilter/ipvs/ip_vs_conn.c
90170 +++ b/net/netfilter/ipvs/ip_vs_conn.c
90171 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
90172 /* Increase the refcnt counter of the dest */
90173 ip_vs_dest_hold(dest);
90174
90175 - conn_flags = atomic_read(&dest->conn_flags);
90176 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
90177 if (cp->protocol != IPPROTO_UDP)
90178 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
90179 flags = cp->flags;
90180 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
90181
90182 cp->control = NULL;
90183 atomic_set(&cp->n_control, 0);
90184 - atomic_set(&cp->in_pkts, 0);
90185 + atomic_set_unchecked(&cp->in_pkts, 0);
90186
90187 cp->packet_xmit = NULL;
90188 cp->app = NULL;
90189 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
90190
90191 /* Don't drop the entry if its number of incoming packets is not
90192 located in [0, 8] */
90193 - i = atomic_read(&cp->in_pkts);
90194 + i = atomic_read_unchecked(&cp->in_pkts);
90195 if (i > 8 || i < 0) return 0;
90196
90197 if (!todrop_rate[i]) return 0;
90198 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
90199 index 23b8eb5..48a8959 100644
90200 --- a/net/netfilter/ipvs/ip_vs_core.c
90201 +++ b/net/netfilter/ipvs/ip_vs_core.c
90202 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
90203 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
90204 /* do not touch skb anymore */
90205
90206 - atomic_inc(&cp->in_pkts);
90207 + atomic_inc_unchecked(&cp->in_pkts);
90208 ip_vs_conn_put(cp);
90209 return ret;
90210 }
90211 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
90212 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
90213 pkts = sysctl_sync_threshold(ipvs);
90214 else
90215 - pkts = atomic_add_return(1, &cp->in_pkts);
90216 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
90217
90218 if (ipvs->sync_state & IP_VS_STATE_MASTER)
90219 ip_vs_sync_conn(net, cp, pkts);
90220 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
90221 index 9e6c2a0..28552e2 100644
90222 --- a/net/netfilter/ipvs/ip_vs_ctl.c
90223 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
90224 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
90225 */
90226 ip_vs_rs_hash(ipvs, dest);
90227 }
90228 - atomic_set(&dest->conn_flags, conn_flags);
90229 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
90230
90231 /* bind the service */
90232 if (!dest->svc) {
90233 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
90234 * align with netns init in ip_vs_control_net_init()
90235 */
90236
90237 -static struct ctl_table vs_vars[] = {
90238 +static ctl_table_no_const vs_vars[] __read_only = {
90239 {
90240 .procname = "amemthresh",
90241 .maxlen = sizeof(int),
90242 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
90243 " %-7s %-6d %-10d %-10d\n",
90244 &dest->addr.in6,
90245 ntohs(dest->port),
90246 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
90247 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
90248 atomic_read(&dest->weight),
90249 atomic_read(&dest->activeconns),
90250 atomic_read(&dest->inactconns));
90251 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
90252 "%-7s %-6d %-10d %-10d\n",
90253 ntohl(dest->addr.ip),
90254 ntohs(dest->port),
90255 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
90256 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
90257 atomic_read(&dest->weight),
90258 atomic_read(&dest->activeconns),
90259 atomic_read(&dest->inactconns));
90260 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
90261
90262 entry.addr = dest->addr.ip;
90263 entry.port = dest->port;
90264 - entry.conn_flags = atomic_read(&dest->conn_flags);
90265 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
90266 entry.weight = atomic_read(&dest->weight);
90267 entry.u_threshold = dest->u_threshold;
90268 entry.l_threshold = dest->l_threshold;
90269 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
90270 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
90271 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
90272 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
90273 - (atomic_read(&dest->conn_flags) &
90274 + (atomic_read_unchecked(&dest->conn_flags) &
90275 IP_VS_CONN_F_FWD_MASK)) ||
90276 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
90277 atomic_read(&dest->weight)) ||
90278 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
90279 {
90280 int idx;
90281 struct netns_ipvs *ipvs = net_ipvs(net);
90282 - struct ctl_table *tbl;
90283 + ctl_table_no_const *tbl;
90284
90285 atomic_set(&ipvs->dropentry, 0);
90286 spin_lock_init(&ipvs->dropentry_lock);
90287 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
90288 index 5ea26bd..c9bc65f 100644
90289 --- a/net/netfilter/ipvs/ip_vs_lblc.c
90290 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
90291 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
90292 * IPVS LBLC sysctl table
90293 */
90294 #ifdef CONFIG_SYSCTL
90295 -static ctl_table vs_vars_table[] = {
90296 +static ctl_table_no_const vs_vars_table[] __read_only = {
90297 {
90298 .procname = "lblc_expiration",
90299 .data = NULL,
90300 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
90301 index 50123c2..067c773 100644
90302 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
90303 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
90304 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
90305 * IPVS LBLCR sysctl table
90306 */
90307
90308 -static ctl_table vs_vars_table[] = {
90309 +static ctl_table_no_const vs_vars_table[] __read_only = {
90310 {
90311 .procname = "lblcr_expiration",
90312 .data = NULL,
90313 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
90314 index f6046d9..4f10cfd 100644
90315 --- a/net/netfilter/ipvs/ip_vs_sync.c
90316 +++ b/net/netfilter/ipvs/ip_vs_sync.c
90317 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
90318 cp = cp->control;
90319 if (cp) {
90320 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
90321 - pkts = atomic_add_return(1, &cp->in_pkts);
90322 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
90323 else
90324 pkts = sysctl_sync_threshold(ipvs);
90325 ip_vs_sync_conn(net, cp->control, pkts);
90326 @@ -758,7 +758,7 @@ control:
90327 if (!cp)
90328 return;
90329 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
90330 - pkts = atomic_add_return(1, &cp->in_pkts);
90331 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
90332 else
90333 pkts = sysctl_sync_threshold(ipvs);
90334 goto sloop;
90335 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
90336
90337 if (opt)
90338 memcpy(&cp->in_seq, opt, sizeof(*opt));
90339 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
90340 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
90341 cp->state = state;
90342 cp->old_state = cp->state;
90343 /*
90344 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
90345 index b75ff64..0c51bbe 100644
90346 --- a/net/netfilter/ipvs/ip_vs_xmit.c
90347 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
90348 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
90349 else
90350 rc = NF_ACCEPT;
90351 /* do not touch skb anymore */
90352 - atomic_inc(&cp->in_pkts);
90353 + atomic_inc_unchecked(&cp->in_pkts);
90354 goto out;
90355 }
90356
90357 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
90358 else
90359 rc = NF_ACCEPT;
90360 /* do not touch skb anymore */
90361 - atomic_inc(&cp->in_pkts);
90362 + atomic_inc_unchecked(&cp->in_pkts);
90363 goto out;
90364 }
90365
90366 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
90367 index 2d3030a..7ba1c0a 100644
90368 --- a/net/netfilter/nf_conntrack_acct.c
90369 +++ b/net/netfilter/nf_conntrack_acct.c
90370 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
90371 #ifdef CONFIG_SYSCTL
90372 static int nf_conntrack_acct_init_sysctl(struct net *net)
90373 {
90374 - struct ctl_table *table;
90375 + ctl_table_no_const *table;
90376
90377 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
90378 GFP_KERNEL);
90379 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
90380 index 0283bae..5febcb0 100644
90381 --- a/net/netfilter/nf_conntrack_core.c
90382 +++ b/net/netfilter/nf_conntrack_core.c
90383 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
90384 #define DYING_NULLS_VAL ((1<<30)+1)
90385 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
90386
90387 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90388 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
90389 +#endif
90390 +
90391 int nf_conntrack_init_net(struct net *net)
90392 {
90393 int ret;
90394 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
90395 goto err_stat;
90396 }
90397
90398 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90399 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
90400 +#else
90401 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
90402 +#endif
90403 if (!net->ct.slabname) {
90404 ret = -ENOMEM;
90405 goto err_slabname;
90406 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
90407 index 1df1761..ce8b88a 100644
90408 --- a/net/netfilter/nf_conntrack_ecache.c
90409 +++ b/net/netfilter/nf_conntrack_ecache.c
90410 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
90411 #ifdef CONFIG_SYSCTL
90412 static int nf_conntrack_event_init_sysctl(struct net *net)
90413 {
90414 - struct ctl_table *table;
90415 + ctl_table_no_const *table;
90416
90417 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
90418 GFP_KERNEL);
90419 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
90420 index 974a2a4..52cc6ff 100644
90421 --- a/net/netfilter/nf_conntrack_helper.c
90422 +++ b/net/netfilter/nf_conntrack_helper.c
90423 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
90424
90425 static int nf_conntrack_helper_init_sysctl(struct net *net)
90426 {
90427 - struct ctl_table *table;
90428 + ctl_table_no_const *table;
90429
90430 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
90431 GFP_KERNEL);
90432 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
90433 index 0ab9636..cea3c6a 100644
90434 --- a/net/netfilter/nf_conntrack_proto.c
90435 +++ b/net/netfilter/nf_conntrack_proto.c
90436 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
90437
90438 static void
90439 nf_ct_unregister_sysctl(struct ctl_table_header **header,
90440 - struct ctl_table **table,
90441 + ctl_table_no_const **table,
90442 unsigned int users)
90443 {
90444 if (users > 0)
90445 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
90446 index a99b6c3..3841268 100644
90447 --- a/net/netfilter/nf_conntrack_proto_dccp.c
90448 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
90449 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
90450 out_invalid:
90451 if (LOG_INVALID(net, IPPROTO_DCCP))
90452 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
90453 - NULL, msg);
90454 + NULL, "%s", msg);
90455 return false;
90456 }
90457
90458 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
90459
90460 out_invalid:
90461 if (LOG_INVALID(net, IPPROTO_DCCP))
90462 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
90463 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
90464 return -NF_ACCEPT;
90465 }
90466
90467 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
90468 index bd700b4..4a3dc61 100644
90469 --- a/net/netfilter/nf_conntrack_standalone.c
90470 +++ b/net/netfilter/nf_conntrack_standalone.c
90471 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
90472
90473 static int nf_conntrack_standalone_init_sysctl(struct net *net)
90474 {
90475 - struct ctl_table *table;
90476 + ctl_table_no_const *table;
90477
90478 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
90479 GFP_KERNEL);
90480 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
90481 index 902fb0a..87f7fdb 100644
90482 --- a/net/netfilter/nf_conntrack_timestamp.c
90483 +++ b/net/netfilter/nf_conntrack_timestamp.c
90484 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
90485 #ifdef CONFIG_SYSCTL
90486 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
90487 {
90488 - struct ctl_table *table;
90489 + ctl_table_no_const *table;
90490
90491 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
90492 GFP_KERNEL);
90493 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
90494 index 3b18dd1..f79e0ca 100644
90495 --- a/net/netfilter/nf_log.c
90496 +++ b/net/netfilter/nf_log.c
90497 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
90498
90499 #ifdef CONFIG_SYSCTL
90500 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
90501 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
90502 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
90503
90504 static int nf_log_proc_dostring(ctl_table *table, int write,
90505 void __user *buffer, size_t *lenp, loff_t *ppos)
90506 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
90507 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
90508 mutex_unlock(&nf_log_mutex);
90509 } else {
90510 + ctl_table_no_const nf_log_table = *table;
90511 +
90512 mutex_lock(&nf_log_mutex);
90513 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
90514 lockdep_is_held(&nf_log_mutex));
90515 if (!logger)
90516 - table->data = "NONE";
90517 + nf_log_table.data = "NONE";
90518 else
90519 - table->data = logger->name;
90520 - r = proc_dostring(table, write, buffer, lenp, ppos);
90521 + nf_log_table.data = logger->name;
90522 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
90523 mutex_unlock(&nf_log_mutex);
90524 }
90525
90526 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
90527 index f042ae5..30ea486 100644
90528 --- a/net/netfilter/nf_sockopt.c
90529 +++ b/net/netfilter/nf_sockopt.c
90530 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
90531 }
90532 }
90533
90534 - list_add(&reg->list, &nf_sockopts);
90535 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
90536 out:
90537 mutex_unlock(&nf_sockopt_mutex);
90538 return ret;
90539 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
90540 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
90541 {
90542 mutex_lock(&nf_sockopt_mutex);
90543 - list_del(&reg->list);
90544 + pax_list_del((struct list_head *)&reg->list);
90545 mutex_unlock(&nf_sockopt_mutex);
90546 }
90547 EXPORT_SYMBOL(nf_unregister_sockopt);
90548 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
90549 index 962e979..d4ae2e9 100644
90550 --- a/net/netfilter/nfnetlink_log.c
90551 +++ b/net/netfilter/nfnetlink_log.c
90552 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
90553 struct nfnl_log_net {
90554 spinlock_t instances_lock;
90555 struct hlist_head instance_table[INSTANCE_BUCKETS];
90556 - atomic_t global_seq;
90557 + atomic_unchecked_t global_seq;
90558 };
90559
90560 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
90561 @@ -559,7 +559,7 @@ __build_packet_message(struct nfnl_log_net *log,
90562 /* global sequence number */
90563 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
90564 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
90565 - htonl(atomic_inc_return(&log->global_seq))))
90566 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
90567 goto nla_put_failure;
90568
90569 if (data_len) {
90570 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
90571 new file mode 100644
90572 index 0000000..c566332
90573 --- /dev/null
90574 +++ b/net/netfilter/xt_gradm.c
90575 @@ -0,0 +1,51 @@
90576 +/*
90577 + * gradm match for netfilter
90578 + * Copyright © Zbigniew Krzystolik, 2010
90579 + *
90580 + * This program is free software; you can redistribute it and/or modify
90581 + * it under the terms of the GNU General Public License; either version
90582 + * 2 or 3 as published by the Free Software Foundation.
90583 + */
90584 +#include <linux/module.h>
90585 +#include <linux/moduleparam.h>
90586 +#include <linux/skbuff.h>
90587 +#include <linux/netfilter/x_tables.h>
90588 +#include <linux/grsecurity.h>
90589 +#include <linux/netfilter/xt_gradm.h>
90590 +
90591 +static bool
90592 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
90593 +{
90594 + const struct xt_gradm_mtinfo *info = par->matchinfo;
90595 + bool retval = false;
90596 + if (gr_acl_is_enabled())
90597 + retval = true;
90598 + return retval ^ info->invflags;
90599 +}
90600 +
90601 +static struct xt_match gradm_mt_reg __read_mostly = {
90602 + .name = "gradm",
90603 + .revision = 0,
90604 + .family = NFPROTO_UNSPEC,
90605 + .match = gradm_mt,
90606 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
90607 + .me = THIS_MODULE,
90608 +};
90609 +
90610 +static int __init gradm_mt_init(void)
90611 +{
90612 + return xt_register_match(&gradm_mt_reg);
90613 +}
90614 +
90615 +static void __exit gradm_mt_exit(void)
90616 +{
90617 + xt_unregister_match(&gradm_mt_reg);
90618 +}
90619 +
90620 +module_init(gradm_mt_init);
90621 +module_exit(gradm_mt_exit);
90622 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
90623 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
90624 +MODULE_LICENSE("GPL");
90625 +MODULE_ALIAS("ipt_gradm");
90626 +MODULE_ALIAS("ip6t_gradm");
90627 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
90628 index 4fe4fb4..87a89e5 100644
90629 --- a/net/netfilter/xt_statistic.c
90630 +++ b/net/netfilter/xt_statistic.c
90631 @@ -19,7 +19,7 @@
90632 #include <linux/module.h>
90633
90634 struct xt_statistic_priv {
90635 - atomic_t count;
90636 + atomic_unchecked_t count;
90637 } ____cacheline_aligned_in_smp;
90638
90639 MODULE_LICENSE("GPL");
90640 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
90641 break;
90642 case XT_STATISTIC_MODE_NTH:
90643 do {
90644 - oval = atomic_read(&info->master->count);
90645 + oval = atomic_read_unchecked(&info->master->count);
90646 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
90647 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
90648 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
90649 if (nval == 0)
90650 ret = !ret;
90651 break;
90652 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
90653 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
90654 if (info->master == NULL)
90655 return -ENOMEM;
90656 - atomic_set(&info->master->count, info->u.nth.count);
90657 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
90658
90659 return 0;
90660 }
90661 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
90662 index 57ee84d..8b99cf5 100644
90663 --- a/net/netlink/af_netlink.c
90664 +++ b/net/netlink/af_netlink.c
90665 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
90666 sk->sk_error_report(sk);
90667 }
90668 }
90669 - atomic_inc(&sk->sk_drops);
90670 + atomic_inc_unchecked(&sk->sk_drops);
90671 }
90672
90673 static void netlink_rcv_wake(struct sock *sk)
90674 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
90675 sk_wmem_alloc_get(s),
90676 nlk->cb,
90677 atomic_read(&s->sk_refcnt),
90678 - atomic_read(&s->sk_drops),
90679 + atomic_read_unchecked(&s->sk_drops),
90680 sock_i_ino(s)
90681 );
90682
90683 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
90684 index 2fd6dbe..1032269 100644
90685 --- a/net/netlink/genetlink.c
90686 +++ b/net/netlink/genetlink.c
90687 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
90688 goto errout;
90689 }
90690
90691 + pax_open_kernel();
90692 if (ops->dumpit)
90693 - ops->flags |= GENL_CMD_CAP_DUMP;
90694 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
90695 if (ops->doit)
90696 - ops->flags |= GENL_CMD_CAP_DO;
90697 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
90698 if (ops->policy)
90699 - ops->flags |= GENL_CMD_CAP_HASPOL;
90700 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
90701 + pax_close_kernel();
90702
90703 genl_lock_all();
90704 - list_add_tail(&ops->ops_list, &family->ops_list);
90705 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
90706 genl_unlock_all();
90707
90708 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
90709 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
90710 err = 0;
90711 errout:
90712 return err;
90713 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
90714 genl_lock_all();
90715 list_for_each_entry(rc, &family->ops_list, ops_list) {
90716 if (rc == ops) {
90717 - list_del(&ops->ops_list);
90718 + pax_list_del((struct list_head *)&ops->ops_list);
90719 genl_unlock_all();
90720 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
90721 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
90722 return 0;
90723 }
90724 }
90725 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
90726 index ec0c80f..41e1830 100644
90727 --- a/net/netrom/af_netrom.c
90728 +++ b/net/netrom/af_netrom.c
90729 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
90730 *uaddr_len = sizeof(struct full_sockaddr_ax25);
90731 } else {
90732 sax->fsa_ax25.sax25_family = AF_NETROM;
90733 - sax->fsa_ax25.sax25_ndigis = 0;
90734 sax->fsa_ax25.sax25_call = nr->source_addr;
90735 *uaddr_len = sizeof(struct sockaddr_ax25);
90736 }
90737 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
90738 index 20a1bd0..bb8f1c1 100644
90739 --- a/net/packet/af_packet.c
90740 +++ b/net/packet/af_packet.c
90741 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
90742
90743 spin_lock(&sk->sk_receive_queue.lock);
90744 po->stats.stats1.tp_packets++;
90745 - skb->dropcount = atomic_read(&sk->sk_drops);
90746 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
90747 __skb_queue_tail(&sk->sk_receive_queue, skb);
90748 spin_unlock(&sk->sk_receive_queue.lock);
90749 sk->sk_data_ready(sk, skb->len);
90750 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
90751 drop_n_acct:
90752 spin_lock(&sk->sk_receive_queue.lock);
90753 po->stats.stats1.tp_drops++;
90754 - atomic_inc(&sk->sk_drops);
90755 + atomic_inc_unchecked(&sk->sk_drops);
90756 spin_unlock(&sk->sk_receive_queue.lock);
90757
90758 drop_n_restore:
90759 @@ -2640,6 +2640,7 @@ out:
90760
90761 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
90762 {
90763 + struct sock_extended_err ee;
90764 struct sock_exterr_skb *serr;
90765 struct sk_buff *skb, *skb2;
90766 int copied, err;
90767 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
90768 sock_recv_timestamp(msg, sk, skb);
90769
90770 serr = SKB_EXT_ERR(skb);
90771 + ee = serr->ee;
90772 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
90773 - sizeof(serr->ee), &serr->ee);
90774 + sizeof ee, &ee);
90775
90776 msg->msg_flags |= MSG_ERRQUEUE;
90777 err = copied;
90778 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
90779 case PACKET_HDRLEN:
90780 if (len > sizeof(int))
90781 len = sizeof(int);
90782 - if (copy_from_user(&val, optval, len))
90783 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
90784 return -EFAULT;
90785 switch (val) {
90786 case TPACKET_V1:
90787 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
90788 len = lv;
90789 if (put_user(len, optlen))
90790 return -EFAULT;
90791 - if (copy_to_user(optval, data, len))
90792 + if (len > sizeof(st) || copy_to_user(optval, data, len))
90793 return -EFAULT;
90794 return 0;
90795 }
90796 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
90797 index 5a940db..d6a502d 100644
90798 --- a/net/phonet/af_phonet.c
90799 +++ b/net/phonet/af_phonet.c
90800 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
90801 {
90802 int err = 0;
90803
90804 - if (protocol >= PHONET_NPROTO)
90805 + if (protocol < 0 || protocol >= PHONET_NPROTO)
90806 return -EINVAL;
90807
90808 err = proto_register(pp->prot, 1);
90809 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
90810 index e774117..900b8b7 100644
90811 --- a/net/phonet/pep.c
90812 +++ b/net/phonet/pep.c
90813 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
90814
90815 case PNS_PEP_CTRL_REQ:
90816 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
90817 - atomic_inc(&sk->sk_drops);
90818 + atomic_inc_unchecked(&sk->sk_drops);
90819 break;
90820 }
90821 __skb_pull(skb, 4);
90822 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
90823 }
90824
90825 if (pn->rx_credits == 0) {
90826 - atomic_inc(&sk->sk_drops);
90827 + atomic_inc_unchecked(&sk->sk_drops);
90828 err = -ENOBUFS;
90829 break;
90830 }
90831 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
90832 }
90833
90834 if (pn->rx_credits == 0) {
90835 - atomic_inc(&sk->sk_drops);
90836 + atomic_inc_unchecked(&sk->sk_drops);
90837 err = NET_RX_DROP;
90838 break;
90839 }
90840 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
90841 index 1afd138..0b42453 100644
90842 --- a/net/phonet/socket.c
90843 +++ b/net/phonet/socket.c
90844 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
90845 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
90846 sock_i_ino(sk),
90847 atomic_read(&sk->sk_refcnt), sk,
90848 - atomic_read(&sk->sk_drops), &len);
90849 + atomic_read_unchecked(&sk->sk_drops), &len);
90850 }
90851 seq_printf(seq, "%*s\n", 127 - len, "");
90852 return 0;
90853 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
90854 index d6bbbbd..61561e4 100644
90855 --- a/net/phonet/sysctl.c
90856 +++ b/net/phonet/sysctl.c
90857 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
90858 {
90859 int ret;
90860 int range[2] = {local_port_range[0], local_port_range[1]};
90861 - ctl_table tmp = {
90862 + ctl_table_no_const tmp = {
90863 .data = &range,
90864 .maxlen = sizeof(range),
90865 .mode = table->mode,
90866 diff --git a/net/rds/cong.c b/net/rds/cong.c
90867 index e5b65ac..f3b6fb7 100644
90868 --- a/net/rds/cong.c
90869 +++ b/net/rds/cong.c
90870 @@ -78,7 +78,7 @@
90871 * finds that the saved generation number is smaller than the global generation
90872 * number, it wakes up the process.
90873 */
90874 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
90875 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
90876
90877 /*
90878 * Congestion monitoring
90879 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
90880 rdsdebug("waking map %p for %pI4\n",
90881 map, &map->m_addr);
90882 rds_stats_inc(s_cong_update_received);
90883 - atomic_inc(&rds_cong_generation);
90884 + atomic_inc_unchecked(&rds_cong_generation);
90885 if (waitqueue_active(&map->m_waitq))
90886 wake_up(&map->m_waitq);
90887 if (waitqueue_active(&rds_poll_waitq))
90888 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
90889
90890 int rds_cong_updated_since(unsigned long *recent)
90891 {
90892 - unsigned long gen = atomic_read(&rds_cong_generation);
90893 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
90894
90895 if (likely(*recent == gen))
90896 return 0;
90897 diff --git a/net/rds/ib.h b/net/rds/ib.h
90898 index 7280ab8..e04f4ea 100644
90899 --- a/net/rds/ib.h
90900 +++ b/net/rds/ib.h
90901 @@ -128,7 +128,7 @@ struct rds_ib_connection {
90902 /* sending acks */
90903 unsigned long i_ack_flags;
90904 #ifdef KERNEL_HAS_ATOMIC64
90905 - atomic64_t i_ack_next; /* next ACK to send */
90906 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90907 #else
90908 spinlock_t i_ack_lock; /* protect i_ack_next */
90909 u64 i_ack_next; /* next ACK to send */
90910 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
90911 index 31b74f5..dc1fbfa 100644
90912 --- a/net/rds/ib_cm.c
90913 +++ b/net/rds/ib_cm.c
90914 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
90915 /* Clear the ACK state */
90916 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90917 #ifdef KERNEL_HAS_ATOMIC64
90918 - atomic64_set(&ic->i_ack_next, 0);
90919 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90920 #else
90921 ic->i_ack_next = 0;
90922 #endif
90923 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
90924 index 8eb9501..0c386ff 100644
90925 --- a/net/rds/ib_recv.c
90926 +++ b/net/rds/ib_recv.c
90927 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90928 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
90929 int ack_required)
90930 {
90931 - atomic64_set(&ic->i_ack_next, seq);
90932 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90933 if (ack_required) {
90934 smp_mb__before_clear_bit();
90935 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90936 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90937 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90938 smp_mb__after_clear_bit();
90939
90940 - return atomic64_read(&ic->i_ack_next);
90941 + return atomic64_read_unchecked(&ic->i_ack_next);
90942 }
90943 #endif
90944
90945 diff --git a/net/rds/iw.h b/net/rds/iw.h
90946 index 04ce3b1..48119a6 100644
90947 --- a/net/rds/iw.h
90948 +++ b/net/rds/iw.h
90949 @@ -134,7 +134,7 @@ struct rds_iw_connection {
90950 /* sending acks */
90951 unsigned long i_ack_flags;
90952 #ifdef KERNEL_HAS_ATOMIC64
90953 - atomic64_t i_ack_next; /* next ACK to send */
90954 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90955 #else
90956 spinlock_t i_ack_lock; /* protect i_ack_next */
90957 u64 i_ack_next; /* next ACK to send */
90958 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
90959 index a91e1db..cf3053f 100644
90960 --- a/net/rds/iw_cm.c
90961 +++ b/net/rds/iw_cm.c
90962 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
90963 /* Clear the ACK state */
90964 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90965 #ifdef KERNEL_HAS_ATOMIC64
90966 - atomic64_set(&ic->i_ack_next, 0);
90967 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90968 #else
90969 ic->i_ack_next = 0;
90970 #endif
90971 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
90972 index 4503335..db566b4 100644
90973 --- a/net/rds/iw_recv.c
90974 +++ b/net/rds/iw_recv.c
90975 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
90976 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
90977 int ack_required)
90978 {
90979 - atomic64_set(&ic->i_ack_next, seq);
90980 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90981 if (ack_required) {
90982 smp_mb__before_clear_bit();
90983 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90984 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
90985 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90986 smp_mb__after_clear_bit();
90987
90988 - return atomic64_read(&ic->i_ack_next);
90989 + return atomic64_read_unchecked(&ic->i_ack_next);
90990 }
90991 #endif
90992
90993 diff --git a/net/rds/rds.h b/net/rds/rds.h
90994 index ec1d731..90a3a8d 100644
90995 --- a/net/rds/rds.h
90996 +++ b/net/rds/rds.h
90997 @@ -449,7 +449,7 @@ struct rds_transport {
90998 void (*sync_mr)(void *trans_private, int direction);
90999 void (*free_mr)(void *trans_private, int invalidate);
91000 void (*flush_mrs)(void);
91001 -};
91002 +} __do_const;
91003
91004 struct rds_sock {
91005 struct sock rs_sk;
91006 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
91007 index edac9ef..16bcb98 100644
91008 --- a/net/rds/tcp.c
91009 +++ b/net/rds/tcp.c
91010 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
91011 int val = 1;
91012
91013 set_fs(KERNEL_DS);
91014 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
91015 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
91016 sizeof(val));
91017 set_fs(oldfs);
91018 }
91019 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
91020 index 81cf5a4..b5826ff 100644
91021 --- a/net/rds/tcp_send.c
91022 +++ b/net/rds/tcp_send.c
91023 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
91024
91025 oldfs = get_fs();
91026 set_fs(KERNEL_DS);
91027 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
91028 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
91029 sizeof(val));
91030 set_fs(oldfs);
91031 }
91032 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
91033 index e61aa60..f07cc89 100644
91034 --- a/net/rxrpc/af_rxrpc.c
91035 +++ b/net/rxrpc/af_rxrpc.c
91036 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
91037 __be32 rxrpc_epoch;
91038
91039 /* current debugging ID */
91040 -atomic_t rxrpc_debug_id;
91041 +atomic_unchecked_t rxrpc_debug_id;
91042
91043 /* count of skbs currently in use */
91044 atomic_t rxrpc_n_skbs;
91045 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
91046 index e4d9cbc..b229649 100644
91047 --- a/net/rxrpc/ar-ack.c
91048 +++ b/net/rxrpc/ar-ack.c
91049 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
91050
91051 _enter("{%d,%d,%d,%d},",
91052 call->acks_hard, call->acks_unacked,
91053 - atomic_read(&call->sequence),
91054 + atomic_read_unchecked(&call->sequence),
91055 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
91056
91057 stop = 0;
91058 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
91059
91060 /* each Tx packet has a new serial number */
91061 sp->hdr.serial =
91062 - htonl(atomic_inc_return(&call->conn->serial));
91063 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
91064
91065 hdr = (struct rxrpc_header *) txb->head;
91066 hdr->serial = sp->hdr.serial;
91067 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
91068 */
91069 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
91070 {
91071 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
91072 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
91073 }
91074
91075 /*
91076 @@ -629,7 +629,7 @@ process_further:
91077
91078 latest = ntohl(sp->hdr.serial);
91079 hard = ntohl(ack.firstPacket);
91080 - tx = atomic_read(&call->sequence);
91081 + tx = atomic_read_unchecked(&call->sequence);
91082
91083 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
91084 latest,
91085 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
91086 goto maybe_reschedule;
91087
91088 send_ACK_with_skew:
91089 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
91090 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
91091 ntohl(ack.serial));
91092 send_ACK:
91093 mtu = call->conn->trans->peer->if_mtu;
91094 @@ -1173,7 +1173,7 @@ send_ACK:
91095 ackinfo.rxMTU = htonl(5692);
91096 ackinfo.jumbo_max = htonl(4);
91097
91098 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
91099 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
91100 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
91101 ntohl(hdr.serial),
91102 ntohs(ack.maxSkew),
91103 @@ -1191,7 +1191,7 @@ send_ACK:
91104 send_message:
91105 _debug("send message");
91106
91107 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
91108 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
91109 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
91110 send_message_2:
91111
91112 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
91113 index a3bbb36..3341fb9 100644
91114 --- a/net/rxrpc/ar-call.c
91115 +++ b/net/rxrpc/ar-call.c
91116 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
91117 spin_lock_init(&call->lock);
91118 rwlock_init(&call->state_lock);
91119 atomic_set(&call->usage, 1);
91120 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
91121 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91122 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
91123
91124 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
91125 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
91126 index 4106ca9..a338d7a 100644
91127 --- a/net/rxrpc/ar-connection.c
91128 +++ b/net/rxrpc/ar-connection.c
91129 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
91130 rwlock_init(&conn->lock);
91131 spin_lock_init(&conn->state_lock);
91132 atomic_set(&conn->usage, 1);
91133 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
91134 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91135 conn->avail_calls = RXRPC_MAXCALLS;
91136 conn->size_align = 4;
91137 conn->header_size = sizeof(struct rxrpc_header);
91138 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
91139 index e7ed43a..6afa140 100644
91140 --- a/net/rxrpc/ar-connevent.c
91141 +++ b/net/rxrpc/ar-connevent.c
91142 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
91143
91144 len = iov[0].iov_len + iov[1].iov_len;
91145
91146 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
91147 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
91148 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
91149
91150 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
91151 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
91152 index 529572f..c758ca7 100644
91153 --- a/net/rxrpc/ar-input.c
91154 +++ b/net/rxrpc/ar-input.c
91155 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
91156 /* track the latest serial number on this connection for ACK packet
91157 * information */
91158 serial = ntohl(sp->hdr.serial);
91159 - hi_serial = atomic_read(&call->conn->hi_serial);
91160 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
91161 while (serial > hi_serial)
91162 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
91163 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
91164 serial);
91165
91166 /* request ACK generation for any ACK or DATA packet that requests
91167 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
91168 index a693aca..81e7293 100644
91169 --- a/net/rxrpc/ar-internal.h
91170 +++ b/net/rxrpc/ar-internal.h
91171 @@ -272,8 +272,8 @@ struct rxrpc_connection {
91172 int error; /* error code for local abort */
91173 int debug_id; /* debug ID for printks */
91174 unsigned int call_counter; /* call ID counter */
91175 - atomic_t serial; /* packet serial number counter */
91176 - atomic_t hi_serial; /* highest serial number received */
91177 + atomic_unchecked_t serial; /* packet serial number counter */
91178 + atomic_unchecked_t hi_serial; /* highest serial number received */
91179 u8 avail_calls; /* number of calls available */
91180 u8 size_align; /* data size alignment (for security) */
91181 u8 header_size; /* rxrpc + security header size */
91182 @@ -346,7 +346,7 @@ struct rxrpc_call {
91183 spinlock_t lock;
91184 rwlock_t state_lock; /* lock for state transition */
91185 atomic_t usage;
91186 - atomic_t sequence; /* Tx data packet sequence counter */
91187 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
91188 u32 abort_code; /* local/remote abort code */
91189 enum { /* current state of call */
91190 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
91191 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
91192 */
91193 extern atomic_t rxrpc_n_skbs;
91194 extern __be32 rxrpc_epoch;
91195 -extern atomic_t rxrpc_debug_id;
91196 +extern atomic_unchecked_t rxrpc_debug_id;
91197 extern struct workqueue_struct *rxrpc_workqueue;
91198
91199 /*
91200 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
91201 index 87f7135..74d3703 100644
91202 --- a/net/rxrpc/ar-local.c
91203 +++ b/net/rxrpc/ar-local.c
91204 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
91205 spin_lock_init(&local->lock);
91206 rwlock_init(&local->services_lock);
91207 atomic_set(&local->usage, 1);
91208 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
91209 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91210 memcpy(&local->srx, srx, sizeof(*srx));
91211 }
91212
91213 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
91214 index e1ac183..b43e10e 100644
91215 --- a/net/rxrpc/ar-output.c
91216 +++ b/net/rxrpc/ar-output.c
91217 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
91218 sp->hdr.cid = call->cid;
91219 sp->hdr.callNumber = call->call_id;
91220 sp->hdr.seq =
91221 - htonl(atomic_inc_return(&call->sequence));
91222 + htonl(atomic_inc_return_unchecked(&call->sequence));
91223 sp->hdr.serial =
91224 - htonl(atomic_inc_return(&conn->serial));
91225 + htonl(atomic_inc_return_unchecked(&conn->serial));
91226 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
91227 sp->hdr.userStatus = 0;
91228 sp->hdr.securityIndex = conn->security_ix;
91229 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
91230 index bebaa43..2644591 100644
91231 --- a/net/rxrpc/ar-peer.c
91232 +++ b/net/rxrpc/ar-peer.c
91233 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
91234 INIT_LIST_HEAD(&peer->error_targets);
91235 spin_lock_init(&peer->lock);
91236 atomic_set(&peer->usage, 1);
91237 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
91238 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91239 memcpy(&peer->srx, srx, sizeof(*srx));
91240
91241 rxrpc_assess_MTU_size(peer);
91242 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
91243 index 38047f7..9f48511 100644
91244 --- a/net/rxrpc/ar-proc.c
91245 +++ b/net/rxrpc/ar-proc.c
91246 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
91247 atomic_read(&conn->usage),
91248 rxrpc_conn_states[conn->state],
91249 key_serial(conn->key),
91250 - atomic_read(&conn->serial),
91251 - atomic_read(&conn->hi_serial));
91252 + atomic_read_unchecked(&conn->serial),
91253 + atomic_read_unchecked(&conn->hi_serial));
91254
91255 return 0;
91256 }
91257 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
91258 index 92df566..87ec1bf 100644
91259 --- a/net/rxrpc/ar-transport.c
91260 +++ b/net/rxrpc/ar-transport.c
91261 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
91262 spin_lock_init(&trans->client_lock);
91263 rwlock_init(&trans->conn_lock);
91264 atomic_set(&trans->usage, 1);
91265 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
91266 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
91267
91268 if (peer->srx.transport.family == AF_INET) {
91269 switch (peer->srx.transport_type) {
91270 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
91271 index f226709..0e735a8 100644
91272 --- a/net/rxrpc/rxkad.c
91273 +++ b/net/rxrpc/rxkad.c
91274 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
91275
91276 len = iov[0].iov_len + iov[1].iov_len;
91277
91278 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
91279 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
91280 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
91281
91282 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
91283 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
91284
91285 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
91286
91287 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
91288 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
91289 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
91290
91291 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
91292 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
91293 index 391a245..296b3d7 100644
91294 --- a/net/sctp/ipv6.c
91295 +++ b/net/sctp/ipv6.c
91296 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
91297 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
91298 };
91299
91300 -static struct sctp_af sctp_af_inet6 = {
91301 +static struct sctp_af sctp_af_inet6 __read_only = {
91302 .sa_family = AF_INET6,
91303 .sctp_xmit = sctp_v6_xmit,
91304 .setsockopt = ipv6_setsockopt,
91305 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
91306 #endif
91307 };
91308
91309 -static struct sctp_pf sctp_pf_inet6 = {
91310 +static struct sctp_pf sctp_pf_inet6 __read_only = {
91311 .event_msgname = sctp_inet6_event_msgname,
91312 .skb_msgname = sctp_inet6_skb_msgname,
91313 .af_supported = sctp_inet6_af_supported,
91314 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
91315
91316 void sctp_v6_pf_exit(void)
91317 {
91318 - list_del(&sctp_af_inet6.list);
91319 + pax_list_del(&sctp_af_inet6.list);
91320 }
91321
91322 /* Initialize IPv6 support and register with socket layer. */
91323 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
91324 index 4e45ee3..e66a031 100644
91325 --- a/net/sctp/proc.c
91326 +++ b/net/sctp/proc.c
91327 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
91328 seq_printf(seq,
91329 "%8pK %8pK %-3d %-3d %-2d %-4d "
91330 "%4d %8d %8d %7d %5lu %-5d %5d ",
91331 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
91332 + assoc, sk,
91333 + sctp_sk(sk)->type, sk->sk_state,
91334 assoc->state, hash,
91335 assoc->assoc_id,
91336 assoc->sndbuf_used,
91337 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
91338 index eaee00c..97c0afd 100644
91339 --- a/net/sctp/protocol.c
91340 +++ b/net/sctp/protocol.c
91341 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
91342 return 0;
91343 }
91344
91345 + pax_open_kernel();
91346 INIT_LIST_HEAD(&af->list);
91347 - list_add_tail(&af->list, &sctp_address_families);
91348 + pax_close_kernel();
91349 + pax_list_add_tail(&af->list, &sctp_address_families);
91350 return 1;
91351 }
91352
91353 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
91354
91355 static struct sctp_af sctp_af_inet;
91356
91357 -static struct sctp_pf sctp_pf_inet = {
91358 +static struct sctp_pf sctp_pf_inet __read_only = {
91359 .event_msgname = sctp_inet_event_msgname,
91360 .skb_msgname = sctp_inet_skb_msgname,
91361 .af_supported = sctp_inet_af_supported,
91362 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
91363 };
91364
91365 /* IPv4 address related functions. */
91366 -static struct sctp_af sctp_af_inet = {
91367 +static struct sctp_af sctp_af_inet __read_only = {
91368 .sa_family = AF_INET,
91369 .sctp_xmit = sctp_v4_xmit,
91370 .setsockopt = ip_setsockopt,
91371 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
91372
91373 static void sctp_v4_pf_exit(void)
91374 {
91375 - list_del(&sctp_af_inet.list);
91376 + pax_list_del(&sctp_af_inet.list);
91377 }
91378
91379 static int sctp_v4_protosw_init(void)
91380 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
91381 index 8aab894..f6b7e7d 100644
91382 --- a/net/sctp/sm_sideeffect.c
91383 +++ b/net/sctp/sm_sideeffect.c
91384 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
91385 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
91386 }
91387
91388 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
91389 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
91390 NULL,
91391 sctp_generate_t1_cookie_event,
91392 sctp_generate_t1_init_event,
91393 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
91394 index 6abb1ca..1678f8b 100644
91395 --- a/net/sctp/socket.c
91396 +++ b/net/sctp/socket.c
91397 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
91398 {
91399 struct sctp_association *asoc;
91400 struct sctp_ulpevent *event;
91401 + struct sctp_event_subscribe subscribe;
91402
91403 if (optlen > sizeof(struct sctp_event_subscribe))
91404 return -EINVAL;
91405 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
91406 + if (copy_from_user(&subscribe, optval, optlen))
91407 return -EFAULT;
91408 + sctp_sk(sk)->subscribe = subscribe;
91409
91410 /*
91411 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
91412 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
91413 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
91414 int __user *optlen)
91415 {
91416 + struct sctp_event_subscribe subscribe;
91417 +
91418 if (len <= 0)
91419 return -EINVAL;
91420 if (len > sizeof(struct sctp_event_subscribe))
91421 len = sizeof(struct sctp_event_subscribe);
91422 if (put_user(len, optlen))
91423 return -EFAULT;
91424 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
91425 + subscribe = sctp_sk(sk)->subscribe;
91426 + if (copy_to_user(optval, &subscribe, len))
91427 return -EFAULT;
91428 return 0;
91429 }
91430 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
91431 */
91432 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
91433 {
91434 + __u32 autoclose;
91435 +
91436 /* Applicable to UDP-style socket only */
91437 if (sctp_style(sk, TCP))
91438 return -EOPNOTSUPP;
91439 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
91440 len = sizeof(int);
91441 if (put_user(len, optlen))
91442 return -EFAULT;
91443 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
91444 + autoclose = sctp_sk(sk)->autoclose;
91445 + if (copy_to_user(optval, &autoclose, sizeof(int)))
91446 return -EFAULT;
91447 return 0;
91448 }
91449 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
91450 */
91451 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
91452 {
91453 + struct sctp_initmsg initmsg;
91454 +
91455 if (len < sizeof(struct sctp_initmsg))
91456 return -EINVAL;
91457 len = sizeof(struct sctp_initmsg);
91458 if (put_user(len, optlen))
91459 return -EFAULT;
91460 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
91461 + initmsg = sctp_sk(sk)->initmsg;
91462 + if (copy_to_user(optval, &initmsg, len))
91463 return -EFAULT;
91464 return 0;
91465 }
91466 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
91467 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
91468 if (space_left < addrlen)
91469 return -ENOMEM;
91470 + if (addrlen > sizeof(temp) || addrlen < 0)
91471 + return -EFAULT;
91472 if (copy_to_user(to, &temp, addrlen))
91473 return -EFAULT;
91474 to += addrlen;
91475 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
91476 index bf3c6e8..376d8d0 100644
91477 --- a/net/sctp/sysctl.c
91478 +++ b/net/sctp/sysctl.c
91479 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
91480 {
91481 struct net *net = current->nsproxy->net_ns;
91482 char tmp[8];
91483 - ctl_table tbl;
91484 + ctl_table_no_const tbl;
91485 int ret;
91486 int changed = 0;
91487 char *none = "none";
91488 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
91489
91490 int sctp_sysctl_net_register(struct net *net)
91491 {
91492 - struct ctl_table *table;
91493 + ctl_table_no_const *table;
91494 int i;
91495
91496 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
91497 diff --git a/net/socket.c b/net/socket.c
91498 index 4ca1526..df83e47 100644
91499 --- a/net/socket.c
91500 +++ b/net/socket.c
91501 @@ -88,6 +88,7 @@
91502 #include <linux/magic.h>
91503 #include <linux/slab.h>
91504 #include <linux/xattr.h>
91505 +#include <linux/in.h>
91506
91507 #include <asm/uaccess.h>
91508 #include <asm/unistd.h>
91509 @@ -105,6 +106,8 @@
91510 #include <linux/sockios.h>
91511 #include <linux/atalk.h>
91512
91513 +#include <linux/grsock.h>
91514 +
91515 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
91516 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
91517 unsigned long nr_segs, loff_t pos);
91518 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
91519 &sockfs_dentry_operations, SOCKFS_MAGIC);
91520 }
91521
91522 -static struct vfsmount *sock_mnt __read_mostly;
91523 +struct vfsmount *sock_mnt __read_mostly;
91524
91525 static struct file_system_type sock_fs_type = {
91526 .name = "sockfs",
91527 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
91528 return -EAFNOSUPPORT;
91529 if (type < 0 || type >= SOCK_MAX)
91530 return -EINVAL;
91531 + if (protocol < 0)
91532 + return -EINVAL;
91533
91534 /* Compatibility.
91535
91536 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
91537 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
91538 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
91539
91540 + if(!gr_search_socket(family, type, protocol)) {
91541 + retval = -EACCES;
91542 + goto out;
91543 + }
91544 +
91545 + if (gr_handle_sock_all(family, type, protocol)) {
91546 + retval = -EACCES;
91547 + goto out;
91548 + }
91549 +
91550 retval = sock_create(family, type, protocol, &sock);
91551 if (retval < 0)
91552 goto out;
91553 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
91554 if (sock) {
91555 err = move_addr_to_kernel(umyaddr, addrlen, &address);
91556 if (err >= 0) {
91557 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
91558 + err = -EACCES;
91559 + goto error;
91560 + }
91561 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
91562 + if (err)
91563 + goto error;
91564 +
91565 err = security_socket_bind(sock,
91566 (struct sockaddr *)&address,
91567 addrlen);
91568 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
91569 (struct sockaddr *)
91570 &address, addrlen);
91571 }
91572 +error:
91573 fput_light(sock->file, fput_needed);
91574 }
91575 return err;
91576 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
91577 if ((unsigned int)backlog > somaxconn)
91578 backlog = somaxconn;
91579
91580 + if (gr_handle_sock_server_other(sock->sk)) {
91581 + err = -EPERM;
91582 + goto error;
91583 + }
91584 +
91585 + err = gr_search_listen(sock);
91586 + if (err)
91587 + goto error;
91588 +
91589 err = security_socket_listen(sock, backlog);
91590 if (!err)
91591 err = sock->ops->listen(sock, backlog);
91592
91593 +error:
91594 fput_light(sock->file, fput_needed);
91595 }
91596 return err;
91597 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
91598 newsock->type = sock->type;
91599 newsock->ops = sock->ops;
91600
91601 + if (gr_handle_sock_server_other(sock->sk)) {
91602 + err = -EPERM;
91603 + sock_release(newsock);
91604 + goto out_put;
91605 + }
91606 +
91607 + err = gr_search_accept(sock);
91608 + if (err) {
91609 + sock_release(newsock);
91610 + goto out_put;
91611 + }
91612 +
91613 /*
91614 * We don't need try_module_get here, as the listening socket (sock)
91615 * has the protocol module (sock->ops->owner) held.
91616 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
91617 fd_install(newfd, newfile);
91618 err = newfd;
91619
91620 + gr_attach_curr_ip(newsock->sk);
91621 +
91622 out_put:
91623 fput_light(sock->file, fput_needed);
91624 out:
91625 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
91626 int, addrlen)
91627 {
91628 struct socket *sock;
91629 + struct sockaddr *sck;
91630 struct sockaddr_storage address;
91631 int err, fput_needed;
91632
91633 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
91634 if (err < 0)
91635 goto out_put;
91636
91637 + sck = (struct sockaddr *)&address;
91638 +
91639 + if (gr_handle_sock_client(sck)) {
91640 + err = -EACCES;
91641 + goto out_put;
91642 + }
91643 +
91644 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
91645 + if (err)
91646 + goto out_put;
91647 +
91648 err =
91649 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
91650 if (err)
91651 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
91652 * the protocol.
91653 */
91654
91655 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
91656 +
91657 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
91658 unsigned int, flags, struct sockaddr __user *, addr,
91659 int, addr_len)
91660 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
91661 struct socket *sock;
91662 struct iovec iov;
91663 struct msghdr msg;
91664 - struct sockaddr_storage address;
91665 + struct sockaddr_storage address = { };
91666 int err, err2;
91667 int fput_needed;
91668
91669 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
91670 * checking falls down on this.
91671 */
91672 if (copy_from_user(ctl_buf,
91673 - (void __user __force *)msg_sys->msg_control,
91674 + (void __force_user *)msg_sys->msg_control,
91675 ctl_len))
91676 goto out_freectl;
91677 msg_sys->msg_control = ctl_buf;
91678 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
91679 int err, total_len, len;
91680
91681 /* kernel mode address */
91682 - struct sockaddr_storage addr;
91683 + struct sockaddr_storage addr = { };
91684
91685 /* user mode address pointers */
91686 struct sockaddr __user *uaddr;
91687 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
91688 * kernel msghdr to use the kernel address space)
91689 */
91690
91691 - uaddr = (__force void __user *)msg_sys->msg_name;
91692 + uaddr = (void __force_user *)msg_sys->msg_name;
91693 uaddr_len = COMPAT_NAMELEN(msg);
91694 if (MSG_CMSG_COMPAT & flags) {
91695 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
91696 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
91697 old_fs = get_fs();
91698 set_fs(KERNEL_DS);
91699 err = dev_ioctl(net, cmd,
91700 - (struct ifreq __user __force *) &kifr);
91701 + (struct ifreq __force_user *) &kifr);
91702 set_fs(old_fs);
91703
91704 return err;
91705 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
91706
91707 old_fs = get_fs();
91708 set_fs(KERNEL_DS);
91709 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
91710 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
91711 set_fs(old_fs);
91712
91713 if (cmd == SIOCGIFMAP && !err) {
91714 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
91715 ret |= __get_user(rtdev, &(ur4->rt_dev));
91716 if (rtdev) {
91717 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
91718 - r4.rt_dev = (char __user __force *)devname;
91719 + r4.rt_dev = (char __force_user *)devname;
91720 devname[15] = 0;
91721 } else
91722 r4.rt_dev = NULL;
91723 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
91724 int __user *uoptlen;
91725 int err;
91726
91727 - uoptval = (char __user __force *) optval;
91728 - uoptlen = (int __user __force *) optlen;
91729 + uoptval = (char __force_user *) optval;
91730 + uoptlen = (int __force_user *) optlen;
91731
91732 set_fs(KERNEL_DS);
91733 if (level == SOL_SOCKET)
91734 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
91735 char __user *uoptval;
91736 int err;
91737
91738 - uoptval = (char __user __force *) optval;
91739 + uoptval = (char __force_user *) optval;
91740
91741 set_fs(KERNEL_DS);
91742 if (level == SOL_SOCKET)
91743 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
91744 index 5a750b9..ca5d7af 100644
91745 --- a/net/sunrpc/clnt.c
91746 +++ b/net/sunrpc/clnt.c
91747 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
91748 (RPC_IS_ASYNC(task) ? "async" : "sync"));
91749
91750 /* Increment call count */
91751 - task->tk_msg.rpc_proc->p_count++;
91752 + pax_open_kernel();
91753 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
91754 + pax_close_kernel();
91755 clnt->cl_stats->rpccnt++;
91756 task->tk_action = call_reserve;
91757 }
91758 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
91759 index 5356b12..c0f4c29 100644
91760 --- a/net/sunrpc/sched.c
91761 +++ b/net/sunrpc/sched.c
91762 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
91763 #ifdef RPC_DEBUG
91764 static void rpc_task_set_debuginfo(struct rpc_task *task)
91765 {
91766 - static atomic_t rpc_pid;
91767 + static atomic_unchecked_t rpc_pid;
91768
91769 - task->tk_pid = atomic_inc_return(&rpc_pid);
91770 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
91771 }
91772 #else
91773 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
91774 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
91775 index 89a588b..678ed90 100644
91776 --- a/net/sunrpc/svc.c
91777 +++ b/net/sunrpc/svc.c
91778 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
91779
91780 __module_get(serv->sv_module);
91781 task = kthread_create_on_node(serv->sv_function, rqstp,
91782 - node, serv->sv_name);
91783 + node, "%s", serv->sv_name);
91784 if (IS_ERR(task)) {
91785 error = PTR_ERR(task);
91786 module_put(serv->sv_module);
91787 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
91788 svc_putnl(resv, RPC_SUCCESS);
91789
91790 /* Bump per-procedure stats counter */
91791 - procp->pc_count++;
91792 + pax_open_kernel();
91793 + (*(unsigned int *)&procp->pc_count)++;
91794 + pax_close_kernel();
91795
91796 /* Initialize storage for argp and resp */
91797 memset(rqstp->rq_argp, 0, procp->pc_argsize);
91798 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
91799 index 8343737..677025e 100644
91800 --- a/net/sunrpc/xprtrdma/svc_rdma.c
91801 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
91802 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
91803 static unsigned int min_max_inline = 4096;
91804 static unsigned int max_max_inline = 65536;
91805
91806 -atomic_t rdma_stat_recv;
91807 -atomic_t rdma_stat_read;
91808 -atomic_t rdma_stat_write;
91809 -atomic_t rdma_stat_sq_starve;
91810 -atomic_t rdma_stat_rq_starve;
91811 -atomic_t rdma_stat_rq_poll;
91812 -atomic_t rdma_stat_rq_prod;
91813 -atomic_t rdma_stat_sq_poll;
91814 -atomic_t rdma_stat_sq_prod;
91815 +atomic_unchecked_t rdma_stat_recv;
91816 +atomic_unchecked_t rdma_stat_read;
91817 +atomic_unchecked_t rdma_stat_write;
91818 +atomic_unchecked_t rdma_stat_sq_starve;
91819 +atomic_unchecked_t rdma_stat_rq_starve;
91820 +atomic_unchecked_t rdma_stat_rq_poll;
91821 +atomic_unchecked_t rdma_stat_rq_prod;
91822 +atomic_unchecked_t rdma_stat_sq_poll;
91823 +atomic_unchecked_t rdma_stat_sq_prod;
91824
91825 /* Temporary NFS request map and context caches */
91826 struct kmem_cache *svc_rdma_map_cachep;
91827 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
91828 len -= *ppos;
91829 if (len > *lenp)
91830 len = *lenp;
91831 - if (len && copy_to_user(buffer, str_buf, len))
91832 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
91833 return -EFAULT;
91834 *lenp = len;
91835 *ppos += len;
91836 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
91837 {
91838 .procname = "rdma_stat_read",
91839 .data = &rdma_stat_read,
91840 - .maxlen = sizeof(atomic_t),
91841 + .maxlen = sizeof(atomic_unchecked_t),
91842 .mode = 0644,
91843 .proc_handler = read_reset_stat,
91844 },
91845 {
91846 .procname = "rdma_stat_recv",
91847 .data = &rdma_stat_recv,
91848 - .maxlen = sizeof(atomic_t),
91849 + .maxlen = sizeof(atomic_unchecked_t),
91850 .mode = 0644,
91851 .proc_handler = read_reset_stat,
91852 },
91853 {
91854 .procname = "rdma_stat_write",
91855 .data = &rdma_stat_write,
91856 - .maxlen = sizeof(atomic_t),
91857 + .maxlen = sizeof(atomic_unchecked_t),
91858 .mode = 0644,
91859 .proc_handler = read_reset_stat,
91860 },
91861 {
91862 .procname = "rdma_stat_sq_starve",
91863 .data = &rdma_stat_sq_starve,
91864 - .maxlen = sizeof(atomic_t),
91865 + .maxlen = sizeof(atomic_unchecked_t),
91866 .mode = 0644,
91867 .proc_handler = read_reset_stat,
91868 },
91869 {
91870 .procname = "rdma_stat_rq_starve",
91871 .data = &rdma_stat_rq_starve,
91872 - .maxlen = sizeof(atomic_t),
91873 + .maxlen = sizeof(atomic_unchecked_t),
91874 .mode = 0644,
91875 .proc_handler = read_reset_stat,
91876 },
91877 {
91878 .procname = "rdma_stat_rq_poll",
91879 .data = &rdma_stat_rq_poll,
91880 - .maxlen = sizeof(atomic_t),
91881 + .maxlen = sizeof(atomic_unchecked_t),
91882 .mode = 0644,
91883 .proc_handler = read_reset_stat,
91884 },
91885 {
91886 .procname = "rdma_stat_rq_prod",
91887 .data = &rdma_stat_rq_prod,
91888 - .maxlen = sizeof(atomic_t),
91889 + .maxlen = sizeof(atomic_unchecked_t),
91890 .mode = 0644,
91891 .proc_handler = read_reset_stat,
91892 },
91893 {
91894 .procname = "rdma_stat_sq_poll",
91895 .data = &rdma_stat_sq_poll,
91896 - .maxlen = sizeof(atomic_t),
91897 + .maxlen = sizeof(atomic_unchecked_t),
91898 .mode = 0644,
91899 .proc_handler = read_reset_stat,
91900 },
91901 {
91902 .procname = "rdma_stat_sq_prod",
91903 .data = &rdma_stat_sq_prod,
91904 - .maxlen = sizeof(atomic_t),
91905 + .maxlen = sizeof(atomic_unchecked_t),
91906 .mode = 0644,
91907 .proc_handler = read_reset_stat,
91908 },
91909 diff --git a/net/sunrpc/xprtrdma/svc_rdma_marshal.c b/net/sunrpc/xprtrdma/svc_rdma_marshal.c
91910 index 8d2eddd..65b1462 100644
91911 --- a/net/sunrpc/xprtrdma/svc_rdma_marshal.c
91912 +++ b/net/sunrpc/xprtrdma/svc_rdma_marshal.c
91913 @@ -98,6 +98,7 @@ void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *ch,
91914 */
91915 static u32 *decode_write_list(u32 *va, u32 *vaend)
91916 {
91917 + unsigned long start, end;
91918 int nchunks;
91919
91920 struct rpcrdma_write_array *ary =
91921 @@ -113,9 +114,12 @@ static u32 *decode_write_list(u32 *va, u32 *vaend)
91922 return NULL;
91923 }
91924 nchunks = ntohl(ary->wc_nchunks);
91925 - if (((unsigned long)&ary->wc_array[0] +
91926 - (sizeof(struct rpcrdma_write_chunk) * nchunks)) >
91927 - (unsigned long)vaend) {
91928 +
91929 + start = (unsigned long)&ary->wc_array[0];
91930 + end = (unsigned long)vaend;
91931 + if (nchunks < 0 ||
91932 + nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) ||
91933 + (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) {
91934 dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n",
91935 ary, nchunks, vaend);
91936 return NULL;
91937 @@ -129,6 +133,7 @@ static u32 *decode_write_list(u32 *va, u32 *vaend)
91938
91939 static u32 *decode_reply_array(u32 *va, u32 *vaend)
91940 {
91941 + unsigned long start, end;
91942 int nchunks;
91943 struct rpcrdma_write_array *ary =
91944 (struct rpcrdma_write_array *)va;
91945 @@ -143,9 +148,12 @@ static u32 *decode_reply_array(u32 *va, u32 *vaend)
91946 return NULL;
91947 }
91948 nchunks = ntohl(ary->wc_nchunks);
91949 - if (((unsigned long)&ary->wc_array[0] +
91950 - (sizeof(struct rpcrdma_write_chunk) * nchunks)) >
91951 - (unsigned long)vaend) {
91952 +
91953 + start = (unsigned long)&ary->wc_array[0];
91954 + end = (unsigned long)vaend;
91955 + if (nchunks < 0 ||
91956 + nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) ||
91957 + (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) {
91958 dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n",
91959 ary, nchunks, vaend);
91960 return NULL;
91961 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91962 index 0ce7552..d074459 100644
91963 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91964 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91965 @@ -501,7 +501,7 @@ next_sge:
91966 svc_rdma_put_context(ctxt, 0);
91967 goto out;
91968 }
91969 - atomic_inc(&rdma_stat_read);
91970 + atomic_inc_unchecked(&rdma_stat_read);
91971
91972 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
91973 chl_map->ch[ch_no].count -= read_wr.num_sge;
91974 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91975 dto_q);
91976 list_del_init(&ctxt->dto_q);
91977 } else {
91978 - atomic_inc(&rdma_stat_rq_starve);
91979 + atomic_inc_unchecked(&rdma_stat_rq_starve);
91980 clear_bit(XPT_DATA, &xprt->xpt_flags);
91981 ctxt = NULL;
91982 }
91983 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91984 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
91985 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
91986 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
91987 - atomic_inc(&rdma_stat_recv);
91988 + atomic_inc_unchecked(&rdma_stat_recv);
91989
91990 /* Build up the XDR from the receive buffers. */
91991 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
91992 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91993 index c1d124d..acfc59e 100644
91994 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91995 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91996 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
91997 write_wr.wr.rdma.remote_addr = to;
91998
91999 /* Post It */
92000 - atomic_inc(&rdma_stat_write);
92001 + atomic_inc_unchecked(&rdma_stat_write);
92002 if (svc_rdma_send(xprt, &write_wr))
92003 goto err;
92004 return 0;
92005 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
92006 index 62e4f9b..dd3f2d7 100644
92007 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
92008 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
92009 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
92010 return;
92011
92012 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
92013 - atomic_inc(&rdma_stat_rq_poll);
92014 + atomic_inc_unchecked(&rdma_stat_rq_poll);
92015
92016 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
92017 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
92018 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
92019 }
92020
92021 if (ctxt)
92022 - atomic_inc(&rdma_stat_rq_prod);
92023 + atomic_inc_unchecked(&rdma_stat_rq_prod);
92024
92025 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
92026 /*
92027 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
92028 return;
92029
92030 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
92031 - atomic_inc(&rdma_stat_sq_poll);
92032 + atomic_inc_unchecked(&rdma_stat_sq_poll);
92033 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
92034 if (wc.status != IB_WC_SUCCESS)
92035 /* Close the transport */
92036 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
92037 }
92038
92039 if (ctxt)
92040 - atomic_inc(&rdma_stat_sq_prod);
92041 + atomic_inc_unchecked(&rdma_stat_sq_prod);
92042 }
92043
92044 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
92045 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
92046 spin_lock_bh(&xprt->sc_lock);
92047 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
92048 spin_unlock_bh(&xprt->sc_lock);
92049 - atomic_inc(&rdma_stat_sq_starve);
92050 + atomic_inc_unchecked(&rdma_stat_sq_starve);
92051
92052 /* See if we can opportunistically reap SQ WR to make room */
92053 sq_cq_reap(xprt);
92054 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
92055 index 9bc6db0..47ac8c0 100644
92056 --- a/net/sysctl_net.c
92057 +++ b/net/sysctl_net.c
92058 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
92059 kgid_t root_gid = make_kgid(net->user_ns, 0);
92060
92061 /* Allow network administrator to have same access as root. */
92062 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
92063 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
92064 uid_eq(root_uid, current_uid())) {
92065 int mode = (table->mode >> 6) & 7;
92066 return (mode << 6) | (mode << 3) | mode;
92067 diff --git a/net/tipc/link.c b/net/tipc/link.c
92068 index a80feee..2bbbe70 100644
92069 --- a/net/tipc/link.c
92070 +++ b/net/tipc/link.c
92071 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
92072 struct tipc_msg fragm_hdr;
92073 struct sk_buff *buf, *buf_chain, *prev;
92074 u32 fragm_crs, fragm_rest, hsz, sect_rest;
92075 - const unchar *sect_crs;
92076 + const unchar __user *sect_crs;
92077 int curr_sect;
92078 u32 fragm_no;
92079
92080 @@ -1242,7 +1242,7 @@ again:
92081
92082 if (!sect_rest) {
92083 sect_rest = msg_sect[++curr_sect].iov_len;
92084 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
92085 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
92086 }
92087
92088 if (sect_rest < fragm_rest)
92089 @@ -1261,7 +1261,7 @@ error:
92090 }
92091 } else
92092 skb_copy_to_linear_data_offset(buf, fragm_crs,
92093 - sect_crs, sz);
92094 + (const void __force_kernel *)sect_crs, sz);
92095 sect_crs += sz;
92096 sect_rest -= sz;
92097 fragm_crs += sz;
92098 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
92099 index f2db8a8..9245aa4 100644
92100 --- a/net/tipc/msg.c
92101 +++ b/net/tipc/msg.c
92102 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
92103 msg_sect[cnt].iov_len);
92104 else
92105 skb_copy_to_linear_data_offset(*buf, pos,
92106 - msg_sect[cnt].iov_base,
92107 + (const void __force_kernel *)msg_sect[cnt].iov_base,
92108 msg_sect[cnt].iov_len);
92109 pos += msg_sect[cnt].iov_len;
92110 }
92111 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
92112 index 6b42d47..2ac24d5 100644
92113 --- a/net/tipc/subscr.c
92114 +++ b/net/tipc/subscr.c
92115 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
92116 {
92117 struct iovec msg_sect;
92118
92119 - msg_sect.iov_base = (void *)&sub->evt;
92120 + msg_sect.iov_base = (void __force_user *)&sub->evt;
92121 msg_sect.iov_len = sizeof(struct tipc_event);
92122
92123 sub->evt.event = htohl(event, sub->swap);
92124 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
92125 index 826e099..4fa8c93 100644
92126 --- a/net/unix/af_unix.c
92127 +++ b/net/unix/af_unix.c
92128 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
92129 err = -ECONNREFUSED;
92130 if (!S_ISSOCK(inode->i_mode))
92131 goto put_fail;
92132 +
92133 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
92134 + err = -EACCES;
92135 + goto put_fail;
92136 + }
92137 +
92138 u = unix_find_socket_byinode(inode);
92139 if (!u)
92140 goto put_fail;
92141 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
92142 if (u) {
92143 struct dentry *dentry;
92144 dentry = unix_sk(u)->path.dentry;
92145 +
92146 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
92147 + err = -EPERM;
92148 + sock_put(u);
92149 + goto fail;
92150 + }
92151 +
92152 if (dentry)
92153 touch_atime(&unix_sk(u)->path);
92154 } else
92155 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
92156 */
92157 err = security_path_mknod(&path, dentry, mode, 0);
92158 if (!err) {
92159 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
92160 + err = -EACCES;
92161 + goto out;
92162 + }
92163 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
92164 if (!err) {
92165 res->mnt = mntget(path.mnt);
92166 res->dentry = dget(dentry);
92167 + gr_handle_create(dentry, path.mnt);
92168 }
92169 }
92170 +out:
92171 done_path_create(&path, dentry);
92172 return err;
92173 }
92174 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
92175 seq_puts(seq, "Num RefCount Protocol Flags Type St "
92176 "Inode Path\n");
92177 else {
92178 - struct sock *s = v;
92179 + struct sock *s = v, *peer;
92180 struct unix_sock *u = unix_sk(s);
92181 unix_state_lock(s);
92182 + peer = unix_peer(s);
92183 + unix_state_unlock(s);
92184 +
92185 + unix_state_double_lock(s, peer);
92186
92187 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
92188 s,
92189 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
92190 }
92191 for ( ; i < len; i++)
92192 seq_putc(seq, u->addr->name->sun_path[i]);
92193 - }
92194 - unix_state_unlock(s);
92195 + } else if (peer)
92196 + seq_printf(seq, " P%lu", sock_i_ino(peer));
92197 +
92198 + unix_state_double_unlock(s, peer);
92199 seq_putc(seq, '\n');
92200 }
92201
92202 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
92203 index 8800604..0526440 100644
92204 --- a/net/unix/sysctl_net_unix.c
92205 +++ b/net/unix/sysctl_net_unix.c
92206 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
92207
92208 int __net_init unix_sysctl_register(struct net *net)
92209 {
92210 - struct ctl_table *table;
92211 + ctl_table_no_const *table;
92212
92213 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
92214 if (table == NULL)
92215 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
92216 index c8717c1..08539f5 100644
92217 --- a/net/wireless/wext-core.c
92218 +++ b/net/wireless/wext-core.c
92219 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
92220 */
92221
92222 /* Support for very large requests */
92223 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
92224 - (user_length > descr->max_tokens)) {
92225 + if (user_length > descr->max_tokens) {
92226 /* Allow userspace to GET more than max so
92227 * we can support any size GET requests.
92228 * There is still a limit : -ENOMEM.
92229 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
92230 }
92231 }
92232
92233 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
92234 - /*
92235 - * If this is a GET, but not NOMAX, it means that the extra
92236 - * data is not bounded by userspace, but by max_tokens. Thus
92237 - * set the length to max_tokens. This matches the extra data
92238 - * allocation.
92239 - * The driver should fill it with the number of tokens it
92240 - * provided, and it may check iwp->length rather than having
92241 - * knowledge of max_tokens. If the driver doesn't change the
92242 - * iwp->length, this ioctl just copies back max_token tokens
92243 - * filled with zeroes. Hopefully the driver isn't claiming
92244 - * them to be valid data.
92245 - */
92246 - iwp->length = descr->max_tokens;
92247 - }
92248 -
92249 err = handler(dev, info, (union iwreq_data *) iwp, extra);
92250
92251 iwp->length += essid_compat;
92252 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
92253 index ea970b8..c68edb9f 100644
92254 --- a/net/xfrm/xfrm_policy.c
92255 +++ b/net/xfrm/xfrm_policy.c
92256 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
92257 {
92258 policy->walk.dead = 1;
92259
92260 - atomic_inc(&policy->genid);
92261 + atomic_inc_unchecked(&policy->genid);
92262
92263 del_timer(&policy->polq.hold_timer);
92264 xfrm_queue_purge(&policy->polq.hold_queue);
92265 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
92266 hlist_add_head(&policy->bydst, chain);
92267 xfrm_pol_hold(policy);
92268 net->xfrm.policy_count[dir]++;
92269 - atomic_inc(&flow_cache_genid);
92270 + atomic_inc_unchecked(&flow_cache_genid);
92271 rt_genid_bump(net);
92272 if (delpol) {
92273 xfrm_policy_requeue(delpol, policy);
92274 @@ -1629,7 +1629,7 @@ free_dst:
92275 goto out;
92276 }
92277
92278 -static int inline
92279 +static inline int
92280 xfrm_dst_alloc_copy(void **target, const void *src, int size)
92281 {
92282 if (!*target) {
92283 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
92284 return 0;
92285 }
92286
92287 -static int inline
92288 +static inline int
92289 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
92290 {
92291 #ifdef CONFIG_XFRM_SUB_POLICY
92292 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
92293 #endif
92294 }
92295
92296 -static int inline
92297 +static inline int
92298 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
92299 {
92300 #ifdef CONFIG_XFRM_SUB_POLICY
92301 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
92302
92303 xdst->num_pols = num_pols;
92304 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
92305 - xdst->policy_genid = atomic_read(&pols[0]->genid);
92306 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
92307
92308 return xdst;
92309 }
92310 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
92311 if (xdst->xfrm_genid != dst->xfrm->genid)
92312 return 0;
92313 if (xdst->num_pols > 0 &&
92314 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
92315 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
92316 return 0;
92317
92318 mtu = dst_mtu(dst->child);
92319 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
92320 dst_ops->link_failure = xfrm_link_failure;
92321 if (likely(dst_ops->neigh_lookup == NULL))
92322 dst_ops->neigh_lookup = xfrm_neigh_lookup;
92323 - if (likely(afinfo->garbage_collect == NULL))
92324 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
92325 + if (likely(afinfo->garbage_collect == NULL)) {
92326 + pax_open_kernel();
92327 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
92328 + pax_close_kernel();
92329 + }
92330 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
92331 }
92332 spin_unlock(&xfrm_policy_afinfo_lock);
92333 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
92334 dst_ops->check = NULL;
92335 dst_ops->negative_advice = NULL;
92336 dst_ops->link_failure = NULL;
92337 - afinfo->garbage_collect = NULL;
92338 + pax_open_kernel();
92339 + *(void **)&afinfo->garbage_collect = NULL;
92340 + pax_close_kernel();
92341 }
92342 return err;
92343 }
92344 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
92345 sizeof(pol->xfrm_vec[i].saddr));
92346 pol->xfrm_vec[i].encap_family = mp->new_family;
92347 /* flush bundles */
92348 - atomic_inc(&pol->genid);
92349 + atomic_inc_unchecked(&pol->genid);
92350 }
92351 }
92352
92353 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
92354 index 78f66fa..9286768 100644
92355 --- a/net/xfrm/xfrm_state.c
92356 +++ b/net/xfrm/xfrm_state.c
92357 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
92358
92359 if (unlikely(afinfo == NULL))
92360 return -EAFNOSUPPORT;
92361 - typemap = afinfo->type_map;
92362 + typemap = (const struct xfrm_type **)afinfo->type_map;
92363 spin_lock_bh(&xfrm_type_lock);
92364
92365 - if (likely(typemap[type->proto] == NULL))
92366 + if (likely(typemap[type->proto] == NULL)) {
92367 + pax_open_kernel();
92368 typemap[type->proto] = type;
92369 - else
92370 + pax_close_kernel();
92371 + } else
92372 err = -EEXIST;
92373 spin_unlock_bh(&xfrm_type_lock);
92374 xfrm_state_put_afinfo(afinfo);
92375 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
92376
92377 if (unlikely(afinfo == NULL))
92378 return -EAFNOSUPPORT;
92379 - typemap = afinfo->type_map;
92380 + typemap = (const struct xfrm_type **)afinfo->type_map;
92381 spin_lock_bh(&xfrm_type_lock);
92382
92383 if (unlikely(typemap[type->proto] != type))
92384 err = -ENOENT;
92385 - else
92386 + else {
92387 + pax_open_kernel();
92388 typemap[type->proto] = NULL;
92389 + pax_close_kernel();
92390 + }
92391 spin_unlock_bh(&xfrm_type_lock);
92392 xfrm_state_put_afinfo(afinfo);
92393 return err;
92394 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
92395 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
92396 {
92397 struct xfrm_state_afinfo *afinfo;
92398 - const struct xfrm_type **typemap;
92399 const struct xfrm_type *type;
92400 int modload_attempted = 0;
92401
92402 @@ -222,9 +226,8 @@ retry:
92403 afinfo = xfrm_state_get_afinfo(family);
92404 if (unlikely(afinfo == NULL))
92405 return NULL;
92406 - typemap = afinfo->type_map;
92407
92408 - type = typemap[proto];
92409 + type = afinfo->type_map[proto];
92410 if (unlikely(type && !try_module_get(type->owner)))
92411 type = NULL;
92412 if (!type && !modload_attempted) {
92413 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
92414 return -EAFNOSUPPORT;
92415
92416 err = -EEXIST;
92417 - modemap = afinfo->mode_map;
92418 + modemap = (struct xfrm_mode **)afinfo->mode_map;
92419 spin_lock_bh(&xfrm_mode_lock);
92420 if (modemap[mode->encap])
92421 goto out;
92422 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
92423 if (!try_module_get(afinfo->owner))
92424 goto out;
92425
92426 - mode->afinfo = afinfo;
92427 + pax_open_kernel();
92428 + *(const void **)&mode->afinfo = afinfo;
92429 modemap[mode->encap] = mode;
92430 + pax_close_kernel();
92431 err = 0;
92432
92433 out:
92434 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
92435 return -EAFNOSUPPORT;
92436
92437 err = -ENOENT;
92438 - modemap = afinfo->mode_map;
92439 + modemap = (struct xfrm_mode **)afinfo->mode_map;
92440 spin_lock_bh(&xfrm_mode_lock);
92441 if (likely(modemap[mode->encap] == mode)) {
92442 + pax_open_kernel();
92443 modemap[mode->encap] = NULL;
92444 + pax_close_kernel();
92445 module_put(mode->afinfo->owner);
92446 err = 0;
92447 }
92448 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
92449 index 05a6e3d..6716ec9 100644
92450 --- a/net/xfrm/xfrm_sysctl.c
92451 +++ b/net/xfrm/xfrm_sysctl.c
92452 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
92453
92454 int __net_init xfrm_sysctl_init(struct net *net)
92455 {
92456 - struct ctl_table *table;
92457 + ctl_table_no_const *table;
92458
92459 __xfrm_sysctl_init(net);
92460
92461 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
92462 index d5d859c..781cbcb 100644
92463 --- a/scripts/Makefile.build
92464 +++ b/scripts/Makefile.build
92465 @@ -111,7 +111,7 @@ endif
92466 endif
92467
92468 # Do not include host rules unless needed
92469 -ifneq ($(hostprogs-y)$(hostprogs-m),)
92470 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
92471 include scripts/Makefile.host
92472 endif
92473
92474 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
92475 index 686cb0d..9d653bf 100644
92476 --- a/scripts/Makefile.clean
92477 +++ b/scripts/Makefile.clean
92478 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
92479 __clean-files := $(extra-y) $(always) \
92480 $(targets) $(clean-files) \
92481 $(host-progs) \
92482 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
92483 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
92484 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
92485
92486 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
92487
92488 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
92489 index 1ac414f..38575f7 100644
92490 --- a/scripts/Makefile.host
92491 +++ b/scripts/Makefile.host
92492 @@ -31,6 +31,8 @@
92493 # Note: Shared libraries consisting of C++ files are not supported
92494
92495 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
92496 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
92497 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
92498
92499 # C code
92500 # Executables compiled from a single .c file
92501 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
92502 # Shared libaries (only .c supported)
92503 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
92504 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
92505 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
92506 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
92507 # Remove .so files from "xxx-objs"
92508 host-cobjs := $(filter-out %.so,$(host-cobjs))
92509 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
92510
92511 -#Object (.o) files used by the shared libaries
92512 +# Object (.o) files used by the shared libaries
92513 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
92514 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
92515
92516 # output directory for programs/.o files
92517 # hostprogs-y := tools/build may have been specified. Retrieve directory
92518 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
92519 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
92520 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
92521 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
92522 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
92523 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
92524 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
92525 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
92526
92527 obj-dirs += $(host-objdirs)
92528 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
92529 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
92530 $(call if_changed_dep,host-cshobjs)
92531
92532 +# Compile .c file, create position independent .o file
92533 +# host-cxxshobjs -> .o
92534 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
92535 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
92536 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
92537 + $(call if_changed_dep,host-cxxshobjs)
92538 +
92539 # Link a shared library, based on position independent .o files
92540 # *.o -> .so shared library (host-cshlib)
92541 quiet_cmd_host-cshlib = HOSTLLD -shared $@
92542 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
92543 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
92544 $(call if_changed,host-cshlib)
92545
92546 +# Link a shared library, based on position independent .o files
92547 +# *.o -> .so shared library (host-cxxshlib)
92548 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
92549 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
92550 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
92551 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
92552 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
92553 + $(call if_changed,host-cxxshlib)
92554 +
92555 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
92556 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
92557 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
92558
92559 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
92560 index 078fe1d..fbdb363 100644
92561 --- a/scripts/basic/fixdep.c
92562 +++ b/scripts/basic/fixdep.c
92563 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
92564 /*
92565 * Lookup a value in the configuration string.
92566 */
92567 -static int is_defined_config(const char *name, int len, unsigned int hash)
92568 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
92569 {
92570 struct item *aux;
92571
92572 @@ -211,10 +211,10 @@ static void clear_config(void)
92573 /*
92574 * Record the use of a CONFIG_* word.
92575 */
92576 -static void use_config(const char *m, int slen)
92577 +static void use_config(const char *m, unsigned int slen)
92578 {
92579 unsigned int hash = strhash(m, slen);
92580 - int c, i;
92581 + unsigned int c, i;
92582
92583 if (is_defined_config(m, slen, hash))
92584 return;
92585 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
92586
92587 static void parse_config_file(const char *map, size_t len)
92588 {
92589 - const int *end = (const int *) (map + len);
92590 + const unsigned int *end = (const unsigned int *) (map + len);
92591 /* start at +1, so that p can never be < map */
92592 - const int *m = (const int *) map + 1;
92593 + const unsigned int *m = (const unsigned int *) map + 1;
92594 const char *p, *q;
92595
92596 for (; m < end; m++) {
92597 @@ -435,7 +435,7 @@ static void print_deps(void)
92598 static void traps(void)
92599 {
92600 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
92601 - int *p = (int *)test;
92602 + unsigned int *p = (unsigned int *)test;
92603
92604 if (*p != INT_CONF) {
92605 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
92606 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
92607 new file mode 100644
92608 index 0000000..5e0222d
92609 --- /dev/null
92610 +++ b/scripts/gcc-plugin.sh
92611 @@ -0,0 +1,17 @@
92612 +#!/bin/bash
92613 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
92614 +#include "gcc-plugin.h"
92615 +#include "tree.h"
92616 +#include "tm.h"
92617 +#include "rtl.h"
92618 +#ifdef ENABLE_BUILD_WITH_CXX
92619 +#warning $2
92620 +#else
92621 +#warning $1
92622 +#endif
92623 +EOF`
92624 +if [ $? -eq 0 ]
92625 +then
92626 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
92627 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
92628 +fi
92629 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
92630 index 643764f..6cc0137 100644
92631 --- a/scripts/headers_install.sh
92632 +++ b/scripts/headers_install.sh
92633 @@ -29,6 +29,7 @@ do
92634 FILE="$(basename "$i")"
92635 sed -r \
92636 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
92637 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
92638 -e 's/__attribute_const__([ \t]|$)/\1/g' \
92639 -e 's@^#include <linux/compiler.h>@@' \
92640 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
92641 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
92642 index 0149949..d482a0d 100644
92643 --- a/scripts/link-vmlinux.sh
92644 +++ b/scripts/link-vmlinux.sh
92645 @@ -158,7 +158,7 @@ else
92646 fi;
92647
92648 # final build of init/
92649 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
92650 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
92651
92652 kallsymso=""
92653 kallsyms_vmlinux=""
92654 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
92655 index 45f9a33..e4194b3 100644
92656 --- a/scripts/mod/file2alias.c
92657 +++ b/scripts/mod/file2alias.c
92658 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
92659 unsigned long size, unsigned long id_size,
92660 void *symval)
92661 {
92662 - int i;
92663 + unsigned int i;
92664
92665 if (size % id_size || size < id_size) {
92666 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
92667 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
92668 /* USB is special because the bcdDevice can be matched against a numeric range */
92669 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
92670 static void do_usb_entry(void *symval,
92671 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
92672 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
92673 unsigned char range_lo, unsigned char range_hi,
92674 unsigned char max, struct module *mod)
92675 {
92676 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
92677 {
92678 unsigned int devlo, devhi;
92679 unsigned char chi, clo, max;
92680 - int ndigits;
92681 + unsigned int ndigits;
92682
92683 DEF_FIELD(symval, usb_device_id, match_flags);
92684 DEF_FIELD(symval, usb_device_id, idVendor);
92685 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
92686 for (i = 0; i < count; i++) {
92687 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
92688 char acpi_id[sizeof(*id)];
92689 - int j;
92690 + unsigned int j;
92691
92692 buf_printf(&mod->dev_table_buf,
92693 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
92694 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
92695
92696 for (j = 0; j < PNP_MAX_DEVICES; j++) {
92697 const char *id = (char *)(*devs)[j].id;
92698 - int i2, j2;
92699 + unsigned int i2, j2;
92700 int dup = 0;
92701
92702 if (!id[0])
92703 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
92704 /* add an individual alias for every device entry */
92705 if (!dup) {
92706 char acpi_id[PNP_ID_LEN];
92707 - int k;
92708 + unsigned int k;
92709
92710 buf_printf(&mod->dev_table_buf,
92711 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
92712 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
92713 static int do_dmi_entry(const char *filename, void *symval,
92714 char *alias)
92715 {
92716 - int i, j;
92717 + unsigned int i, j;
92718 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
92719 sprintf(alias, "dmi*");
92720
92721 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
92722 index a4be8e1..6e8a5fb 100644
92723 --- a/scripts/mod/modpost.c
92724 +++ b/scripts/mod/modpost.c
92725 @@ -933,6 +933,7 @@ enum mismatch {
92726 ANY_INIT_TO_ANY_EXIT,
92727 ANY_EXIT_TO_ANY_INIT,
92728 EXPORT_TO_INIT_EXIT,
92729 + DATA_TO_TEXT
92730 };
92731
92732 struct sectioncheck {
92733 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
92734 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
92735 .mismatch = EXPORT_TO_INIT_EXIT,
92736 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
92737 +},
92738 +/* Do not reference code from writable data */
92739 +{
92740 + .fromsec = { DATA_SECTIONS, NULL },
92741 + .tosec = { TEXT_SECTIONS, NULL },
92742 + .mismatch = DATA_TO_TEXT
92743 }
92744 };
92745
92746 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
92747 continue;
92748 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
92749 continue;
92750 - if (sym->st_value == addr)
92751 - return sym;
92752 /* Find a symbol nearby - addr are maybe negative */
92753 d = sym->st_value - addr;
92754 + if (d == 0)
92755 + return sym;
92756 if (d < 0)
92757 d = addr - sym->st_value;
92758 if (d < distance) {
92759 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
92760 tosym, prl_to, prl_to, tosym);
92761 free(prl_to);
92762 break;
92763 + case DATA_TO_TEXT:
92764 +#if 0
92765 + fprintf(stderr,
92766 + "The %s %s:%s references\n"
92767 + "the %s %s:%s%s\n",
92768 + from, fromsec, fromsym, to, tosec, tosym, to_p);
92769 +#endif
92770 + break;
92771 }
92772 fprintf(stderr, "\n");
92773 }
92774 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
92775 static void check_sec_ref(struct module *mod, const char *modname,
92776 struct elf_info *elf)
92777 {
92778 - int i;
92779 + unsigned int i;
92780 Elf_Shdr *sechdrs = elf->sechdrs;
92781
92782 /* Walk through all sections */
92783 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
92784 va_end(ap);
92785 }
92786
92787 -void buf_write(struct buffer *buf, const char *s, int len)
92788 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
92789 {
92790 if (buf->size - buf->pos < len) {
92791 buf->size += len + SZ;
92792 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
92793 if (fstat(fileno(file), &st) < 0)
92794 goto close_write;
92795
92796 - if (st.st_size != b->pos)
92797 + if (st.st_size != (off_t)b->pos)
92798 goto close_write;
92799
92800 tmp = NOFAIL(malloc(b->pos));
92801 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
92802 index 51207e4..f7d603d 100644
92803 --- a/scripts/mod/modpost.h
92804 +++ b/scripts/mod/modpost.h
92805 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
92806
92807 struct buffer {
92808 char *p;
92809 - int pos;
92810 - int size;
92811 + unsigned int pos;
92812 + unsigned int size;
92813 };
92814
92815 void __attribute__((format(printf, 2, 3)))
92816 buf_printf(struct buffer *buf, const char *fmt, ...);
92817
92818 void
92819 -buf_write(struct buffer *buf, const char *s, int len);
92820 +buf_write(struct buffer *buf, const char *s, unsigned int len);
92821
92822 struct module {
92823 struct module *next;
92824 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
92825 index 9dfcd6d..099068e 100644
92826 --- a/scripts/mod/sumversion.c
92827 +++ b/scripts/mod/sumversion.c
92828 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
92829 goto out;
92830 }
92831
92832 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
92833 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
92834 warn("writing sum in %s failed: %s\n",
92835 filename, strerror(errno));
92836 goto out;
92837 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
92838 index acb8650..b8c5f02 100644
92839 --- a/scripts/package/builddeb
92840 +++ b/scripts/package/builddeb
92841 @@ -246,6 +246,7 @@ fi
92842 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
92843 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
92844 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
92845 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
92846 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
92847 mkdir -p "$destdir"
92848 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
92849 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
92850 index 68bb4ef..2f419e1 100644
92851 --- a/scripts/pnmtologo.c
92852 +++ b/scripts/pnmtologo.c
92853 @@ -244,14 +244,14 @@ static void write_header(void)
92854 fprintf(out, " * Linux logo %s\n", logoname);
92855 fputs(" */\n\n", out);
92856 fputs("#include <linux/linux_logo.h>\n\n", out);
92857 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
92858 + fprintf(out, "static unsigned char %s_data[] = {\n",
92859 logoname);
92860 }
92861
92862 static void write_footer(void)
92863 {
92864 fputs("\n};\n\n", out);
92865 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
92866 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
92867 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
92868 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
92869 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
92870 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
92871 fputs("\n};\n\n", out);
92872
92873 /* write logo clut */
92874 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
92875 + fprintf(out, "static unsigned char %s_clut[] = {\n",
92876 logoname);
92877 write_hex_cnt = 0;
92878 for (i = 0; i < logo_clutsize; i++) {
92879 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
92880 index f5eb43d..1814de8 100644
92881 --- a/scripts/sortextable.h
92882 +++ b/scripts/sortextable.h
92883 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
92884 const char *secstrtab;
92885 const char *strtab;
92886 char *extab_image;
92887 - int extab_index = 0;
92888 - int i;
92889 - int idx;
92890 + unsigned int extab_index = 0;
92891 + unsigned int i;
92892 + unsigned int idx;
92893
92894 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
92895 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
92896 diff --git a/security/Kconfig b/security/Kconfig
92897 index e9c6ac7..0d298ea 100644
92898 --- a/security/Kconfig
92899 +++ b/security/Kconfig
92900 @@ -4,6 +4,956 @@
92901
92902 menu "Security options"
92903
92904 +menu "Grsecurity"
92905 +
92906 + config ARCH_TRACK_EXEC_LIMIT
92907 + bool
92908 +
92909 + config PAX_KERNEXEC_PLUGIN
92910 + bool
92911 +
92912 + config PAX_PER_CPU_PGD
92913 + bool
92914 +
92915 + config TASK_SIZE_MAX_SHIFT
92916 + int
92917 + depends on X86_64
92918 + default 47 if !PAX_PER_CPU_PGD
92919 + default 42 if PAX_PER_CPU_PGD
92920 +
92921 + config PAX_ENABLE_PAE
92922 + bool
92923 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
92924 +
92925 + config PAX_USERCOPY_SLABS
92926 + bool
92927 +
92928 +config GRKERNSEC
92929 + bool "Grsecurity"
92930 + select CRYPTO
92931 + select CRYPTO_SHA256
92932 + select PROC_FS
92933 + select STOP_MACHINE
92934 + select TTY
92935 + help
92936 + If you say Y here, you will be able to configure many features
92937 + that will enhance the security of your system. It is highly
92938 + recommended that you say Y here and read through the help
92939 + for each option so that you fully understand the features and
92940 + can evaluate their usefulness for your machine.
92941 +
92942 +choice
92943 + prompt "Configuration Method"
92944 + depends on GRKERNSEC
92945 + default GRKERNSEC_CONFIG_CUSTOM
92946 + help
92947 +
92948 +config GRKERNSEC_CONFIG_AUTO
92949 + bool "Automatic"
92950 + help
92951 + If you choose this configuration method, you'll be able to answer a small
92952 + number of simple questions about how you plan to use this kernel.
92953 + The settings of grsecurity and PaX will be automatically configured for
92954 + the highest commonly-used settings within the provided constraints.
92955 +
92956 + If you require additional configuration, custom changes can still be made
92957 + from the "custom configuration" menu.
92958 +
92959 +config GRKERNSEC_CONFIG_CUSTOM
92960 + bool "Custom"
92961 + help
92962 + If you choose this configuration method, you'll be able to configure all
92963 + grsecurity and PaX settings manually. Via this method, no options are
92964 + automatically enabled.
92965 +
92966 +endchoice
92967 +
92968 +choice
92969 + prompt "Usage Type"
92970 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92971 + default GRKERNSEC_CONFIG_SERVER
92972 + help
92973 +
92974 +config GRKERNSEC_CONFIG_SERVER
92975 + bool "Server"
92976 + help
92977 + Choose this option if you plan to use this kernel on a server.
92978 +
92979 +config GRKERNSEC_CONFIG_DESKTOP
92980 + bool "Desktop"
92981 + help
92982 + Choose this option if you plan to use this kernel on a desktop.
92983 +
92984 +endchoice
92985 +
92986 +choice
92987 + prompt "Virtualization Type"
92988 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
92989 + default GRKERNSEC_CONFIG_VIRT_NONE
92990 + help
92991 +
92992 +config GRKERNSEC_CONFIG_VIRT_NONE
92993 + bool "None"
92994 + help
92995 + Choose this option if this kernel will be run on bare metal.
92996 +
92997 +config GRKERNSEC_CONFIG_VIRT_GUEST
92998 + bool "Guest"
92999 + help
93000 + Choose this option if this kernel will be run as a VM guest.
93001 +
93002 +config GRKERNSEC_CONFIG_VIRT_HOST
93003 + bool "Host"
93004 + help
93005 + Choose this option if this kernel will be run as a VM host.
93006 +
93007 +endchoice
93008 +
93009 +choice
93010 + prompt "Virtualization Hardware"
93011 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
93012 + help
93013 +
93014 +config GRKERNSEC_CONFIG_VIRT_EPT
93015 + bool "EPT/RVI Processor Support"
93016 + depends on X86
93017 + help
93018 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
93019 + hardware virtualization. This allows for additional kernel hardening protections
93020 + to operate without additional performance impact.
93021 +
93022 + To see if your Intel processor supports EPT, see:
93023 + http://ark.intel.com/Products/VirtualizationTechnology
93024 + (Most Core i3/5/7 support EPT)
93025 +
93026 + To see if your AMD processor supports RVI, see:
93027 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
93028 +
93029 +config GRKERNSEC_CONFIG_VIRT_SOFT
93030 + bool "First-gen/No Hardware Virtualization"
93031 + help
93032 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
93033 + support hardware virtualization or doesn't support the EPT/RVI extensions.
93034 +
93035 +endchoice
93036 +
93037 +choice
93038 + prompt "Virtualization Software"
93039 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
93040 + help
93041 +
93042 +config GRKERNSEC_CONFIG_VIRT_XEN
93043 + bool "Xen"
93044 + help
93045 + Choose this option if this kernel is running as a Xen guest or host.
93046 +
93047 +config GRKERNSEC_CONFIG_VIRT_VMWARE
93048 + bool "VMWare"
93049 + help
93050 + Choose this option if this kernel is running as a VMWare guest or host.
93051 +
93052 +config GRKERNSEC_CONFIG_VIRT_KVM
93053 + bool "KVM"
93054 + help
93055 + Choose this option if this kernel is running as a KVM guest or host.
93056 +
93057 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
93058 + bool "VirtualBox"
93059 + help
93060 + Choose this option if this kernel is running as a VirtualBox guest or host.
93061 +
93062 +endchoice
93063 +
93064 +choice
93065 + prompt "Required Priorities"
93066 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
93067 + default GRKERNSEC_CONFIG_PRIORITY_PERF
93068 + help
93069 +
93070 +config GRKERNSEC_CONFIG_PRIORITY_PERF
93071 + bool "Performance"
93072 + help
93073 + Choose this option if performance is of highest priority for this deployment
93074 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
93075 + clearing of structures intended for userland, and freed memory sanitizing will
93076 + be disabled.
93077 +
93078 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
93079 + bool "Security"
93080 + help
93081 + Choose this option if security is of highest priority for this deployment of
93082 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
93083 + for userland, and freed memory sanitizing will be enabled for this kernel.
93084 + In a worst-case scenario, these features can introduce a 20% performance hit
93085 + (UDEREF on x64 contributing half of this hit).
93086 +
93087 +endchoice
93088 +
93089 +menu "Default Special Groups"
93090 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
93091 +
93092 +config GRKERNSEC_PROC_GID
93093 + int "GID exempted from /proc restrictions"
93094 + default 1001
93095 + help
93096 + Setting this GID determines which group will be exempted from
93097 + grsecurity's /proc restrictions, allowing users of the specified
93098 + group to view network statistics and the existence of other users'
93099 + processes on the system. This GID may also be chosen at boot time
93100 + via "grsec_proc_gid=" on the kernel commandline.
93101 +
93102 +config GRKERNSEC_TPE_UNTRUSTED_GID
93103 + int "GID for TPE-untrusted users"
93104 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
93105 + default 1005
93106 + help
93107 + Setting this GID determines which group untrusted users should
93108 + be added to. These users will be placed under grsecurity's Trusted Path
93109 + Execution mechanism, preventing them from executing their own binaries.
93110 + The users will only be able to execute binaries in directories owned and
93111 + writable only by the root user. If the sysctl option is enabled, a sysctl
93112 + option with name "tpe_gid" is created.
93113 +
93114 +config GRKERNSEC_TPE_TRUSTED_GID
93115 + int "GID for TPE-trusted users"
93116 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
93117 + default 1005
93118 + help
93119 + Setting this GID determines what group TPE restrictions will be
93120 + *disabled* for. If the sysctl option is enabled, a sysctl option
93121 + with name "tpe_gid" is created.
93122 +
93123 +config GRKERNSEC_SYMLINKOWN_GID
93124 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
93125 + depends on GRKERNSEC_CONFIG_SERVER
93126 + default 1006
93127 + help
93128 + Setting this GID determines what group kernel-enforced
93129 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
93130 + is enabled, a sysctl option with name "symlinkown_gid" is created.
93131 +
93132 +
93133 +endmenu
93134 +
93135 +menu "Customize Configuration"
93136 +depends on GRKERNSEC
93137 +
93138 +menu "PaX"
93139 +
93140 +config PAX
93141 + bool "Enable various PaX features"
93142 + default y if GRKERNSEC_CONFIG_AUTO
93143 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
93144 + help
93145 + This allows you to enable various PaX features. PaX adds
93146 + intrusion prevention mechanisms to the kernel that reduce
93147 + the risks posed by exploitable memory corruption bugs.
93148 +
93149 +menu "PaX Control"
93150 + depends on PAX
93151 +
93152 +config PAX_SOFTMODE
93153 + bool 'Support soft mode'
93154 + help
93155 + Enabling this option will allow you to run PaX in soft mode, that
93156 + is, PaX features will not be enforced by default, only on executables
93157 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
93158 + support as they are the only way to mark executables for soft mode use.
93159 +
93160 + Soft mode can be activated by using the "pax_softmode=1" kernel command
93161 + line option on boot. Furthermore you can control various PaX features
93162 + at runtime via the entries in /proc/sys/kernel/pax.
93163 +
93164 +config PAX_EI_PAX
93165 + bool 'Use legacy ELF header marking'
93166 + default y if GRKERNSEC_CONFIG_AUTO
93167 + help
93168 + Enabling this option will allow you to control PaX features on
93169 + a per executable basis via the 'chpax' utility available at
93170 + http://pax.grsecurity.net/. The control flags will be read from
93171 + an otherwise reserved part of the ELF header. This marking has
93172 + numerous drawbacks (no support for soft-mode, toolchain does not
93173 + know about the non-standard use of the ELF header) therefore it
93174 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
93175 + support.
93176 +
93177 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
93178 + support as well, they will override the legacy EI_PAX marks.
93179 +
93180 + If you enable none of the marking options then all applications
93181 + will run with PaX enabled on them by default.
93182 +
93183 +config PAX_PT_PAX_FLAGS
93184 + bool 'Use ELF program header marking'
93185 + default y if GRKERNSEC_CONFIG_AUTO
93186 + help
93187 + Enabling this option will allow you to control PaX features on
93188 + a per executable basis via the 'paxctl' utility available at
93189 + http://pax.grsecurity.net/. The control flags will be read from
93190 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
93191 + has the benefits of supporting both soft mode and being fully
93192 + integrated into the toolchain (the binutils patch is available
93193 + from http://pax.grsecurity.net).
93194 +
93195 + Note that if you enable the legacy EI_PAX marking support as well,
93196 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
93197 +
93198 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
93199 + must make sure that the marks are the same if a binary has both marks.
93200 +
93201 + If you enable none of the marking options then all applications
93202 + will run with PaX enabled on them by default.
93203 +
93204 +config PAX_XATTR_PAX_FLAGS
93205 + bool 'Use filesystem extended attributes marking'
93206 + default y if GRKERNSEC_CONFIG_AUTO
93207 + select CIFS_XATTR if CIFS
93208 + select EXT2_FS_XATTR if EXT2_FS
93209 + select EXT3_FS_XATTR if EXT3_FS
93210 + select EXT4_FS_XATTR if EXT4_FS
93211 + select JFFS2_FS_XATTR if JFFS2_FS
93212 + select REISERFS_FS_XATTR if REISERFS_FS
93213 + select SQUASHFS_XATTR if SQUASHFS
93214 + select TMPFS_XATTR if TMPFS
93215 + select UBIFS_FS_XATTR if UBIFS_FS
93216 + help
93217 + Enabling this option will allow you to control PaX features on
93218 + a per executable basis via the 'setfattr' utility. The control
93219 + flags will be read from the user.pax.flags extended attribute of
93220 + the file. This marking has the benefit of supporting binary-only
93221 + applications that self-check themselves (e.g., skype) and would
93222 + not tolerate chpax/paxctl changes. The main drawback is that
93223 + extended attributes are not supported by some filesystems (e.g.,
93224 + isofs, udf, vfat) so copying files through such filesystems will
93225 + lose the extended attributes and these PaX markings.
93226 +
93227 + Note that if you enable the legacy EI_PAX marking support as well,
93228 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
93229 +
93230 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
93231 + must make sure that the marks are the same if a binary has both marks.
93232 +
93233 + If you enable none of the marking options then all applications
93234 + will run with PaX enabled on them by default.
93235 +
93236 +choice
93237 + prompt 'MAC system integration'
93238 + default PAX_HAVE_ACL_FLAGS
93239 + help
93240 + Mandatory Access Control systems have the option of controlling
93241 + PaX flags on a per executable basis, choose the method supported
93242 + by your particular system.
93243 +
93244 + - "none": if your MAC system does not interact with PaX,
93245 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
93246 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
93247 +
93248 + NOTE: this option is for developers/integrators only.
93249 +
93250 + config PAX_NO_ACL_FLAGS
93251 + bool 'none'
93252 +
93253 + config PAX_HAVE_ACL_FLAGS
93254 + bool 'direct'
93255 +
93256 + config PAX_HOOK_ACL_FLAGS
93257 + bool 'hook'
93258 +endchoice
93259 +
93260 +endmenu
93261 +
93262 +menu "Non-executable pages"
93263 + depends on PAX
93264 +
93265 +config PAX_NOEXEC
93266 + bool "Enforce non-executable pages"
93267 + default y if GRKERNSEC_CONFIG_AUTO
93268 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
93269 + help
93270 + By design some architectures do not allow for protecting memory
93271 + pages against execution or even if they do, Linux does not make
93272 + use of this feature. In practice this means that if a page is
93273 + readable (such as the stack or heap) it is also executable.
93274 +
93275 + There is a well known exploit technique that makes use of this
93276 + fact and a common programming mistake where an attacker can
93277 + introduce code of his choice somewhere in the attacked program's
93278 + memory (typically the stack or the heap) and then execute it.
93279 +
93280 + If the attacked program was running with different (typically
93281 + higher) privileges than that of the attacker, then he can elevate
93282 + his own privilege level (e.g. get a root shell, write to files for
93283 + which he does not have write access to, etc).
93284 +
93285 + Enabling this option will let you choose from various features
93286 + that prevent the injection and execution of 'foreign' code in
93287 + a program.
93288 +
93289 + This will also break programs that rely on the old behaviour and
93290 + expect that dynamically allocated memory via the malloc() family
93291 + of functions is executable (which it is not). Notable examples
93292 + are the XFree86 4.x server, the java runtime and wine.
93293 +
93294 +config PAX_PAGEEXEC
93295 + bool "Paging based non-executable pages"
93296 + default y if GRKERNSEC_CONFIG_AUTO
93297 + 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)
93298 + select S390_SWITCH_AMODE if S390
93299 + select S390_EXEC_PROTECT if S390
93300 + select ARCH_TRACK_EXEC_LIMIT if X86_32
93301 + help
93302 + This implementation is based on the paging feature of the CPU.
93303 + On i386 without hardware non-executable bit support there is a
93304 + variable but usually low performance impact, however on Intel's
93305 + P4 core based CPUs it is very high so you should not enable this
93306 + for kernels meant to be used on such CPUs.
93307 +
93308 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
93309 + with hardware non-executable bit support there is no performance
93310 + impact, on ppc the impact is negligible.
93311 +
93312 + Note that several architectures require various emulations due to
93313 + badly designed userland ABIs, this will cause a performance impact
93314 + but will disappear as soon as userland is fixed. For example, ppc
93315 + userland MUST have been built with secure-plt by a recent toolchain.
93316 +
93317 +config PAX_SEGMEXEC
93318 + bool "Segmentation based non-executable pages"
93319 + default y if GRKERNSEC_CONFIG_AUTO
93320 + depends on PAX_NOEXEC && X86_32
93321 + help
93322 + This implementation is based on the segmentation feature of the
93323 + CPU and has a very small performance impact, however applications
93324 + will be limited to a 1.5 GB address space instead of the normal
93325 + 3 GB.
93326 +
93327 +config PAX_EMUTRAMP
93328 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
93329 + default y if PARISC
93330 + help
93331 + There are some programs and libraries that for one reason or
93332 + another attempt to execute special small code snippets from
93333 + non-executable memory pages. Most notable examples are the
93334 + signal handler return code generated by the kernel itself and
93335 + the GCC trampolines.
93336 +
93337 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
93338 + such programs will no longer work under your kernel.
93339 +
93340 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
93341 + utilities to enable trampoline emulation for the affected programs
93342 + yet still have the protection provided by the non-executable pages.
93343 +
93344 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
93345 + your system will not even boot.
93346 +
93347 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
93348 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
93349 + for the affected files.
93350 +
93351 + NOTE: enabling this feature *may* open up a loophole in the
93352 + protection provided by non-executable pages that an attacker
93353 + could abuse. Therefore the best solution is to not have any
93354 + files on your system that would require this option. This can
93355 + be achieved by not using libc5 (which relies on the kernel
93356 + signal handler return code) and not using or rewriting programs
93357 + that make use of the nested function implementation of GCC.
93358 + Skilled users can just fix GCC itself so that it implements
93359 + nested function calls in a way that does not interfere with PaX.
93360 +
93361 +config PAX_EMUSIGRT
93362 + bool "Automatically emulate sigreturn trampolines"
93363 + depends on PAX_EMUTRAMP && PARISC
93364 + default y
93365 + help
93366 + Enabling this option will have the kernel automatically detect
93367 + and emulate signal return trampolines executing on the stack
93368 + that would otherwise lead to task termination.
93369 +
93370 + This solution is intended as a temporary one for users with
93371 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
93372 + Modula-3 runtime, etc) or executables linked to such, basically
93373 + everything that does not specify its own SA_RESTORER function in
93374 + normal executable memory like glibc 2.1+ does.
93375 +
93376 + On parisc you MUST enable this option, otherwise your system will
93377 + not even boot.
93378 +
93379 + NOTE: this feature cannot be disabled on a per executable basis
93380 + and since it *does* open up a loophole in the protection provided
93381 + by non-executable pages, the best solution is to not have any
93382 + files on your system that would require this option.
93383 +
93384 +config PAX_MPROTECT
93385 + bool "Restrict mprotect()"
93386 + default y if GRKERNSEC_CONFIG_AUTO
93387 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
93388 + help
93389 + Enabling this option will prevent programs from
93390 + - changing the executable status of memory pages that were
93391 + not originally created as executable,
93392 + - making read-only executable pages writable again,
93393 + - creating executable pages from anonymous memory,
93394 + - making read-only-after-relocations (RELRO) data pages writable again.
93395 +
93396 + You should say Y here to complete the protection provided by
93397 + the enforcement of non-executable pages.
93398 +
93399 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
93400 + this feature on a per file basis.
93401 +
93402 +config PAX_MPROTECT_COMPAT
93403 + bool "Use legacy/compat protection demoting (read help)"
93404 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
93405 + depends on PAX_MPROTECT
93406 + help
93407 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
93408 + by sending the proper error code to the application. For some broken
93409 + userland, this can cause problems with Python or other applications. The
93410 + current implementation however allows for applications like clamav to
93411 + detect if JIT compilation/execution is allowed and to fall back gracefully
93412 + to an interpreter-based mode if it does not. While we encourage everyone
93413 + to use the current implementation as-is and push upstream to fix broken
93414 + userland (note that the RWX logging option can assist with this), in some
93415 + environments this may not be possible. Having to disable MPROTECT
93416 + completely on certain binaries reduces the security benefit of PaX,
93417 + so this option is provided for those environments to revert to the old
93418 + behavior.
93419 +
93420 +config PAX_ELFRELOCS
93421 + bool "Allow ELF text relocations (read help)"
93422 + depends on PAX_MPROTECT
93423 + default n
93424 + help
93425 + Non-executable pages and mprotect() restrictions are effective
93426 + in preventing the introduction of new executable code into an
93427 + attacked task's address space. There remain only two venues
93428 + for this kind of attack: if the attacker can execute already
93429 + existing code in the attacked task then he can either have it
93430 + create and mmap() a file containing his code or have it mmap()
93431 + an already existing ELF library that does not have position
93432 + independent code in it and use mprotect() on it to make it
93433 + writable and copy his code there. While protecting against
93434 + the former approach is beyond PaX, the latter can be prevented
93435 + by having only PIC ELF libraries on one's system (which do not
93436 + need to relocate their code). If you are sure this is your case,
93437 + as is the case with all modern Linux distributions, then leave
93438 + this option disabled. You should say 'n' here.
93439 +
93440 +config PAX_ETEXECRELOCS
93441 + bool "Allow ELF ET_EXEC text relocations"
93442 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
93443 + select PAX_ELFRELOCS
93444 + default y
93445 + help
93446 + On some architectures there are incorrectly created applications
93447 + that require text relocations and would not work without enabling
93448 + this option. If you are an alpha, ia64 or parisc user, you should
93449 + enable this option and disable it once you have made sure that
93450 + none of your applications need it.
93451 +
93452 +config PAX_EMUPLT
93453 + bool "Automatically emulate ELF PLT"
93454 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
93455 + default y
93456 + help
93457 + Enabling this option will have the kernel automatically detect
93458 + and emulate the Procedure Linkage Table entries in ELF files.
93459 + On some architectures such entries are in writable memory, and
93460 + become non-executable leading to task termination. Therefore
93461 + it is mandatory that you enable this option on alpha, parisc,
93462 + sparc and sparc64, otherwise your system would not even boot.
93463 +
93464 + NOTE: this feature *does* open up a loophole in the protection
93465 + provided by the non-executable pages, therefore the proper
93466 + solution is to modify the toolchain to produce a PLT that does
93467 + not need to be writable.
93468 +
93469 +config PAX_DLRESOLVE
93470 + bool 'Emulate old glibc resolver stub'
93471 + depends on PAX_EMUPLT && SPARC
93472 + default n
93473 + help
93474 + This option is needed if userland has an old glibc (before 2.4)
93475 + that puts a 'save' instruction into the runtime generated resolver
93476 + stub that needs special emulation.
93477 +
93478 +config PAX_KERNEXEC
93479 + bool "Enforce non-executable kernel pages"
93480 + 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))
93481 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
93482 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
93483 + select PAX_KERNEXEC_PLUGIN if X86_64
93484 + help
93485 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
93486 + that is, enabling this option will make it harder to inject
93487 + and execute 'foreign' code in kernel memory itself.
93488 +
93489 +choice
93490 + prompt "Return Address Instrumentation Method"
93491 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
93492 + depends on PAX_KERNEXEC_PLUGIN
93493 + help
93494 + Select the method used to instrument function pointer dereferences.
93495 + Note that binary modules cannot be instrumented by this approach.
93496 +
93497 + Note that the implementation requires a gcc with plugin support,
93498 + i.e., gcc 4.5 or newer. You may need to install the supporting
93499 + headers explicitly in addition to the normal gcc package.
93500 +
93501 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
93502 + bool "bts"
93503 + help
93504 + This method is compatible with binary only modules but has
93505 + a higher runtime overhead.
93506 +
93507 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
93508 + bool "or"
93509 + depends on !PARAVIRT
93510 + help
93511 + This method is incompatible with binary only modules but has
93512 + a lower runtime overhead.
93513 +endchoice
93514 +
93515 +config PAX_KERNEXEC_PLUGIN_METHOD
93516 + string
93517 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
93518 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
93519 + default ""
93520 +
93521 +config PAX_KERNEXEC_MODULE_TEXT
93522 + int "Minimum amount of memory reserved for module code"
93523 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
93524 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
93525 + depends on PAX_KERNEXEC && X86_32
93526 + help
93527 + Due to implementation details the kernel must reserve a fixed
93528 + amount of memory for runtime allocated code (such as modules)
93529 + at compile time that cannot be changed at runtime. Here you
93530 + can specify the minimum amount in MB that will be reserved.
93531 + Due to the same implementation details this size will always
93532 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
93533 + the actually available memory for runtime allocated code will
93534 + usually be more than this minimum.
93535 +
93536 + The default 4 MB should be enough for most users but if you have
93537 + an excessive number of modules (e.g., most distribution configs
93538 + compile many drivers as modules) or use huge modules such as
93539 + nvidia's kernel driver, you will need to adjust this amount.
93540 + A good rule of thumb is to look at your currently loaded kernel
93541 + modules and add up their sizes.
93542 +
93543 +endmenu
93544 +
93545 +menu "Address Space Layout Randomization"
93546 + depends on PAX
93547 +
93548 +config PAX_ASLR
93549 + bool "Address Space Layout Randomization"
93550 + default y if GRKERNSEC_CONFIG_AUTO
93551 + help
93552 + Many if not most exploit techniques rely on the knowledge of
93553 + certain addresses in the attacked program. The following options
93554 + will allow the kernel to apply a certain amount of randomization
93555 + to specific parts of the program thereby forcing an attacker to
93556 + guess them in most cases. Any failed guess will most likely crash
93557 + the attacked program which allows the kernel to detect such attempts
93558 + and react on them. PaX itself provides no reaction mechanisms,
93559 + instead it is strongly encouraged that you make use of Nergal's
93560 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
93561 + (http://www.grsecurity.net/) built-in crash detection features or
93562 + develop one yourself.
93563 +
93564 + By saying Y here you can choose to randomize the following areas:
93565 + - top of the task's kernel stack
93566 + - top of the task's userland stack
93567 + - base address for mmap() requests that do not specify one
93568 + (this includes all libraries)
93569 + - base address of the main executable
93570 +
93571 + It is strongly recommended to say Y here as address space layout
93572 + randomization has negligible impact on performance yet it provides
93573 + a very effective protection.
93574 +
93575 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
93576 + this feature on a per file basis.
93577 +
93578 +config PAX_RANDKSTACK
93579 + bool "Randomize kernel stack base"
93580 + default y if GRKERNSEC_CONFIG_AUTO
93581 + depends on X86_TSC && X86
93582 + help
93583 + By saying Y here the kernel will randomize every task's kernel
93584 + stack on every system call. This will not only force an attacker
93585 + to guess it but also prevent him from making use of possible
93586 + leaked information about it.
93587 +
93588 + Since the kernel stack is a rather scarce resource, randomization
93589 + may cause unexpected stack overflows, therefore you should very
93590 + carefully test your system. Note that once enabled in the kernel
93591 + configuration, this feature cannot be disabled on a per file basis.
93592 +
93593 +config PAX_RANDUSTACK
93594 + bool "Randomize user stack base"
93595 + default y if GRKERNSEC_CONFIG_AUTO
93596 + depends on PAX_ASLR
93597 + help
93598 + By saying Y here the kernel will randomize every task's userland
93599 + stack. The randomization is done in two steps where the second
93600 + one may apply a big amount of shift to the top of the stack and
93601 + cause problems for programs that want to use lots of memory (more
93602 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
93603 + For this reason the second step can be controlled by 'chpax' or
93604 + 'paxctl' on a per file basis.
93605 +
93606 +config PAX_RANDMMAP
93607 + bool "Randomize mmap() base"
93608 + default y if GRKERNSEC_CONFIG_AUTO
93609 + depends on PAX_ASLR
93610 + help
93611 + By saying Y here the kernel will use a randomized base address for
93612 + mmap() requests that do not specify one themselves. As a result
93613 + all dynamically loaded libraries will appear at random addresses
93614 + and therefore be harder to exploit by a technique where an attacker
93615 + attempts to execute library code for his purposes (e.g. spawn a
93616 + shell from an exploited program that is running at an elevated
93617 + privilege level).
93618 +
93619 + Furthermore, if a program is relinked as a dynamic ELF file, its
93620 + base address will be randomized as well, completing the full
93621 + randomization of the address space layout. Attacking such programs
93622 + becomes a guess game. You can find an example of doing this at
93623 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
93624 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
93625 +
93626 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
93627 + feature on a per file basis.
93628 +
93629 +endmenu
93630 +
93631 +menu "Miscellaneous hardening features"
93632 +
93633 +config PAX_MEMORY_SANITIZE
93634 + bool "Sanitize all freed memory"
93635 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
93636 + depends on !HIBERNATION
93637 + help
93638 + By saying Y here the kernel will erase memory pages and slab objects
93639 + as soon as they are freed. This in turn reduces the lifetime of data
93640 + stored in them, making it less likely that sensitive information such
93641 + as passwords, cryptographic secrets, etc stay in memory for too long.
93642 +
93643 + This is especially useful for programs whose runtime is short, long
93644 + lived processes and the kernel itself benefit from this as long as
93645 + they ensure timely freeing of memory that may hold sensitive
93646 + information.
93647 +
93648 + A nice side effect of the sanitization of slab objects is the
93649 + reduction of possible info leaks caused by padding bytes within the
93650 + leaky structures. Use-after-free bugs for structures containing
93651 + pointers can also be detected as dereferencing the sanitized pointer
93652 + will generate an access violation.
93653 +
93654 + The tradeoff is performance impact, on a single CPU system kernel
93655 + compilation sees a 3% slowdown, other systems and workloads may vary
93656 + and you are advised to test this feature on your expected workload
93657 + before deploying it.
93658 +
93659 + To reduce the performance penalty by sanitizing pages only, albeit
93660 + limiting the effectiveness of this feature at the same time, slab
93661 + sanitization can be disabled with the kernel commandline parameter
93662 + "pax_sanitize_slab=0".
93663 +
93664 + Note that this feature does not protect data stored in live pages,
93665 + e.g., process memory swapped to disk may stay there for a long time.
93666 +
93667 +config PAX_MEMORY_STACKLEAK
93668 + bool "Sanitize kernel stack"
93669 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
93670 + depends on X86
93671 + help
93672 + By saying Y here the kernel will erase the kernel stack before it
93673 + returns from a system call. This in turn reduces the information
93674 + that a kernel stack leak bug can reveal.
93675 +
93676 + Note that such a bug can still leak information that was put on
93677 + the stack by the current system call (the one eventually triggering
93678 + the bug) but traces of earlier system calls on the kernel stack
93679 + cannot leak anymore.
93680 +
93681 + The tradeoff is performance impact: on a single CPU system kernel
93682 + compilation sees a 1% slowdown, other systems and workloads may vary
93683 + and you are advised to test this feature on your expected workload
93684 + before deploying it.
93685 +
93686 + Note that the full feature requires a gcc with plugin support,
93687 + i.e., gcc 4.5 or newer. You may need to install the supporting
93688 + headers explicitly in addition to the normal gcc package. Using
93689 + older gcc versions means that functions with large enough stack
93690 + frames may leave uninitialized memory behind that may be exposed
93691 + to a later syscall leaking the stack.
93692 +
93693 +config PAX_MEMORY_STRUCTLEAK
93694 + bool "Forcibly initialize local variables copied to userland"
93695 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
93696 + help
93697 + By saying Y here the kernel will zero initialize some local
93698 + variables that are going to be copied to userland. This in
93699 + turn prevents unintended information leakage from the kernel
93700 + stack should later code forget to explicitly set all parts of
93701 + the copied variable.
93702 +
93703 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
93704 + at a much smaller coverage.
93705 +
93706 + Note that the implementation requires a gcc with plugin support,
93707 + i.e., gcc 4.5 or newer. You may need to install the supporting
93708 + headers explicitly in addition to the normal gcc package.
93709 +
93710 +config PAX_MEMORY_UDEREF
93711 + bool "Prevent invalid userland pointer dereference"
93712 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
93713 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
93714 + select PAX_PER_CPU_PGD if X86_64
93715 + help
93716 + By saying Y here the kernel will be prevented from dereferencing
93717 + userland pointers in contexts where the kernel expects only kernel
93718 + pointers. This is both a useful runtime debugging feature and a
93719 + security measure that prevents exploiting a class of kernel bugs.
93720 +
93721 + The tradeoff is that some virtualization solutions may experience
93722 + a huge slowdown and therefore you should not enable this feature
93723 + for kernels meant to run in such environments. Whether a given VM
93724 + solution is affected or not is best determined by simply trying it
93725 + out, the performance impact will be obvious right on boot as this
93726 + mechanism engages from very early on. A good rule of thumb is that
93727 + VMs running on CPUs without hardware virtualization support (i.e.,
93728 + the majority of IA-32 CPUs) will likely experience the slowdown.
93729 +
93730 +config PAX_REFCOUNT
93731 + bool "Prevent various kernel object reference counter overflows"
93732 + default y if GRKERNSEC_CONFIG_AUTO
93733 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
93734 + help
93735 + By saying Y here the kernel will detect and prevent overflowing
93736 + various (but not all) kinds of object reference counters. Such
93737 + overflows can normally occur due to bugs only and are often, if
93738 + not always, exploitable.
93739 +
93740 + The tradeoff is that data structures protected by an overflowed
93741 + refcount will never be freed and therefore will leak memory. Note
93742 + that this leak also happens even without this protection but in
93743 + that case the overflow can eventually trigger the freeing of the
93744 + data structure while it is still being used elsewhere, resulting
93745 + in the exploitable situation that this feature prevents.
93746 +
93747 + Since this has a negligible performance impact, you should enable
93748 + this feature.
93749 +
93750 +config PAX_CONSTIFY_PLUGIN
93751 + bool "Automatically constify eligible structures"
93752 + default y
93753 + depends on !UML && PAX_KERNEXEC
93754 + help
93755 + By saying Y here the compiler will automatically constify a class
93756 + of types that contain only function pointers. This reduces the
93757 + kernel's attack surface and also produces a better memory layout.
93758 +
93759 + Note that the implementation requires a gcc with plugin support,
93760 + i.e., gcc 4.5 or newer. You may need to install the supporting
93761 + headers explicitly in addition to the normal gcc package.
93762 +
93763 + Note that if some code really has to modify constified variables
93764 + then the source code will have to be patched to allow it. Examples
93765 + can be found in PaX itself (the no_const attribute) and for some
93766 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
93767 +
93768 +config PAX_USERCOPY
93769 + bool "Harden heap object copies between kernel and userland"
93770 + default y if GRKERNSEC_CONFIG_AUTO
93771 + depends on ARM || IA64 || PPC || SPARC || X86
93772 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
93773 + select PAX_USERCOPY_SLABS
93774 + help
93775 + By saying Y here the kernel will enforce the size of heap objects
93776 + when they are copied in either direction between the kernel and
93777 + userland, even if only a part of the heap object is copied.
93778 +
93779 + Specifically, this checking prevents information leaking from the
93780 + kernel heap during kernel to userland copies (if the kernel heap
93781 + object is otherwise fully initialized) and prevents kernel heap
93782 + overflows during userland to kernel copies.
93783 +
93784 + Note that the current implementation provides the strictest bounds
93785 + checks for the SLUB allocator.
93786 +
93787 + Enabling this option also enables per-slab cache protection against
93788 + data in a given cache being copied into/out of via userland
93789 + accessors. Though the whitelist of regions will be reduced over
93790 + time, it notably protects important data structures like task structs.
93791 +
93792 + If frame pointers are enabled on x86, this option will also restrict
93793 + copies into and out of the kernel stack to local variables within a
93794 + single frame.
93795 +
93796 + Since this has a negligible performance impact, you should enable
93797 + this feature.
93798 +
93799 +config PAX_USERCOPY_DEBUG
93800 + bool
93801 + depends on X86 && PAX_USERCOPY
93802 + default n
93803 +
93804 +config PAX_SIZE_OVERFLOW
93805 + bool "Prevent various integer overflows in function size parameters"
93806 + default y if GRKERNSEC_CONFIG_AUTO
93807 + depends on X86
93808 + help
93809 + By saying Y here the kernel recomputes expressions of function
93810 + arguments marked by a size_overflow attribute with double integer
93811 + precision (DImode/TImode for 32/64 bit integer types).
93812 +
93813 + The recomputed argument is checked against TYPE_MAX and an event
93814 + is logged on overflow and the triggering process is killed.
93815 +
93816 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
93817 +
93818 + Note that the implementation requires a gcc with plugin support,
93819 + i.e., gcc 4.5 or newer. You may need to install the supporting
93820 + headers explicitly in addition to the normal gcc package.
93821 +
93822 +config PAX_LATENT_ENTROPY
93823 + bool "Generate some entropy during boot"
93824 + default y if GRKERNSEC_CONFIG_AUTO
93825 + help
93826 + By saying Y here the kernel will instrument early boot code to
93827 + extract some entropy from both original and artificially created
93828 + program state. This will help especially embedded systems where
93829 + there is little 'natural' source of entropy normally. The cost
93830 + is some slowdown of the boot process.
93831 +
93832 + When pax_extra_latent_entropy is passed on the kernel command line,
93833 + entropy will be extracted from up to the first 4GB of RAM while the
93834 + runtime memory allocator is being initialized. This costs even more
93835 + slowdown of the boot process.
93836 +
93837 + Note that the implementation requires a gcc with plugin support,
93838 + i.e., gcc 4.5 or newer. You may need to install the supporting
93839 + headers explicitly in addition to the normal gcc package.
93840 +
93841 + Note that entropy extracted this way is not cryptographically
93842 + secure!
93843 +
93844 +endmenu
93845 +
93846 +endmenu
93847 +
93848 +source grsecurity/Kconfig
93849 +
93850 +endmenu
93851 +
93852 +endmenu
93853 +
93854 source security/keys/Kconfig
93855
93856 config SECURITY_DMESG_RESTRICT
93857 @@ -103,7 +1053,7 @@ config INTEL_TXT
93858 config LSM_MMAP_MIN_ADDR
93859 int "Low address space for LSM to protect from user allocation"
93860 depends on SECURITY && SECURITY_SELINUX
93861 - default 32768 if ARM
93862 + default 32768 if ALPHA || ARM || PARISC || SPARC32
93863 default 65536
93864 help
93865 This is the portion of low virtual memory which should be protected
93866 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
93867 index 9b9013b..51ebf96 100644
93868 --- a/security/apparmor/Kconfig
93869 +++ b/security/apparmor/Kconfig
93870 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
93871 boot.
93872
93873 If you are unsure how to answer this question, answer 1.
93874 +
93875 +config SECURITY_APPARMOR_COMPAT_24
93876 + bool "Enable AppArmor 2.4 compatability"
93877 + depends on SECURITY_APPARMOR
93878 + default y
93879 + help
93880 + This option enables compatability with AppArmor 2.4. It is
93881 + recommended if compatability with older versions of AppArmor
93882 + is desired.
93883 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
93884 index 16c15ec..42b7c9f 100644
93885 --- a/security/apparmor/apparmorfs.c
93886 +++ b/security/apparmor/apparmorfs.c
93887 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
93888 .release = single_release,
93889 };
93890
93891 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
93892 +/**
93893 + * __next_namespace - find the next namespace to list
93894 + * @root: root namespace to stop search at (NOT NULL)
93895 + * @ns: current ns position (NOT NULL)
93896 + *
93897 + * Find the next namespace from @ns under @root and handle all locking needed
93898 + * while switching current namespace.
93899 + *
93900 + * Returns: next namespace or NULL if at last namespace under @root
93901 + * NOTE: will not unlock root->lock
93902 + */
93903 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
93904 + struct aa_namespace *ns)
93905 +{
93906 + struct aa_namespace *parent;
93907 +
93908 + /* is next namespace a child */
93909 + if (!list_empty(&ns->sub_ns)) {
93910 + struct aa_namespace *next;
93911 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
93912 + read_lock(&next->lock);
93913 + return next;
93914 + }
93915 +
93916 + /* check if the next ns is a sibling, parent, gp, .. */
93917 + parent = ns->parent;
93918 + while (parent) {
93919 + read_unlock(&ns->lock);
93920 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
93921 + read_lock(&ns->lock);
93922 + return ns;
93923 + }
93924 + if (parent == root)
93925 + return NULL;
93926 + ns = parent;
93927 + parent = parent->parent;
93928 + }
93929 +
93930 + return NULL;
93931 +}
93932 +
93933 +/**
93934 + * __first_profile - find the first profile in a namespace
93935 + * @root: namespace that is root of profiles being displayed (NOT NULL)
93936 + * @ns: namespace to start in (NOT NULL)
93937 + *
93938 + * Returns: unrefcounted profile or NULL if no profile
93939 + */
93940 +static struct aa_profile *__first_profile(struct aa_namespace *root,
93941 + struct aa_namespace *ns)
93942 +{
93943 + for ( ; ns; ns = __next_namespace(root, ns)) {
93944 + if (!list_empty(&ns->base.profiles))
93945 + return list_first_entry(&ns->base.profiles,
93946 + struct aa_profile, base.list);
93947 + }
93948 + return NULL;
93949 +}
93950 +
93951 +/**
93952 + * __next_profile - step to the next profile in a profile tree
93953 + * @profile: current profile in tree (NOT NULL)
93954 + *
93955 + * Perform a depth first taversal on the profile tree in a namespace
93956 + *
93957 + * Returns: next profile or NULL if done
93958 + * Requires: profile->ns.lock to be held
93959 + */
93960 +static struct aa_profile *__next_profile(struct aa_profile *p)
93961 +{
93962 + struct aa_profile *parent;
93963 + struct aa_namespace *ns = p->ns;
93964 +
93965 + /* is next profile a child */
93966 + if (!list_empty(&p->base.profiles))
93967 + return list_first_entry(&p->base.profiles, typeof(*p),
93968 + base.list);
93969 +
93970 + /* is next profile a sibling, parent sibling, gp, subling, .. */
93971 + parent = p->parent;
93972 + while (parent) {
93973 + list_for_each_entry_continue(p, &parent->base.profiles,
93974 + base.list)
93975 + return p;
93976 + p = parent;
93977 + parent = parent->parent;
93978 + }
93979 +
93980 + /* is next another profile in the namespace */
93981 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
93982 + return p;
93983 +
93984 + return NULL;
93985 +}
93986 +
93987 +/**
93988 + * next_profile - step to the next profile in where ever it may be
93989 + * @root: root namespace (NOT NULL)
93990 + * @profile: current profile (NOT NULL)
93991 + *
93992 + * Returns: next profile or NULL if there isn't one
93993 + */
93994 +static struct aa_profile *next_profile(struct aa_namespace *root,
93995 + struct aa_profile *profile)
93996 +{
93997 + struct aa_profile *next = __next_profile(profile);
93998 + if (next)
93999 + return next;
94000 +
94001 + /* finished all profiles in namespace move to next namespace */
94002 + return __first_profile(root, __next_namespace(root, profile->ns));
94003 +}
94004 +
94005 +/**
94006 + * p_start - start a depth first traversal of profile tree
94007 + * @f: seq_file to fill
94008 + * @pos: current position
94009 + *
94010 + * Returns: first profile under current namespace or NULL if none found
94011 + *
94012 + * acquires first ns->lock
94013 + */
94014 +static void *p_start(struct seq_file *f, loff_t *pos)
94015 + __acquires(root->lock)
94016 +{
94017 + struct aa_profile *profile = NULL;
94018 + struct aa_namespace *root = aa_current_profile()->ns;
94019 + loff_t l = *pos;
94020 + f->private = aa_get_namespace(root);
94021 +
94022 +
94023 + /* find the first profile */
94024 + read_lock(&root->lock);
94025 + profile = __first_profile(root, root);
94026 +
94027 + /* skip to position */
94028 + for (; profile && l > 0; l--)
94029 + profile = next_profile(root, profile);
94030 +
94031 + return profile;
94032 +}
94033 +
94034 +/**
94035 + * p_next - read the next profile entry
94036 + * @f: seq_file to fill
94037 + * @p: profile previously returned
94038 + * @pos: current position
94039 + *
94040 + * Returns: next profile after @p or NULL if none
94041 + *
94042 + * may acquire/release locks in namespace tree as necessary
94043 + */
94044 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
94045 +{
94046 + struct aa_profile *profile = p;
94047 + struct aa_namespace *root = f->private;
94048 + (*pos)++;
94049 +
94050 + return next_profile(root, profile);
94051 +}
94052 +
94053 +/**
94054 + * p_stop - stop depth first traversal
94055 + * @f: seq_file we are filling
94056 + * @p: the last profile writen
94057 + *
94058 + * Release all locking done by p_start/p_next on namespace tree
94059 + */
94060 +static void p_stop(struct seq_file *f, void *p)
94061 + __releases(root->lock)
94062 +{
94063 + struct aa_profile *profile = p;
94064 + struct aa_namespace *root = f->private, *ns;
94065 +
94066 + if (profile) {
94067 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
94068 + read_unlock(&ns->lock);
94069 + }
94070 + read_unlock(&root->lock);
94071 + aa_put_namespace(root);
94072 +}
94073 +
94074 +/**
94075 + * seq_show_profile - show a profile entry
94076 + * @f: seq_file to file
94077 + * @p: current position (profile) (NOT NULL)
94078 + *
94079 + * Returns: error on failure
94080 + */
94081 +static int seq_show_profile(struct seq_file *f, void *p)
94082 +{
94083 + struct aa_profile *profile = (struct aa_profile *)p;
94084 + struct aa_namespace *root = f->private;
94085 +
94086 + if (profile->ns != root)
94087 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
94088 + seq_printf(f, "%s (%s)\n", profile->base.hname,
94089 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
94090 +
94091 + return 0;
94092 +}
94093 +
94094 +static const struct seq_operations aa_fs_profiles_op = {
94095 + .start = p_start,
94096 + .next = p_next,
94097 + .stop = p_stop,
94098 + .show = seq_show_profile,
94099 +};
94100 +
94101 +static int profiles_open(struct inode *inode, struct file *file)
94102 +{
94103 + return seq_open(file, &aa_fs_profiles_op);
94104 +}
94105 +
94106 +static int profiles_release(struct inode *inode, struct file *file)
94107 +{
94108 + return seq_release(inode, file);
94109 +}
94110 +
94111 +const struct file_operations aa_fs_profiles_fops = {
94112 + .open = profiles_open,
94113 + .read = seq_read,
94114 + .llseek = seq_lseek,
94115 + .release = profiles_release,
94116 +};
94117 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
94118 +
94119 /** Base file system setup **/
94120
94121 static struct aa_fs_entry aa_fs_entry_file[] = {
94122 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
94123 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
94124 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
94125 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
94126 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
94127 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
94128 +#endif
94129 AA_FS_DIR("features", aa_fs_entry_features),
94130 { }
94131 };
94132 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
94133 index b21830e..a7d1a17 100644
94134 --- a/security/apparmor/lsm.c
94135 +++ b/security/apparmor/lsm.c
94136 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
94137 return error;
94138 }
94139
94140 -static struct security_operations apparmor_ops = {
94141 +static struct security_operations apparmor_ops __read_only = {
94142 .name = "apparmor",
94143
94144 .ptrace_access_check = apparmor_ptrace_access_check,
94145 diff --git a/security/commoncap.c b/security/commoncap.c
94146 index c44b6fe..932df30 100644
94147 --- a/security/commoncap.c
94148 +++ b/security/commoncap.c
94149 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
94150 return 0;
94151 }
94152
94153 +/* returns:
94154 + 1 for suid privilege
94155 + 2 for sgid privilege
94156 + 3 for fscap privilege
94157 +*/
94158 +int is_privileged_binary(const struct dentry *dentry)
94159 +{
94160 + struct cpu_vfs_cap_data capdata;
94161 + struct inode *inode = dentry->d_inode;
94162 +
94163 + if (!inode || S_ISDIR(inode->i_mode))
94164 + return 0;
94165 +
94166 + if (inode->i_mode & S_ISUID)
94167 + return 1;
94168 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
94169 + return 2;
94170 +
94171 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
94172 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
94173 + return 3;
94174 + }
94175 +
94176 + return 0;
94177 +}
94178 +
94179 /*
94180 * Attempt to get the on-exec apply capability sets for an executable file from
94181 * its xattrs and, if present, apply them to the proposed credentials being
94182 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
94183 const struct cred *cred = current_cred();
94184 kuid_t root_uid = make_kuid(cred->user_ns, 0);
94185
94186 + if (gr_acl_enable_at_secure())
94187 + return 1;
94188 +
94189 if (!uid_eq(cred->uid, root_uid)) {
94190 if (bprm->cap_effective)
94191 return 1;
94192 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
94193 index a41c9c1..83da6dd 100644
94194 --- a/security/integrity/ima/ima.h
94195 +++ b/security/integrity/ima/ima.h
94196 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
94197 extern spinlock_t ima_queue_lock;
94198
94199 struct ima_h_table {
94200 - atomic_long_t len; /* number of stored measurements in the list */
94201 - atomic_long_t violations;
94202 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
94203 + atomic_long_unchecked_t violations;
94204 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
94205 };
94206 extern struct ima_h_table ima_htable;
94207 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
94208 index 1c03e8f1..398a941 100644
94209 --- a/security/integrity/ima/ima_api.c
94210 +++ b/security/integrity/ima/ima_api.c
94211 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
94212 int result;
94213
94214 /* can overflow, only indicator */
94215 - atomic_long_inc(&ima_htable.violations);
94216 + atomic_long_inc_unchecked(&ima_htable.violations);
94217
94218 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
94219 if (!entry) {
94220 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
94221 index 38477c9..87a60c7 100644
94222 --- a/security/integrity/ima/ima_fs.c
94223 +++ b/security/integrity/ima/ima_fs.c
94224 @@ -28,12 +28,12 @@
94225 static int valid_policy = 1;
94226 #define TMPBUFLEN 12
94227 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
94228 - loff_t *ppos, atomic_long_t *val)
94229 + loff_t *ppos, atomic_long_unchecked_t *val)
94230 {
94231 char tmpbuf[TMPBUFLEN];
94232 ssize_t len;
94233
94234 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
94235 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
94236 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
94237 }
94238
94239 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
94240 index ff63fe0..809cd96 100644
94241 --- a/security/integrity/ima/ima_queue.c
94242 +++ b/security/integrity/ima/ima_queue.c
94243 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
94244 INIT_LIST_HEAD(&qe->later);
94245 list_add_tail_rcu(&qe->later, &ima_measurements);
94246
94247 - atomic_long_inc(&ima_htable.len);
94248 + atomic_long_inc_unchecked(&ima_htable.len);
94249 key = ima_hash_key(entry->digest);
94250 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
94251 return 0;
94252 diff --git a/security/keys/compat.c b/security/keys/compat.c
94253 index d65fa7f..cbfe366 100644
94254 --- a/security/keys/compat.c
94255 +++ b/security/keys/compat.c
94256 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
94257 if (ret == 0)
94258 goto no_payload_free;
94259
94260 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
94261 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
94262 err:
94263 if (iov != iovstack)
94264 kfree(iov);
94265 diff --git a/security/keys/internal.h b/security/keys/internal.h
94266 index d4f1468..cc52f92 100644
94267 --- a/security/keys/internal.h
94268 +++ b/security/keys/internal.h
94269 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
94270 extern long keyctl_invalidate_key(key_serial_t);
94271
94272 extern long keyctl_instantiate_key_common(key_serial_t,
94273 - const struct iovec *,
94274 + const struct iovec __user *,
94275 unsigned, size_t, key_serial_t);
94276
94277 /*
94278 diff --git a/security/keys/key.c b/security/keys/key.c
94279 index 8fb7c7b..ba3610d 100644
94280 --- a/security/keys/key.c
94281 +++ b/security/keys/key.c
94282 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
94283
94284 atomic_set(&key->usage, 1);
94285 init_rwsem(&key->sem);
94286 - lockdep_set_class(&key->sem, &type->lock_class);
94287 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
94288 key->type = type;
94289 key->user = user;
94290 key->quotalen = quotalen;
94291 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
94292 struct key_type *p;
94293 int ret;
94294
94295 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
94296 + pax_open_kernel();
94297 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
94298 + pax_close_kernel();
94299
94300 ret = -EEXIST;
94301 down_write(&key_types_sem);
94302 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
94303 }
94304
94305 /* store the type */
94306 - list_add(&ktype->link, &key_types_list);
94307 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
94308
94309 pr_notice("Key type %s registered\n", ktype->name);
94310 ret = 0;
94311 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
94312 void unregister_key_type(struct key_type *ktype)
94313 {
94314 down_write(&key_types_sem);
94315 - list_del_init(&ktype->link);
94316 + pax_list_del_init((struct list_head *)&ktype->link);
94317 downgrade_write(&key_types_sem);
94318 key_gc_keytype(ktype);
94319 pr_notice("Key type %s unregistered\n", ktype->name);
94320 @@ -1084,10 +1086,10 @@ void __init key_init(void)
94321 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
94322
94323 /* add the special key types */
94324 - list_add_tail(&key_type_keyring.link, &key_types_list);
94325 - list_add_tail(&key_type_dead.link, &key_types_list);
94326 - list_add_tail(&key_type_user.link, &key_types_list);
94327 - list_add_tail(&key_type_logon.link, &key_types_list);
94328 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
94329 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
94330 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
94331 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
94332
94333 /* record the root user tracking */
94334 rb_link_node(&root_key_user.node,
94335 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
94336 index 33cfd27..842fc5a 100644
94337 --- a/security/keys/keyctl.c
94338 +++ b/security/keys/keyctl.c
94339 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
94340 /*
94341 * Copy the iovec data from userspace
94342 */
94343 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
94344 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
94345 unsigned ioc)
94346 {
94347 for (; ioc > 0; ioc--) {
94348 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
94349 * If successful, 0 will be returned.
94350 */
94351 long keyctl_instantiate_key_common(key_serial_t id,
94352 - const struct iovec *payload_iov,
94353 + const struct iovec __user *payload_iov,
94354 unsigned ioc,
94355 size_t plen,
94356 key_serial_t ringid)
94357 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
94358 [0].iov_len = plen
94359 };
94360
94361 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
94362 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
94363 }
94364
94365 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
94366 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
94367 if (ret == 0)
94368 goto no_payload_free;
94369
94370 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
94371 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
94372 err:
94373 if (iov != iovstack)
94374 kfree(iov);
94375 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
94376 index 6ece7f2..ecdb55c 100644
94377 --- a/security/keys/keyring.c
94378 +++ b/security/keys/keyring.c
94379 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
94380 ret = -EFAULT;
94381
94382 for (loop = 0; loop < klist->nkeys; loop++) {
94383 + key_serial_t serial;
94384 key = rcu_deref_link_locked(klist, loop,
94385 keyring);
94386 + serial = key->serial;
94387
94388 tmp = sizeof(key_serial_t);
94389 if (tmp > buflen)
94390 tmp = buflen;
94391
94392 - if (copy_to_user(buffer,
94393 - &key->serial,
94394 - tmp) != 0)
94395 + if (copy_to_user(buffer, &serial, tmp))
94396 goto error;
94397
94398 buflen -= tmp;
94399 diff --git a/security/min_addr.c b/security/min_addr.c
94400 index f728728..6457a0c 100644
94401 --- a/security/min_addr.c
94402 +++ b/security/min_addr.c
94403 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
94404 */
94405 static void update_mmap_min_addr(void)
94406 {
94407 +#ifndef SPARC
94408 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
94409 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
94410 mmap_min_addr = dac_mmap_min_addr;
94411 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
94412 #else
94413 mmap_min_addr = dac_mmap_min_addr;
94414 #endif
94415 +#endif
94416 }
94417
94418 /*
94419 diff --git a/security/security.c b/security/security.c
94420 index a3dce87..9ca1435 100644
94421 --- a/security/security.c
94422 +++ b/security/security.c
94423 @@ -20,6 +20,7 @@
94424 #include <linux/ima.h>
94425 #include <linux/evm.h>
94426 #include <linux/fsnotify.h>
94427 +#include <linux/mm.h>
94428 #include <linux/mman.h>
94429 #include <linux/mount.h>
94430 #include <linux/personality.h>
94431 @@ -32,8 +33,8 @@
94432 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
94433 CONFIG_DEFAULT_SECURITY;
94434
94435 -static struct security_operations *security_ops;
94436 -static struct security_operations default_security_ops = {
94437 +static struct security_operations *security_ops __read_only;
94438 +static struct security_operations default_security_ops __read_only = {
94439 .name = "default",
94440 };
94441
94442 @@ -74,7 +75,9 @@ int __init security_init(void)
94443
94444 void reset_security_ops(void)
94445 {
94446 + pax_open_kernel();
94447 security_ops = &default_security_ops;
94448 + pax_close_kernel();
94449 }
94450
94451 /* Save user chosen LSM */
94452 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
94453 index 5c6f2cd..b4f945c 100644
94454 --- a/security/selinux/hooks.c
94455 +++ b/security/selinux/hooks.c
94456 @@ -96,8 +96,6 @@
94457
94458 #define NUM_SEL_MNT_OPTS 5
94459
94460 -extern struct security_operations *security_ops;
94461 -
94462 /* SECMARK reference count */
94463 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
94464
94465 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
94466
94467 #endif
94468
94469 -static struct security_operations selinux_ops = {
94470 +static struct security_operations selinux_ops __read_only = {
94471 .name = "selinux",
94472
94473 .ptrace_access_check = selinux_ptrace_access_check,
94474 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
94475 index 65f67cb..3f141ef 100644
94476 --- a/security/selinux/include/xfrm.h
94477 +++ b/security/selinux/include/xfrm.h
94478 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
94479
94480 static inline void selinux_xfrm_notify_policyload(void)
94481 {
94482 - atomic_inc(&flow_cache_genid);
94483 + atomic_inc_unchecked(&flow_cache_genid);
94484 rt_genid_bump(&init_net);
94485 }
94486 #else
94487 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
94488 index d52c780..6431349 100644
94489 --- a/security/smack/smack_lsm.c
94490 +++ b/security/smack/smack_lsm.c
94491 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
94492 return 0;
94493 }
94494
94495 -struct security_operations smack_ops = {
94496 +struct security_operations smack_ops __read_only = {
94497 .name = "smack",
94498
94499 .ptrace_access_check = smack_ptrace_access_check,
94500 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
94501 index 390c646..f2f8db3 100644
94502 --- a/security/tomoyo/mount.c
94503 +++ b/security/tomoyo/mount.c
94504 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
94505 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
94506 need_dev = -1; /* dev_name is a directory */
94507 } else {
94508 + if (!capable(CAP_SYS_ADMIN)) {
94509 + error = -EPERM;
94510 + goto out;
94511 + }
94512 fstype = get_fs_type(type);
94513 if (!fstype) {
94514 error = -ENODEV;
94515 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
94516 index f0b756e..b129202 100644
94517 --- a/security/tomoyo/tomoyo.c
94518 +++ b/security/tomoyo/tomoyo.c
94519 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
94520 * tomoyo_security_ops is a "struct security_operations" which is used for
94521 * registering TOMOYO.
94522 */
94523 -static struct security_operations tomoyo_security_ops = {
94524 +static struct security_operations tomoyo_security_ops __read_only = {
94525 .name = "tomoyo",
94526 .cred_alloc_blank = tomoyo_cred_alloc_blank,
94527 .cred_prepare = tomoyo_cred_prepare,
94528 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
94529 index 20ef514..4182bed 100644
94530 --- a/security/yama/Kconfig
94531 +++ b/security/yama/Kconfig
94532 @@ -1,6 +1,6 @@
94533 config SECURITY_YAMA
94534 bool "Yama support"
94535 - depends on SECURITY
94536 + depends on SECURITY && !GRKERNSEC
94537 select SECURITYFS
94538 select SECURITY_PATH
94539 default n
94540 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
94541 index 13c88fbc..f8c115e 100644
94542 --- a/security/yama/yama_lsm.c
94543 +++ b/security/yama/yama_lsm.c
94544 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
94545 }
94546
94547 #ifndef CONFIG_SECURITY_YAMA_STACKED
94548 -static struct security_operations yama_ops = {
94549 +static struct security_operations yama_ops __read_only = {
94550 .name = "yama",
94551
94552 .ptrace_access_check = yama_ptrace_access_check,
94553 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
94554 #endif
94555
94556 #ifdef CONFIG_SYSCTL
94557 +static int zero __read_only;
94558 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
94559 +
94560 static int yama_dointvec_minmax(struct ctl_table *table, int write,
94561 void __user *buffer, size_t *lenp, loff_t *ppos)
94562 {
94563 - int rc;
94564 + ctl_table_no_const yama_table;
94565
94566 if (write && !capable(CAP_SYS_PTRACE))
94567 return -EPERM;
94568
94569 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
94570 - if (rc)
94571 - return rc;
94572 -
94573 + yama_table = *table;
94574 /* Lock the max value if it ever gets set. */
94575 - if (write && *(int *)table->data == *(int *)table->extra2)
94576 - table->extra1 = table->extra2;
94577 -
94578 - return rc;
94579 + if (ptrace_scope == max_scope)
94580 + yama_table.extra1 = &max_scope;
94581 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
94582 }
94583
94584 -static int zero;
94585 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
94586 -
94587 struct ctl_path yama_sysctl_path[] = {
94588 { .procname = "kernel", },
94589 { .procname = "yama", },
94590 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
94591 index 4cedc69..e59d8a3 100644
94592 --- a/sound/aoa/codecs/onyx.c
94593 +++ b/sound/aoa/codecs/onyx.c
94594 @@ -54,7 +54,7 @@ struct onyx {
94595 spdif_locked:1,
94596 analog_locked:1,
94597 original_mute:2;
94598 - int open_count;
94599 + local_t open_count;
94600 struct codec_info *codec_info;
94601
94602 /* mutex serializes concurrent access to the device
94603 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
94604 struct onyx *onyx = cii->codec_data;
94605
94606 mutex_lock(&onyx->mutex);
94607 - onyx->open_count++;
94608 + local_inc(&onyx->open_count);
94609 mutex_unlock(&onyx->mutex);
94610
94611 return 0;
94612 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
94613 struct onyx *onyx = cii->codec_data;
94614
94615 mutex_lock(&onyx->mutex);
94616 - onyx->open_count--;
94617 - if (!onyx->open_count)
94618 + if (local_dec_and_test(&onyx->open_count))
94619 onyx->spdif_locked = onyx->analog_locked = 0;
94620 mutex_unlock(&onyx->mutex);
94621
94622 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
94623 index ffd2025..df062c9 100644
94624 --- a/sound/aoa/codecs/onyx.h
94625 +++ b/sound/aoa/codecs/onyx.h
94626 @@ -11,6 +11,7 @@
94627 #include <linux/i2c.h>
94628 #include <asm/pmac_low_i2c.h>
94629 #include <asm/prom.h>
94630 +#include <asm/local.h>
94631
94632 /* PCM3052 register definitions */
94633
94634 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
94635 index 4c1cc51..16040040 100644
94636 --- a/sound/core/oss/pcm_oss.c
94637 +++ b/sound/core/oss/pcm_oss.c
94638 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
94639 if (in_kernel) {
94640 mm_segment_t fs;
94641 fs = snd_enter_user();
94642 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
94643 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
94644 snd_leave_user(fs);
94645 } else {
94646 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
94647 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
94648 }
94649 if (ret != -EPIPE && ret != -ESTRPIPE)
94650 break;
94651 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
94652 if (in_kernel) {
94653 mm_segment_t fs;
94654 fs = snd_enter_user();
94655 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
94656 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
94657 snd_leave_user(fs);
94658 } else {
94659 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
94660 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
94661 }
94662 if (ret == -EPIPE) {
94663 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
94664 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
94665 struct snd_pcm_plugin_channel *channels;
94666 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
94667 if (!in_kernel) {
94668 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
94669 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
94670 return -EFAULT;
94671 buf = runtime->oss.buffer;
94672 }
94673 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
94674 }
94675 } else {
94676 tmp = snd_pcm_oss_write2(substream,
94677 - (const char __force *)buf,
94678 + (const char __force_kernel *)buf,
94679 runtime->oss.period_bytes, 0);
94680 if (tmp <= 0)
94681 goto err;
94682 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
94683 struct snd_pcm_runtime *runtime = substream->runtime;
94684 snd_pcm_sframes_t frames, frames1;
94685 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
94686 - char __user *final_dst = (char __force __user *)buf;
94687 + char __user *final_dst = (char __force_user *)buf;
94688 if (runtime->oss.plugin_first) {
94689 struct snd_pcm_plugin_channel *channels;
94690 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
94691 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
94692 xfer += tmp;
94693 runtime->oss.buffer_used -= tmp;
94694 } else {
94695 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
94696 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
94697 runtime->oss.period_bytes, 0);
94698 if (tmp <= 0)
94699 goto err;
94700 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
94701 size1);
94702 size1 /= runtime->channels; /* frames */
94703 fs = snd_enter_user();
94704 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
94705 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
94706 snd_leave_user(fs);
94707 }
94708 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
94709 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
94710 index af49721..e85058e 100644
94711 --- a/sound/core/pcm_compat.c
94712 +++ b/sound/core/pcm_compat.c
94713 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
94714 int err;
94715
94716 fs = snd_enter_user();
94717 - err = snd_pcm_delay(substream, &delay);
94718 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
94719 snd_leave_user(fs);
94720 if (err < 0)
94721 return err;
94722 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
94723 index f928181..33fb83d 100644
94724 --- a/sound/core/pcm_native.c
94725 +++ b/sound/core/pcm_native.c
94726 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
94727 switch (substream->stream) {
94728 case SNDRV_PCM_STREAM_PLAYBACK:
94729 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
94730 - (void __user *)arg);
94731 + (void __force_user *)arg);
94732 break;
94733 case SNDRV_PCM_STREAM_CAPTURE:
94734 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
94735 - (void __user *)arg);
94736 + (void __force_user *)arg);
94737 break;
94738 default:
94739 result = -EINVAL;
94740 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
94741 index 040c60e..989a19a 100644
94742 --- a/sound/core/seq/seq_device.c
94743 +++ b/sound/core/seq/seq_device.c
94744 @@ -64,7 +64,7 @@ struct ops_list {
94745 int argsize; /* argument size */
94746
94747 /* operators */
94748 - struct snd_seq_dev_ops ops;
94749 + struct snd_seq_dev_ops *ops;
94750
94751 /* registered devices */
94752 struct list_head dev_list; /* list of devices */
94753 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
94754
94755 mutex_lock(&ops->reg_mutex);
94756 /* copy driver operators */
94757 - ops->ops = *entry;
94758 + ops->ops = entry;
94759 ops->driver |= DRIVER_LOADED;
94760 ops->argsize = argsize;
94761
94762 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
94763 dev->name, ops->id, ops->argsize, dev->argsize);
94764 return -EINVAL;
94765 }
94766 - if (ops->ops.init_device(dev) >= 0) {
94767 + if (ops->ops->init_device(dev) >= 0) {
94768 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
94769 ops->num_init_devices++;
94770 } else {
94771 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
94772 dev->name, ops->id, ops->argsize, dev->argsize);
94773 return -EINVAL;
94774 }
94775 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
94776 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
94777 dev->status = SNDRV_SEQ_DEVICE_FREE;
94778 dev->driver_data = NULL;
94779 ops->num_init_devices--;
94780 diff --git a/sound/core/sound.c b/sound/core/sound.c
94781 index f002bd9..c462985 100644
94782 --- a/sound/core/sound.c
94783 +++ b/sound/core/sound.c
94784 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
94785 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
94786 default: return;
94787 }
94788 - request_module(str);
94789 + request_module("%s", str);
94790 }
94791
94792 #endif /* modular kernel */
94793 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
94794 index 4e0dd22..7a1f32c 100644
94795 --- a/sound/drivers/mts64.c
94796 +++ b/sound/drivers/mts64.c
94797 @@ -29,6 +29,7 @@
94798 #include <sound/initval.h>
94799 #include <sound/rawmidi.h>
94800 #include <sound/control.h>
94801 +#include <asm/local.h>
94802
94803 #define CARD_NAME "Miditerminal 4140"
94804 #define DRIVER_NAME "MTS64"
94805 @@ -67,7 +68,7 @@ struct mts64 {
94806 struct pardevice *pardev;
94807 int pardev_claimed;
94808
94809 - int open_count;
94810 + local_t open_count;
94811 int current_midi_output_port;
94812 int current_midi_input_port;
94813 u8 mode[MTS64_NUM_INPUT_PORTS];
94814 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
94815 {
94816 struct mts64 *mts = substream->rmidi->private_data;
94817
94818 - if (mts->open_count == 0) {
94819 + if (local_read(&mts->open_count) == 0) {
94820 /* We don't need a spinlock here, because this is just called
94821 if the device has not been opened before.
94822 So there aren't any IRQs from the device */
94823 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
94824
94825 msleep(50);
94826 }
94827 - ++(mts->open_count);
94828 + local_inc(&mts->open_count);
94829
94830 return 0;
94831 }
94832 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
94833 struct mts64 *mts = substream->rmidi->private_data;
94834 unsigned long flags;
94835
94836 - --(mts->open_count);
94837 - if (mts->open_count == 0) {
94838 + if (local_dec_return(&mts->open_count) == 0) {
94839 /* We need the spinlock_irqsave here because we can still
94840 have IRQs at this point */
94841 spin_lock_irqsave(&mts->lock, flags);
94842 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
94843
94844 msleep(500);
94845
94846 - } else if (mts->open_count < 0)
94847 - mts->open_count = 0;
94848 + } else if (local_read(&mts->open_count) < 0)
94849 + local_set(&mts->open_count, 0);
94850
94851 return 0;
94852 }
94853 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
94854 index b953fb4..1999c01 100644
94855 --- a/sound/drivers/opl4/opl4_lib.c
94856 +++ b/sound/drivers/opl4/opl4_lib.c
94857 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
94858 MODULE_DESCRIPTION("OPL4 driver");
94859 MODULE_LICENSE("GPL");
94860
94861 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
94862 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
94863 {
94864 int timeout = 10;
94865 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
94866 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
94867 index 991018d..8984740 100644
94868 --- a/sound/drivers/portman2x4.c
94869 +++ b/sound/drivers/portman2x4.c
94870 @@ -48,6 +48,7 @@
94871 #include <sound/initval.h>
94872 #include <sound/rawmidi.h>
94873 #include <sound/control.h>
94874 +#include <asm/local.h>
94875
94876 #define CARD_NAME "Portman 2x4"
94877 #define DRIVER_NAME "portman"
94878 @@ -85,7 +86,7 @@ struct portman {
94879 struct pardevice *pardev;
94880 int pardev_claimed;
94881
94882 - int open_count;
94883 + local_t open_count;
94884 int mode[PORTMAN_NUM_INPUT_PORTS];
94885 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
94886 };
94887 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
94888 index ea995af..f1bfa37 100644
94889 --- a/sound/firewire/amdtp.c
94890 +++ b/sound/firewire/amdtp.c
94891 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
94892 ptr = s->pcm_buffer_pointer + data_blocks;
94893 if (ptr >= pcm->runtime->buffer_size)
94894 ptr -= pcm->runtime->buffer_size;
94895 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
94896 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
94897
94898 s->pcm_period_pointer += data_blocks;
94899 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
94900 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
94901 */
94902 void amdtp_out_stream_update(struct amdtp_out_stream *s)
94903 {
94904 - ACCESS_ONCE(s->source_node_id_field) =
94905 + ACCESS_ONCE_RW(s->source_node_id_field) =
94906 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
94907 }
94908 EXPORT_SYMBOL(amdtp_out_stream_update);
94909 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
94910 index b680c5e..061b7a0 100644
94911 --- a/sound/firewire/amdtp.h
94912 +++ b/sound/firewire/amdtp.h
94913 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
94914 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
94915 struct snd_pcm_substream *pcm)
94916 {
94917 - ACCESS_ONCE(s->pcm) = pcm;
94918 + ACCESS_ONCE_RW(s->pcm) = pcm;
94919 }
94920
94921 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
94922 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
94923 index d428ffe..751ef78 100644
94924 --- a/sound/firewire/isight.c
94925 +++ b/sound/firewire/isight.c
94926 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
94927 ptr += count;
94928 if (ptr >= runtime->buffer_size)
94929 ptr -= runtime->buffer_size;
94930 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
94931 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
94932
94933 isight->period_counter += count;
94934 if (isight->period_counter >= runtime->period_size) {
94935 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
94936 if (err < 0)
94937 return err;
94938
94939 - ACCESS_ONCE(isight->pcm_active) = true;
94940 + ACCESS_ONCE_RW(isight->pcm_active) = true;
94941
94942 return 0;
94943 }
94944 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
94945 {
94946 struct isight *isight = substream->private_data;
94947
94948 - ACCESS_ONCE(isight->pcm_active) = false;
94949 + ACCESS_ONCE_RW(isight->pcm_active) = false;
94950
94951 mutex_lock(&isight->mutex);
94952 isight_stop_streaming(isight);
94953 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
94954
94955 switch (cmd) {
94956 case SNDRV_PCM_TRIGGER_START:
94957 - ACCESS_ONCE(isight->pcm_running) = true;
94958 + ACCESS_ONCE_RW(isight->pcm_running) = true;
94959 break;
94960 case SNDRV_PCM_TRIGGER_STOP:
94961 - ACCESS_ONCE(isight->pcm_running) = false;
94962 + ACCESS_ONCE_RW(isight->pcm_running) = false;
94963 break;
94964 default:
94965 return -EINVAL;
94966 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
94967 index 844a555..985ab83 100644
94968 --- a/sound/firewire/scs1x.c
94969 +++ b/sound/firewire/scs1x.c
94970 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
94971 {
94972 struct scs *scs = stream->rmidi->private_data;
94973
94974 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
94975 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
94976 if (up) {
94977 scs->output_idle = false;
94978 tasklet_schedule(&scs->tasklet);
94979 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
94980 {
94981 struct scs *scs = stream->rmidi->private_data;
94982
94983 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
94984 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
94985 }
94986
94987 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
94988 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
94989
94990 snd_card_disconnect(scs->card);
94991
94992 - ACCESS_ONCE(scs->output) = NULL;
94993 - ACCESS_ONCE(scs->input) = NULL;
94994 + ACCESS_ONCE_RW(scs->output) = NULL;
94995 + ACCESS_ONCE_RW(scs->input) = NULL;
94996
94997 wait_event(scs->idle_wait, scs->output_idle);
94998
94999 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
95000 index 048439a..3be9f6f 100644
95001 --- a/sound/oss/sb_audio.c
95002 +++ b/sound/oss/sb_audio.c
95003 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
95004 buf16 = (signed short *)(localbuf + localoffs);
95005 while (c)
95006 {
95007 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
95008 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
95009 if (copy_from_user(lbuf8,
95010 userbuf+useroffs + p,
95011 locallen))
95012 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
95013 index 7d8803a..559f8d0 100644
95014 --- a/sound/oss/swarm_cs4297a.c
95015 +++ b/sound/oss/swarm_cs4297a.c
95016 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
95017 {
95018 struct cs4297a_state *s;
95019 u32 pwr, id;
95020 - mm_segment_t fs;
95021 int rval;
95022 #ifndef CONFIG_BCM_CS4297A_CSWARM
95023 u64 cfg;
95024 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
95025 if (!rval) {
95026 char *sb1250_duart_present;
95027
95028 +#if 0
95029 + mm_segment_t fs;
95030 fs = get_fs();
95031 set_fs(KERNEL_DS);
95032 -#if 0
95033 val = SOUND_MASK_LINE;
95034 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
95035 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
95036 val = initvol[i].vol;
95037 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
95038 }
95039 + set_fs(fs);
95040 // cs4297a_write_ac97(s, 0x18, 0x0808);
95041 #else
95042 // cs4297a_write_ac97(s, 0x5e, 0x180);
95043 cs4297a_write_ac97(s, 0x02, 0x0808);
95044 cs4297a_write_ac97(s, 0x18, 0x0808);
95045 #endif
95046 - set_fs(fs);
95047
95048 list_add(&s->list, &cs4297a_devs);
95049
95050 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
95051 index 4631a23..001ae57 100644
95052 --- a/sound/pci/ymfpci/ymfpci.h
95053 +++ b/sound/pci/ymfpci/ymfpci.h
95054 @@ -358,7 +358,7 @@ struct snd_ymfpci {
95055 spinlock_t reg_lock;
95056 spinlock_t voice_lock;
95057 wait_queue_head_t interrupt_sleep;
95058 - atomic_t interrupt_sleep_count;
95059 + atomic_unchecked_t interrupt_sleep_count;
95060 struct snd_info_entry *proc_entry;
95061 const struct firmware *dsp_microcode;
95062 const struct firmware *controller_microcode;
95063 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
95064 index 22056c5..25d3244 100644
95065 --- a/sound/pci/ymfpci/ymfpci_main.c
95066 +++ b/sound/pci/ymfpci/ymfpci_main.c
95067 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
95068 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
95069 break;
95070 }
95071 - if (atomic_read(&chip->interrupt_sleep_count)) {
95072 - atomic_set(&chip->interrupt_sleep_count, 0);
95073 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
95074 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
95075 wake_up(&chip->interrupt_sleep);
95076 }
95077 __end:
95078 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
95079 continue;
95080 init_waitqueue_entry(&wait, current);
95081 add_wait_queue(&chip->interrupt_sleep, &wait);
95082 - atomic_inc(&chip->interrupt_sleep_count);
95083 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
95084 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
95085 remove_wait_queue(&chip->interrupt_sleep, &wait);
95086 }
95087 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
95088 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
95089 spin_unlock(&chip->reg_lock);
95090
95091 - if (atomic_read(&chip->interrupt_sleep_count)) {
95092 - atomic_set(&chip->interrupt_sleep_count, 0);
95093 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
95094 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
95095 wake_up(&chip->interrupt_sleep);
95096 }
95097 }
95098 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
95099 spin_lock_init(&chip->reg_lock);
95100 spin_lock_init(&chip->voice_lock);
95101 init_waitqueue_head(&chip->interrupt_sleep);
95102 - atomic_set(&chip->interrupt_sleep_count, 0);
95103 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
95104 chip->card = card;
95105 chip->pci = pci;
95106 chip->irq = -1;
95107 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
95108 index 0f0bed6..c161e28 100644
95109 --- a/sound/soc/fsl/fsl_ssi.c
95110 +++ b/sound/soc/fsl/fsl_ssi.c
95111 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
95112 {
95113 struct fsl_ssi_private *ssi_private;
95114 int ret = 0;
95115 - struct device_attribute *dev_attr = NULL;
95116 + device_attribute_no_const *dev_attr = NULL;
95117 struct device_node *np = pdev->dev.of_node;
95118 const char *p, *sprop;
95119 const uint32_t *iprop;
95120 diff --git a/sound/sound_core.c b/sound/sound_core.c
95121 index 359753f..45759f4 100644
95122 --- a/sound/sound_core.c
95123 +++ b/sound/sound_core.c
95124 @@ -292,7 +292,7 @@ retry:
95125 }
95126
95127 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
95128 - NULL, s->name+6);
95129 + NULL, "%s", s->name+6);
95130 return s->unit_minor;
95131
95132 fail:
95133 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
95134 new file mode 100644
95135 index 0000000..50f2f2f
95136 --- /dev/null
95137 +++ b/tools/gcc/.gitignore
95138 @@ -0,0 +1 @@
95139 +size_overflow_hash.h
95140 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
95141 new file mode 100644
95142 index 0000000..144dbee
95143 --- /dev/null
95144 +++ b/tools/gcc/Makefile
95145 @@ -0,0 +1,45 @@
95146 +#CC := gcc
95147 +#PLUGIN_SOURCE_FILES := pax_plugin.c
95148 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
95149 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
95150 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
95151 +
95152 +ifeq ($(PLUGINCC),$(HOSTCC))
95153 +HOSTLIBS := hostlibs
95154 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
95155 +else
95156 +HOSTLIBS := hostcxxlibs
95157 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
95158 +endif
95159 +
95160 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
95161 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
95162 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
95163 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
95164 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
95165 +$(HOSTLIBS)-y += colorize_plugin.so
95166 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
95167 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
95168 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
95169 +
95170 +always := $($(HOSTLIBS)-y)
95171 +
95172 +constify_plugin-objs := constify_plugin.o
95173 +stackleak_plugin-objs := stackleak_plugin.o
95174 +kallocstat_plugin-objs := kallocstat_plugin.o
95175 +kernexec_plugin-objs := kernexec_plugin.o
95176 +checker_plugin-objs := checker_plugin.o
95177 +colorize_plugin-objs := colorize_plugin.o
95178 +size_overflow_plugin-objs := size_overflow_plugin.o
95179 +latent_entropy_plugin-objs := latent_entropy_plugin.o
95180 +structleak_plugin-objs := structleak_plugin.o
95181 +
95182 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
95183 +
95184 +quiet_cmd_build_size_overflow_hash = GENHASH $@
95185 + cmd_build_size_overflow_hash = \
95186 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
95187 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
95188 + $(call if_changed,build_size_overflow_hash)
95189 +
95190 +targets += size_overflow_hash.h
95191 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
95192 new file mode 100644
95193 index 0000000..22f03c0
95194 --- /dev/null
95195 +++ b/tools/gcc/checker_plugin.c
95196 @@ -0,0 +1,172 @@
95197 +/*
95198 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
95199 + * Licensed under the GPL v2
95200 + *
95201 + * Note: the choice of the license means that the compilation process is
95202 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95203 + * but for the kernel it doesn't matter since it doesn't link against
95204 + * any of the gcc libraries
95205 + *
95206 + * gcc plugin to implement various sparse (source code checker) features
95207 + *
95208 + * TODO:
95209 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
95210 + *
95211 + * BUGS:
95212 + * - none known
95213 + */
95214 +#include "gcc-plugin.h"
95215 +#include "config.h"
95216 +#include "system.h"
95217 +#include "coretypes.h"
95218 +#include "tree.h"
95219 +#include "tree-pass.h"
95220 +#include "flags.h"
95221 +#include "intl.h"
95222 +#include "toplev.h"
95223 +#include "plugin.h"
95224 +//#include "expr.h" where are you...
95225 +#include "diagnostic.h"
95226 +#include "plugin-version.h"
95227 +#include "tm.h"
95228 +#include "function.h"
95229 +#include "basic-block.h"
95230 +#include "gimple.h"
95231 +#include "rtl.h"
95232 +#include "emit-rtl.h"
95233 +#include "tree-flow.h"
95234 +#include "target.h"
95235 +
95236 +extern void c_register_addr_space (const char *str, addr_space_t as);
95237 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
95238 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
95239 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
95240 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
95241 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
95242 +
95243 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95244 +extern rtx emit_move_insn(rtx x, rtx y);
95245 +
95246 +int plugin_is_GPL_compatible;
95247 +
95248 +static struct plugin_info checker_plugin_info = {
95249 + .version = "201111150100",
95250 + .help = NULL,
95251 +};
95252 +
95253 +#define ADDR_SPACE_KERNEL 0
95254 +#define ADDR_SPACE_FORCE_KERNEL 1
95255 +#define ADDR_SPACE_USER 2
95256 +#define ADDR_SPACE_FORCE_USER 3
95257 +#define ADDR_SPACE_IOMEM 0
95258 +#define ADDR_SPACE_FORCE_IOMEM 0
95259 +#define ADDR_SPACE_PERCPU 0
95260 +#define ADDR_SPACE_FORCE_PERCPU 0
95261 +#define ADDR_SPACE_RCU 0
95262 +#define ADDR_SPACE_FORCE_RCU 0
95263 +
95264 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
95265 +{
95266 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
95267 +}
95268 +
95269 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
95270 +{
95271 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
95272 +}
95273 +
95274 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
95275 +{
95276 + return default_addr_space_valid_pointer_mode(mode, as);
95277 +}
95278 +
95279 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
95280 +{
95281 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
95282 +}
95283 +
95284 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
95285 +{
95286 + return default_addr_space_legitimize_address(x, oldx, mode, as);
95287 +}
95288 +
95289 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
95290 +{
95291 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
95292 + return true;
95293 +
95294 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
95295 + return true;
95296 +
95297 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
95298 + return true;
95299 +
95300 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
95301 + return true;
95302 +
95303 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
95304 + return true;
95305 +
95306 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
95307 + return true;
95308 +
95309 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
95310 + return true;
95311 +
95312 + return subset == superset;
95313 +}
95314 +
95315 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
95316 +{
95317 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
95318 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
95319 +
95320 + return op;
95321 +}
95322 +
95323 +static void register_checker_address_spaces(void *event_data, void *data)
95324 +{
95325 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
95326 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
95327 + c_register_addr_space("__user", ADDR_SPACE_USER);
95328 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
95329 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
95330 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
95331 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
95332 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
95333 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
95334 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
95335 +
95336 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
95337 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
95338 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
95339 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
95340 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
95341 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
95342 + targetm.addr_space.convert = checker_addr_space_convert;
95343 +}
95344 +
95345 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95346 +{
95347 + const char * const plugin_name = plugin_info->base_name;
95348 + const int argc = plugin_info->argc;
95349 + const struct plugin_argument * const argv = plugin_info->argv;
95350 + int i;
95351 +
95352 + if (!plugin_default_version_check(version, &gcc_version)) {
95353 + error(G_("incompatible gcc/plugin versions"));
95354 + return 1;
95355 + }
95356 +
95357 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
95358 +
95359 + for (i = 0; i < argc; ++i)
95360 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95361 +
95362 + if (TARGET_64BIT == 0)
95363 + return 0;
95364 +
95365 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
95366 +
95367 + return 0;
95368 +}
95369 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
95370 new file mode 100644
95371 index 0000000..414fe5e
95372 --- /dev/null
95373 +++ b/tools/gcc/colorize_plugin.c
95374 @@ -0,0 +1,151 @@
95375 +/*
95376 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
95377 + * Licensed under the GPL v2
95378 + *
95379 + * Note: the choice of the license means that the compilation process is
95380 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95381 + * but for the kernel it doesn't matter since it doesn't link against
95382 + * any of the gcc libraries
95383 + *
95384 + * gcc plugin to colorize diagnostic output
95385 + *
95386 + */
95387 +
95388 +#include "gcc-plugin.h"
95389 +#include "config.h"
95390 +#include "system.h"
95391 +#include "coretypes.h"
95392 +#include "tree.h"
95393 +#include "tree-pass.h"
95394 +#include "flags.h"
95395 +#include "intl.h"
95396 +#include "toplev.h"
95397 +#include "plugin.h"
95398 +#include "diagnostic.h"
95399 +#include "plugin-version.h"
95400 +#include "tm.h"
95401 +
95402 +int plugin_is_GPL_compatible;
95403 +
95404 +static struct plugin_info colorize_plugin_info = {
95405 + .version = "201302112000",
95406 + .help = NULL,
95407 +};
95408 +
95409 +#define GREEN "\033[32m\033[2m"
95410 +#define LIGHTGREEN "\033[32m\033[1m"
95411 +#define YELLOW "\033[33m\033[2m"
95412 +#define LIGHTYELLOW "\033[33m\033[1m"
95413 +#define RED "\033[31m\033[2m"
95414 +#define LIGHTRED "\033[31m\033[1m"
95415 +#define BLUE "\033[34m\033[2m"
95416 +#define LIGHTBLUE "\033[34m\033[1m"
95417 +#define BRIGHT "\033[m\033[1m"
95418 +#define NORMAL "\033[m"
95419 +
95420 +static diagnostic_starter_fn old_starter;
95421 +static diagnostic_finalizer_fn old_finalizer;
95422 +
95423 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
95424 +{
95425 + const char *color;
95426 + char *newprefix;
95427 +
95428 + switch (diagnostic->kind) {
95429 + case DK_NOTE:
95430 + color = LIGHTBLUE;
95431 + break;
95432 +
95433 + case DK_PEDWARN:
95434 + case DK_WARNING:
95435 + color = LIGHTYELLOW;
95436 + break;
95437 +
95438 + case DK_ERROR:
95439 + case DK_FATAL:
95440 + case DK_ICE:
95441 + case DK_PERMERROR:
95442 + case DK_SORRY:
95443 + color = LIGHTRED;
95444 + break;
95445 +
95446 + default:
95447 + color = NORMAL;
95448 + }
95449 +
95450 + old_starter(context, diagnostic);
95451 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
95452 + return;
95453 + pp_destroy_prefix(context->printer);
95454 + pp_set_prefix(context->printer, newprefix);
95455 +}
95456 +
95457 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
95458 +{
95459 + old_finalizer(context, diagnostic);
95460 +}
95461 +
95462 +static void colorize_arm(void)
95463 +{
95464 + old_starter = diagnostic_starter(global_dc);
95465 + old_finalizer = diagnostic_finalizer(global_dc);
95466 +
95467 + diagnostic_starter(global_dc) = start_colorize;
95468 + diagnostic_finalizer(global_dc) = finalize_colorize;
95469 +}
95470 +
95471 +static unsigned int execute_colorize_rearm(void)
95472 +{
95473 + if (diagnostic_starter(global_dc) == start_colorize)
95474 + return 0;
95475 +
95476 + colorize_arm();
95477 + return 0;
95478 +}
95479 +
95480 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
95481 + .pass = {
95482 + .type = SIMPLE_IPA_PASS,
95483 + .name = "colorize_rearm",
95484 +#if BUILDING_GCC_VERSION >= 4008
95485 + .optinfo_flags = OPTGROUP_NONE,
95486 +#endif
95487 + .gate = NULL,
95488 + .execute = execute_colorize_rearm,
95489 + .sub = NULL,
95490 + .next = NULL,
95491 + .static_pass_number = 0,
95492 + .tv_id = TV_NONE,
95493 + .properties_required = 0,
95494 + .properties_provided = 0,
95495 + .properties_destroyed = 0,
95496 + .todo_flags_start = 0,
95497 + .todo_flags_finish = 0
95498 + }
95499 +};
95500 +
95501 +static void colorize_start_unit(void *gcc_data, void *user_data)
95502 +{
95503 + colorize_arm();
95504 +}
95505 +
95506 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95507 +{
95508 + const char * const plugin_name = plugin_info->base_name;
95509 + struct register_pass_info colorize_rearm_pass_info = {
95510 + .pass = &pass_ipa_colorize_rearm.pass,
95511 + .reference_pass_name = "*free_lang_data",
95512 + .ref_pass_instance_number = 1,
95513 + .pos_op = PASS_POS_INSERT_AFTER
95514 + };
95515 +
95516 + if (!plugin_default_version_check(version, &gcc_version)) {
95517 + error(G_("incompatible gcc/plugin versions"));
95518 + return 1;
95519 + }
95520 +
95521 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
95522 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
95523 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
95524 + return 0;
95525 +}
95526 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
95527 new file mode 100644
95528 index 0000000..c17312d
95529 --- /dev/null
95530 +++ b/tools/gcc/constify_plugin.c
95531 @@ -0,0 +1,560 @@
95532 +/*
95533 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
95534 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
95535 + * Licensed under the GPL v2, or (at your option) v3
95536 + *
95537 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
95538 + *
95539 + * Homepage:
95540 + * http://www.grsecurity.net/~ephox/const_plugin/
95541 + *
95542 + * Usage:
95543 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
95544 + * $ gcc -fplugin=constify_plugin.so test.c -O2
95545 + */
95546 +
95547 +#include "gcc-plugin.h"
95548 +#include "config.h"
95549 +#include "system.h"
95550 +#include "coretypes.h"
95551 +#include "tree.h"
95552 +#include "tree-pass.h"
95553 +#include "flags.h"
95554 +#include "intl.h"
95555 +#include "toplev.h"
95556 +#include "plugin.h"
95557 +#include "diagnostic.h"
95558 +#include "plugin-version.h"
95559 +#include "tm.h"
95560 +#include "function.h"
95561 +#include "basic-block.h"
95562 +#include "gimple.h"
95563 +#include "rtl.h"
95564 +#include "emit-rtl.h"
95565 +#include "tree-flow.h"
95566 +#include "target.h"
95567 +#include "langhooks.h"
95568 +
95569 +// should come from c-tree.h if only it were installed for gcc 4.5...
95570 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
95571 +
95572 +// unused type flag in all versions 4.5-4.8
95573 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
95574 +
95575 +int plugin_is_GPL_compatible;
95576 +
95577 +static struct plugin_info const_plugin_info = {
95578 + .version = "201305231310",
95579 + .help = "no-constify\tturn off constification\n",
95580 +};
95581 +
95582 +typedef struct {
95583 + bool has_fptr_field;
95584 + bool has_writable_field;
95585 + bool has_do_const_field;
95586 + bool has_no_const_field;
95587 +} constify_info;
95588 +
95589 +static const_tree get_field_type(const_tree field)
95590 +{
95591 + return strip_array_types(TREE_TYPE(field));
95592 +}
95593 +
95594 +static bool is_fptr(const_tree field)
95595 +{
95596 + const_tree ptr = get_field_type(field);
95597 +
95598 + if (TREE_CODE(ptr) != POINTER_TYPE)
95599 + return false;
95600 +
95601 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
95602 +}
95603 +
95604 +/*
95605 + * determine whether the given structure type meets the requirements for automatic constification,
95606 + * including the constification attributes on nested structure types
95607 + */
95608 +static void constifiable(const_tree node, constify_info *cinfo)
95609 +{
95610 + const_tree field;
95611 +
95612 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
95613 +
95614 + // e.g., pointer to structure fields while still constructing the structure type
95615 + if (TYPE_FIELDS(node) == NULL_TREE)
95616 + return;
95617 +
95618 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
95619 + const_tree type = get_field_type(field);
95620 + enum tree_code code = TREE_CODE(type);
95621 +
95622 + if (node == type)
95623 + continue;
95624 +
95625 + if (is_fptr(field))
95626 + cinfo->has_fptr_field = true;
95627 + else if (!TREE_READONLY(field))
95628 + cinfo->has_writable_field = true;
95629 +
95630 + if (code == RECORD_TYPE || code == UNION_TYPE) {
95631 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95632 + cinfo->has_do_const_field = true;
95633 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
95634 + cinfo->has_no_const_field = true;
95635 + else
95636 + constifiable(type, cinfo);
95637 + }
95638 + }
95639 +}
95640 +
95641 +static bool constified(const_tree node)
95642 +{
95643 + constify_info cinfo = {
95644 + .has_fptr_field = false,
95645 + .has_writable_field = false,
95646 + .has_do_const_field = false,
95647 + .has_no_const_field = false
95648 + };
95649 +
95650 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
95651 +
95652 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
95653 + gcc_assert(!TYPE_READONLY(node));
95654 + return false;
95655 + }
95656 +
95657 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
95658 + gcc_assert(TYPE_READONLY(node));
95659 + return true;
95660 + }
95661 +
95662 + constifiable(node, &cinfo);
95663 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
95664 + return false;
95665 +
95666 + return TYPE_READONLY(node);
95667 +}
95668 +
95669 +static void deconstify_tree(tree node);
95670 +
95671 +static void deconstify_type(tree type)
95672 +{
95673 + tree field;
95674 +
95675 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
95676 +
95677 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
95678 + const_tree fieldtype = get_field_type(field);
95679 +
95680 + // special case handling of simple ptr-to-same-array-type members
95681 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
95682 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
95683 +
95684 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
95685 + continue;
95686 + if (TREE_TYPE(TREE_TYPE(field)) == type)
95687 + continue;
95688 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
95689 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
95690 + TREE_TYPE(TREE_TYPE(field)) = type;
95691 + }
95692 + continue;
95693 + }
95694 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
95695 + continue;
95696 + if (!constified(fieldtype))
95697 + continue;
95698 +
95699 + deconstify_tree(field);
95700 + TREE_READONLY(field) = 0;
95701 + }
95702 + TYPE_READONLY(type) = 0;
95703 + C_TYPE_FIELDS_READONLY(type) = 0;
95704 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95705 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
95706 +}
95707 +
95708 +static void deconstify_tree(tree node)
95709 +{
95710 + tree old_type, new_type, field;
95711 +
95712 + old_type = TREE_TYPE(node);
95713 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
95714 + node = TREE_TYPE(node) = copy_node(old_type);
95715 + old_type = TREE_TYPE(old_type);
95716 + }
95717 +
95718 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
95719 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
95720 +
95721 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
95722 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
95723 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
95724 + DECL_FIELD_CONTEXT(field) = new_type;
95725 +
95726 + deconstify_type(new_type);
95727 +
95728 + TREE_TYPE(node) = new_type;
95729 +}
95730 +
95731 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95732 +{
95733 + tree type;
95734 + constify_info cinfo = {
95735 + .has_fptr_field = false,
95736 + .has_writable_field = false,
95737 + .has_do_const_field = false,
95738 + .has_no_const_field = false
95739 + };
95740 +
95741 + *no_add_attrs = true;
95742 + if (TREE_CODE(*node) == FUNCTION_DECL) {
95743 + error("%qE attribute does not apply to functions", name);
95744 + return NULL_TREE;
95745 + }
95746 +
95747 + if (TREE_CODE(*node) == PARM_DECL) {
95748 + error("%qE attribute does not apply to function parameters", name);
95749 + return NULL_TREE;
95750 + }
95751 +
95752 + if (TREE_CODE(*node) == VAR_DECL) {
95753 + error("%qE attribute does not apply to variables", name);
95754 + return NULL_TREE;
95755 + }
95756 +
95757 + if (TYPE_P(*node)) {
95758 + *no_add_attrs = false;
95759 + type = *node;
95760 + } else {
95761 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
95762 + type = TREE_TYPE(*node);
95763 + }
95764 +
95765 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
95766 + error("%qE attribute applies to struct and union types only", name);
95767 + return NULL_TREE;
95768 + }
95769 +
95770 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
95771 + error("%qE attribute is already applied to the type", name);
95772 + return NULL_TREE;
95773 + }
95774 +
95775 + if (TYPE_P(*node)) {
95776 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95777 + error("%qE attribute is incompatible with 'do_const'", name);
95778 + return NULL_TREE;
95779 + }
95780 +
95781 + constifiable(type, &cinfo);
95782 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
95783 + deconstify_tree(*node);
95784 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
95785 + return NULL_TREE;
95786 + }
95787 +
95788 + error("%qE attribute used on type that is not constified", name);
95789 + return NULL_TREE;
95790 +}
95791 +
95792 +static void constify_type(tree type)
95793 +{
95794 + TYPE_READONLY(type) = 1;
95795 + C_TYPE_FIELDS_READONLY(type) = 1;
95796 + TYPE_CONSTIFY_VISITED(type) = 1;
95797 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
95798 +}
95799 +
95800 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95801 +{
95802 + *no_add_attrs = true;
95803 + if (!TYPE_P(*node)) {
95804 + error("%qE attribute applies to types only", name);
95805 + return NULL_TREE;
95806 + }
95807 +
95808 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
95809 + error("%qE attribute applies to struct and union types only", name);
95810 + return NULL_TREE;
95811 + }
95812 +
95813 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
95814 + error("%qE attribute is already applied to the type", name);
95815 + return NULL_TREE;
95816 + }
95817 +
95818 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
95819 + error("%qE attribute is incompatible with 'no_const'", name);
95820 + return NULL_TREE;
95821 + }
95822 +
95823 + *no_add_attrs = false;
95824 + return NULL_TREE;
95825 +}
95826 +
95827 +static struct attribute_spec no_const_attr = {
95828 + .name = "no_const",
95829 + .min_length = 0,
95830 + .max_length = 0,
95831 + .decl_required = false,
95832 + .type_required = false,
95833 + .function_type_required = false,
95834 + .handler = handle_no_const_attribute,
95835 +#if BUILDING_GCC_VERSION >= 4007
95836 + .affects_type_identity = true
95837 +#endif
95838 +};
95839 +
95840 +static struct attribute_spec do_const_attr = {
95841 + .name = "do_const",
95842 + .min_length = 0,
95843 + .max_length = 0,
95844 + .decl_required = false,
95845 + .type_required = false,
95846 + .function_type_required = false,
95847 + .handler = handle_do_const_attribute,
95848 +#if BUILDING_GCC_VERSION >= 4007
95849 + .affects_type_identity = true
95850 +#endif
95851 +};
95852 +
95853 +static void register_attributes(void *event_data, void *data)
95854 +{
95855 + register_attribute(&no_const_attr);
95856 + register_attribute(&do_const_attr);
95857 +}
95858 +
95859 +static void finish_type(void *event_data, void *data)
95860 +{
95861 + tree type = (tree)event_data;
95862 + constify_info cinfo = {
95863 + .has_fptr_field = false,
95864 + .has_writable_field = false,
95865 + .has_do_const_field = false,
95866 + .has_no_const_field = false
95867 + };
95868 +
95869 + if (type == NULL_TREE || type == error_mark_node)
95870 + return;
95871 +
95872 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
95873 + return;
95874 +
95875 + constifiable(type, &cinfo);
95876 +
95877 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
95878 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
95879 + return;
95880 + if (cinfo.has_writable_field)
95881 + return;
95882 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
95883 + return;
95884 + }
95885 +
95886 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
95887 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
95888 + deconstify_type(type);
95889 + TYPE_CONSTIFY_VISITED(type) = 1;
95890 + } else
95891 + error("'no_const' attribute used on type that is not constified");
95892 + return;
95893 + }
95894 +
95895 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
95896 + constify_type(type);
95897 + return;
95898 + }
95899 +
95900 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
95901 + constify_type(type);
95902 + return;
95903 + }
95904 +
95905 + deconstify_type(type);
95906 + TYPE_CONSTIFY_VISITED(type) = 1;
95907 +}
95908 +
95909 +static void check_global_variables(void)
95910 +{
95911 + struct varpool_node *node;
95912 +
95913 +#if BUILDING_GCC_VERSION <= 4007
95914 + for (node = varpool_nodes; node; node = node->next) {
95915 + tree var = node->decl;
95916 +#else
95917 + FOR_EACH_VARIABLE(node) {
95918 + tree var = node->symbol.decl;
95919 +#endif
95920 + tree type = TREE_TYPE(var);
95921 +
95922 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95923 + continue;
95924 +
95925 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95926 + continue;
95927 +
95928 + if (!TYPE_CONSTIFY_VISITED(type))
95929 + continue;
95930 +
95931 + if (DECL_EXTERNAL(var))
95932 + continue;
95933 +
95934 + if (DECL_INITIAL(var))
95935 + continue;
95936 +
95937 + // this works around a gcc bug/feature where uninitialized globals
95938 + // are moved into the .bss section regardless of any constification
95939 + DECL_INITIAL(var) = build_constructor(type, NULL);
95940 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
95941 + }
95942 +}
95943 +
95944 +static unsigned int check_local_variables(void)
95945 +{
95946 + unsigned int ret = 0;
95947 + tree var;
95948 +
95949 +#if BUILDING_GCC_VERSION == 4005
95950 + tree vars;
95951 +#else
95952 + unsigned int i;
95953 +#endif
95954 +
95955 +#if BUILDING_GCC_VERSION == 4005
95956 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
95957 + var = TREE_VALUE(vars);
95958 +#else
95959 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
95960 +#endif
95961 + tree type = TREE_TYPE(var);
95962 +
95963 + gcc_assert(DECL_P(var));
95964 + if (is_global_var(var))
95965 + continue;
95966 +
95967 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
95968 + continue;
95969 +
95970 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
95971 + continue;
95972 +
95973 + if (!TYPE_CONSTIFY_VISITED(type))
95974 + continue;
95975 +
95976 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
95977 + ret = 1;
95978 + }
95979 + return ret;
95980 +}
95981 +
95982 +static unsigned int check_variables(void)
95983 +{
95984 + check_global_variables();
95985 + return check_local_variables();
95986 +}
95987 +
95988 + unsigned int ret = 0;
95989 +static struct gimple_opt_pass pass_local_variable = {
95990 + {
95991 + .type = GIMPLE_PASS,
95992 + .name = "check_variables",
95993 +#if BUILDING_GCC_VERSION >= 4008
95994 + .optinfo_flags = OPTGROUP_NONE,
95995 +#endif
95996 + .gate = NULL,
95997 + .execute = check_variables,
95998 + .sub = NULL,
95999 + .next = NULL,
96000 + .static_pass_number = 0,
96001 + .tv_id = TV_NONE,
96002 + .properties_required = 0,
96003 + .properties_provided = 0,
96004 + .properties_destroyed = 0,
96005 + .todo_flags_start = 0,
96006 + .todo_flags_finish = 0
96007 + }
96008 +};
96009 +
96010 +static struct {
96011 + const char *name;
96012 + const char *asm_op;
96013 +} sections[] = {
96014 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
96015 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
96016 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
96017 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
96018 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
96019 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
96020 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
96021 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
96022 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
96023 +};
96024 +
96025 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
96026 +
96027 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
96028 +{
96029 + size_t i;
96030 +
96031 + for (i = 0; i < ARRAY_SIZE(sections); i++)
96032 + if (!strcmp(sections[i].name, name))
96033 + return 0;
96034 + return old_section_type_flags(decl, name, reloc);
96035 +}
96036 +
96037 +static void constify_start_unit(void *gcc_data, void *user_data)
96038 +{
96039 +// size_t i;
96040 +
96041 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
96042 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
96043 +// sections[i].section = get_section(sections[i].name, 0, NULL);
96044 +
96045 + old_section_type_flags = targetm.section_type_flags;
96046 + targetm.section_type_flags = constify_section_type_flags;
96047 +}
96048 +
96049 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96050 +{
96051 + const char * const plugin_name = plugin_info->base_name;
96052 + const int argc = plugin_info->argc;
96053 + const struct plugin_argument * const argv = plugin_info->argv;
96054 + int i;
96055 + bool constify = true;
96056 +
96057 + struct register_pass_info local_variable_pass_info = {
96058 + .pass = &pass_local_variable.pass,
96059 + .reference_pass_name = "ssa",
96060 + .ref_pass_instance_number = 1,
96061 + .pos_op = PASS_POS_INSERT_BEFORE
96062 + };
96063 +
96064 + if (!plugin_default_version_check(version, &gcc_version)) {
96065 + error(G_("incompatible gcc/plugin versions"));
96066 + return 1;
96067 + }
96068 +
96069 + for (i = 0; i < argc; ++i) {
96070 + if (!(strcmp(argv[i].key, "no-constify"))) {
96071 + constify = false;
96072 + continue;
96073 + }
96074 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96075 + }
96076 +
96077 + if (strcmp(lang_hooks.name, "GNU C")) {
96078 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
96079 + constify = false;
96080 + }
96081 +
96082 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
96083 + if (constify) {
96084 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
96085 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
96086 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
96087 + }
96088 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
96089 +
96090 + return 0;
96091 +}
96092 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
96093 new file mode 100644
96094 index 0000000..e518932
96095 --- /dev/null
96096 +++ b/tools/gcc/generate_size_overflow_hash.sh
96097 @@ -0,0 +1,94 @@
96098 +#!/bin/bash
96099 +
96100 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
96101 +
96102 +header1="size_overflow_hash.h"
96103 +database="size_overflow_hash.data"
96104 +n=65536
96105 +
96106 +usage() {
96107 +cat <<EOF
96108 +usage: $0 options
96109 +OPTIONS:
96110 + -h|--help help
96111 + -o header file
96112 + -d database file
96113 + -n hash array size
96114 +EOF
96115 + return 0
96116 +}
96117 +
96118 +while true
96119 +do
96120 + case "$1" in
96121 + -h|--help) usage && exit 0;;
96122 + -n) n=$2; shift 2;;
96123 + -o) header1="$2"; shift 2;;
96124 + -d) database="$2"; shift 2;;
96125 + --) shift 1; break ;;
96126 + *) break ;;
96127 + esac
96128 +done
96129 +
96130 +create_defines() {
96131 + for i in `seq 0 31`
96132 + do
96133 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
96134 + done
96135 + echo >> "$header1"
96136 +}
96137 +
96138 +create_structs() {
96139 + rm -f "$header1"
96140 +
96141 + create_defines
96142 +
96143 + cat "$database" | while read data
96144 + do
96145 + data_array=($data)
96146 + struct_hash_name="${data_array[0]}"
96147 + funcn="${data_array[1]}"
96148 + params="${data_array[2]}"
96149 + next="${data_array[4]}"
96150 +
96151 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
96152 +
96153 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
96154 + echo -en "\t.param\t= " >> "$header1"
96155 + line=
96156 + for param_num in ${params//-/ };
96157 + do
96158 + line="${line}PARAM"$param_num"|"
96159 + done
96160 +
96161 + echo -e "${line%?},\n};\n" >> "$header1"
96162 + done
96163 +}
96164 +
96165 +create_headers() {
96166 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
96167 +}
96168 +
96169 +create_array_elements() {
96170 + index=0
96171 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
96172 + do
96173 + data_array=($data)
96174 + i="${data_array[3]}"
96175 + hash="${data_array[0]}"
96176 + while [[ $index -lt $i ]]
96177 + do
96178 + echo -e "\t["$index"]\t= NULL," >> "$header1"
96179 + index=$(($index + 1))
96180 + done
96181 + index=$(($index + 1))
96182 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
96183 + done
96184 + echo '};' >> $header1
96185 +}
96186 +
96187 +create_structs
96188 +create_headers
96189 +create_array_elements
96190 +
96191 +exit 0
96192 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
96193 new file mode 100644
96194 index 0000000..568b360
96195 --- /dev/null
96196 +++ b/tools/gcc/kallocstat_plugin.c
96197 @@ -0,0 +1,170 @@
96198 +/*
96199 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
96200 + * Licensed under the GPL v2
96201 + *
96202 + * Note: the choice of the license means that the compilation process is
96203 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96204 + * but for the kernel it doesn't matter since it doesn't link against
96205 + * any of the gcc libraries
96206 + *
96207 + * gcc plugin to find the distribution of k*alloc sizes
96208 + *
96209 + * TODO:
96210 + *
96211 + * BUGS:
96212 + * - none known
96213 + */
96214 +#include "gcc-plugin.h"
96215 +#include "config.h"
96216 +#include "system.h"
96217 +#include "coretypes.h"
96218 +#include "tree.h"
96219 +#include "tree-pass.h"
96220 +#include "flags.h"
96221 +#include "intl.h"
96222 +#include "toplev.h"
96223 +#include "plugin.h"
96224 +//#include "expr.h" where are you...
96225 +#include "diagnostic.h"
96226 +#include "plugin-version.h"
96227 +#include "tm.h"
96228 +#include "function.h"
96229 +#include "basic-block.h"
96230 +#include "gimple.h"
96231 +#include "rtl.h"
96232 +#include "emit-rtl.h"
96233 +
96234 +extern void print_gimple_stmt(FILE *, gimple, int, int);
96235 +
96236 +int plugin_is_GPL_compatible;
96237 +
96238 +static const char * const kalloc_functions[] = {
96239 + "__kmalloc",
96240 + "kmalloc",
96241 + "kmalloc_large",
96242 + "kmalloc_node",
96243 + "kmalloc_order",
96244 + "kmalloc_order_trace",
96245 + "kmalloc_slab",
96246 + "kzalloc",
96247 + "kzalloc_node",
96248 +};
96249 +
96250 +static struct plugin_info kallocstat_plugin_info = {
96251 + .version = "201302112000",
96252 +};
96253 +
96254 +static unsigned int execute_kallocstat(void);
96255 +
96256 +static struct gimple_opt_pass kallocstat_pass = {
96257 + .pass = {
96258 + .type = GIMPLE_PASS,
96259 + .name = "kallocstat",
96260 +#if BUILDING_GCC_VERSION >= 4008
96261 + .optinfo_flags = OPTGROUP_NONE,
96262 +#endif
96263 + .gate = NULL,
96264 + .execute = execute_kallocstat,
96265 + .sub = NULL,
96266 + .next = NULL,
96267 + .static_pass_number = 0,
96268 + .tv_id = TV_NONE,
96269 + .properties_required = 0,
96270 + .properties_provided = 0,
96271 + .properties_destroyed = 0,
96272 + .todo_flags_start = 0,
96273 + .todo_flags_finish = 0
96274 + }
96275 +};
96276 +
96277 +static bool is_kalloc(const char *fnname)
96278 +{
96279 + size_t i;
96280 +
96281 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
96282 + if (!strcmp(fnname, kalloc_functions[i]))
96283 + return true;
96284 + return false;
96285 +}
96286 +
96287 +static unsigned int execute_kallocstat(void)
96288 +{
96289 + basic_block bb;
96290 +
96291 + // 1. loop through BBs and GIMPLE statements
96292 + FOR_EACH_BB(bb) {
96293 + gimple_stmt_iterator gsi;
96294 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96295 + // gimple match:
96296 + tree fndecl, size;
96297 + gimple call_stmt;
96298 + const char *fnname;
96299 +
96300 + // is it a call
96301 + call_stmt = gsi_stmt(gsi);
96302 + if (!is_gimple_call(call_stmt))
96303 + continue;
96304 + fndecl = gimple_call_fndecl(call_stmt);
96305 + if (fndecl == NULL_TREE)
96306 + continue;
96307 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
96308 + continue;
96309 +
96310 + // is it a call to k*alloc
96311 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
96312 + if (!is_kalloc(fnname))
96313 + continue;
96314 +
96315 + // is the size arg the result of a simple const assignment
96316 + size = gimple_call_arg(call_stmt, 0);
96317 + while (true) {
96318 + gimple def_stmt;
96319 + expanded_location xloc;
96320 + size_t size_val;
96321 +
96322 + if (TREE_CODE(size) != SSA_NAME)
96323 + break;
96324 + def_stmt = SSA_NAME_DEF_STMT(size);
96325 + if (!def_stmt || !is_gimple_assign(def_stmt))
96326 + break;
96327 + if (gimple_num_ops(def_stmt) != 2)
96328 + break;
96329 + size = gimple_assign_rhs1(def_stmt);
96330 + if (!TREE_CONSTANT(size))
96331 + continue;
96332 + xloc = expand_location(gimple_location(def_stmt));
96333 + if (!xloc.file)
96334 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
96335 + size_val = TREE_INT_CST_LOW(size);
96336 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
96337 + break;
96338 + }
96339 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
96340 +//debug_tree(gimple_call_fn(call_stmt));
96341 +//print_node(stderr, "pax", fndecl, 4);
96342 + }
96343 + }
96344 +
96345 + return 0;
96346 +}
96347 +
96348 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96349 +{
96350 + const char * const plugin_name = plugin_info->base_name;
96351 + struct register_pass_info kallocstat_pass_info = {
96352 + .pass = &kallocstat_pass.pass,
96353 + .reference_pass_name = "ssa",
96354 + .ref_pass_instance_number = 1,
96355 + .pos_op = PASS_POS_INSERT_AFTER
96356 + };
96357 +
96358 + if (!plugin_default_version_check(version, &gcc_version)) {
96359 + error(G_("incompatible gcc/plugin versions"));
96360 + return 1;
96361 + }
96362 +
96363 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
96364 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
96365 +
96366 + return 0;
96367 +}
96368 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
96369 new file mode 100644
96370 index 0000000..0408e06
96371 --- /dev/null
96372 +++ b/tools/gcc/kernexec_plugin.c
96373 @@ -0,0 +1,465 @@
96374 +/*
96375 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
96376 + * Licensed under the GPL v2
96377 + *
96378 + * Note: the choice of the license means that the compilation process is
96379 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96380 + * but for the kernel it doesn't matter since it doesn't link against
96381 + * any of the gcc libraries
96382 + *
96383 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
96384 + *
96385 + * TODO:
96386 + *
96387 + * BUGS:
96388 + * - none known
96389 + */
96390 +#include "gcc-plugin.h"
96391 +#include "config.h"
96392 +#include "system.h"
96393 +#include "coretypes.h"
96394 +#include "tree.h"
96395 +#include "tree-pass.h"
96396 +#include "flags.h"
96397 +#include "intl.h"
96398 +#include "toplev.h"
96399 +#include "plugin.h"
96400 +//#include "expr.h" where are you...
96401 +#include "diagnostic.h"
96402 +#include "plugin-version.h"
96403 +#include "tm.h"
96404 +#include "function.h"
96405 +#include "basic-block.h"
96406 +#include "gimple.h"
96407 +#include "rtl.h"
96408 +#include "emit-rtl.h"
96409 +#include "tree-flow.h"
96410 +
96411 +extern void print_gimple_stmt(FILE *, gimple, int, int);
96412 +extern rtx emit_move_insn(rtx x, rtx y);
96413 +
96414 +#if BUILDING_GCC_VERSION <= 4006
96415 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
96416 +#endif
96417 +
96418 +#if BUILDING_GCC_VERSION >= 4008
96419 +#define TODO_dump_func 0
96420 +#endif
96421 +
96422 +int plugin_is_GPL_compatible;
96423 +
96424 +static struct plugin_info kernexec_plugin_info = {
96425 + .version = "201302112000",
96426 + .help = "method=[bts|or]\tinstrumentation method\n"
96427 +};
96428 +
96429 +static unsigned int execute_kernexec_reload(void);
96430 +static unsigned int execute_kernexec_fptr(void);
96431 +static unsigned int execute_kernexec_retaddr(void);
96432 +static bool kernexec_cmodel_check(void);
96433 +
96434 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
96435 +static void (*kernexec_instrument_retaddr)(rtx);
96436 +
96437 +static struct gimple_opt_pass kernexec_reload_pass = {
96438 + .pass = {
96439 + .type = GIMPLE_PASS,
96440 + .name = "kernexec_reload",
96441 +#if BUILDING_GCC_VERSION >= 4008
96442 + .optinfo_flags = OPTGROUP_NONE,
96443 +#endif
96444 + .gate = kernexec_cmodel_check,
96445 + .execute = execute_kernexec_reload,
96446 + .sub = NULL,
96447 + .next = NULL,
96448 + .static_pass_number = 0,
96449 + .tv_id = TV_NONE,
96450 + .properties_required = 0,
96451 + .properties_provided = 0,
96452 + .properties_destroyed = 0,
96453 + .todo_flags_start = 0,
96454 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
96455 + }
96456 +};
96457 +
96458 +static struct gimple_opt_pass kernexec_fptr_pass = {
96459 + .pass = {
96460 + .type = GIMPLE_PASS,
96461 + .name = "kernexec_fptr",
96462 +#if BUILDING_GCC_VERSION >= 4008
96463 + .optinfo_flags = OPTGROUP_NONE,
96464 +#endif
96465 + .gate = kernexec_cmodel_check,
96466 + .execute = execute_kernexec_fptr,
96467 + .sub = NULL,
96468 + .next = NULL,
96469 + .static_pass_number = 0,
96470 + .tv_id = TV_NONE,
96471 + .properties_required = 0,
96472 + .properties_provided = 0,
96473 + .properties_destroyed = 0,
96474 + .todo_flags_start = 0,
96475 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
96476 + }
96477 +};
96478 +
96479 +static struct rtl_opt_pass kernexec_retaddr_pass = {
96480 + .pass = {
96481 + .type = RTL_PASS,
96482 + .name = "kernexec_retaddr",
96483 +#if BUILDING_GCC_VERSION >= 4008
96484 + .optinfo_flags = OPTGROUP_NONE,
96485 +#endif
96486 + .gate = kernexec_cmodel_check,
96487 + .execute = execute_kernexec_retaddr,
96488 + .sub = NULL,
96489 + .next = NULL,
96490 + .static_pass_number = 0,
96491 + .tv_id = TV_NONE,
96492 + .properties_required = 0,
96493 + .properties_provided = 0,
96494 + .properties_destroyed = 0,
96495 + .todo_flags_start = 0,
96496 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
96497 + }
96498 +};
96499 +
96500 +static bool kernexec_cmodel_check(void)
96501 +{
96502 + tree section;
96503 +
96504 + if (ix86_cmodel != CM_KERNEL)
96505 + return false;
96506 +
96507 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
96508 + if (!section || !TREE_VALUE(section))
96509 + return true;
96510 +
96511 + section = TREE_VALUE(TREE_VALUE(section));
96512 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
96513 + return true;
96514 +
96515 + return false;
96516 +}
96517 +
96518 +/*
96519 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
96520 + */
96521 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
96522 +{
96523 + gimple asm_movabs_stmt;
96524 +
96525 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
96526 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
96527 + gimple_asm_set_volatile(asm_movabs_stmt, true);
96528 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
96529 + update_stmt(asm_movabs_stmt);
96530 +}
96531 +
96532 +/*
96533 + * find all asm() stmts that clobber r10 and add a reload of r10
96534 + */
96535 +static unsigned int execute_kernexec_reload(void)
96536 +{
96537 + basic_block bb;
96538 +
96539 + // 1. loop through BBs and GIMPLE statements
96540 + FOR_EACH_BB(bb) {
96541 + gimple_stmt_iterator gsi;
96542 +
96543 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96544 + // gimple match: __asm__ ("" : : : "r10");
96545 + gimple asm_stmt;
96546 + size_t nclobbers;
96547 +
96548 + // is it an asm ...
96549 + asm_stmt = gsi_stmt(gsi);
96550 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
96551 + continue;
96552 +
96553 + // ... clobbering r10
96554 + nclobbers = gimple_asm_nclobbers(asm_stmt);
96555 + while (nclobbers--) {
96556 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
96557 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
96558 + continue;
96559 + kernexec_reload_fptr_mask(&gsi);
96560 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
96561 + break;
96562 + }
96563 + }
96564 + }
96565 +
96566 + return 0;
96567 +}
96568 +
96569 +/*
96570 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
96571 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
96572 + */
96573 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
96574 +{
96575 + gimple assign_intptr, assign_new_fptr, call_stmt;
96576 + tree intptr, old_fptr, new_fptr, kernexec_mask;
96577 +
96578 + call_stmt = gsi_stmt(*gsi);
96579 + old_fptr = gimple_call_fn(call_stmt);
96580 +
96581 + // create temporary unsigned long variable used for bitops and cast fptr to it
96582 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
96583 +#if BUILDING_GCC_VERSION <= 4007
96584 + add_referenced_var(intptr);
96585 + mark_sym_for_renaming(intptr);
96586 +#endif
96587 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
96588 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
96589 + update_stmt(assign_intptr);
96590 +
96591 + // apply logical or to temporary unsigned long and bitmask
96592 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
96593 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
96594 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
96595 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
96596 + update_stmt(assign_intptr);
96597 +
96598 + // cast temporary unsigned long back to a temporary fptr variable
96599 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
96600 +#if BUILDING_GCC_VERSION <= 4007
96601 + add_referenced_var(new_fptr);
96602 + mark_sym_for_renaming(new_fptr);
96603 +#endif
96604 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
96605 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
96606 + update_stmt(assign_new_fptr);
96607 +
96608 + // replace call stmt fn with the new fptr
96609 + gimple_call_set_fn(call_stmt, new_fptr);
96610 + update_stmt(call_stmt);
96611 +}
96612 +
96613 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
96614 +{
96615 + gimple asm_or_stmt, call_stmt;
96616 + tree old_fptr, new_fptr, input, output;
96617 +#if BUILDING_GCC_VERSION <= 4007
96618 + VEC(tree, gc) *inputs = NULL;
96619 + VEC(tree, gc) *outputs = NULL;
96620 +#else
96621 + vec<tree, va_gc> *inputs = NULL;
96622 + vec<tree, va_gc> *outputs = NULL;
96623 +#endif
96624 +
96625 + call_stmt = gsi_stmt(*gsi);
96626 + old_fptr = gimple_call_fn(call_stmt);
96627 +
96628 + // create temporary fptr variable
96629 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
96630 +#if BUILDING_GCC_VERSION <= 4007
96631 + add_referenced_var(new_fptr);
96632 + mark_sym_for_renaming(new_fptr);
96633 +#endif
96634 +
96635 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
96636 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
96637 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
96638 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
96639 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
96640 +#if BUILDING_GCC_VERSION <= 4007
96641 + VEC_safe_push(tree, gc, inputs, input);
96642 + VEC_safe_push(tree, gc, outputs, output);
96643 +#else
96644 + vec_safe_push(inputs, input);
96645 + vec_safe_push(outputs, output);
96646 +#endif
96647 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
96648 + gimple_asm_set_volatile(asm_or_stmt, true);
96649 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
96650 + update_stmt(asm_or_stmt);
96651 +
96652 + // replace call stmt fn with the new fptr
96653 + gimple_call_set_fn(call_stmt, new_fptr);
96654 + update_stmt(call_stmt);
96655 +}
96656 +
96657 +/*
96658 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
96659 + */
96660 +static unsigned int execute_kernexec_fptr(void)
96661 +{
96662 + basic_block bb;
96663 +
96664 + // 1. loop through BBs and GIMPLE statements
96665 + FOR_EACH_BB(bb) {
96666 + gimple_stmt_iterator gsi;
96667 +
96668 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
96669 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
96670 + tree fn;
96671 + gimple call_stmt;
96672 +
96673 + // is it a call ...
96674 + call_stmt = gsi_stmt(gsi);
96675 + if (!is_gimple_call(call_stmt))
96676 + continue;
96677 + fn = gimple_call_fn(call_stmt);
96678 + if (TREE_CODE(fn) == ADDR_EXPR)
96679 + continue;
96680 + if (TREE_CODE(fn) != SSA_NAME)
96681 + gcc_unreachable();
96682 +
96683 + // ... through a function pointer
96684 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
96685 + fn = SSA_NAME_VAR(fn);
96686 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
96687 + debug_tree(fn);
96688 + gcc_unreachable();
96689 + }
96690 + }
96691 + fn = TREE_TYPE(fn);
96692 + if (TREE_CODE(fn) != POINTER_TYPE)
96693 + continue;
96694 + fn = TREE_TYPE(fn);
96695 + if (TREE_CODE(fn) != FUNCTION_TYPE)
96696 + continue;
96697 +
96698 + kernexec_instrument_fptr(&gsi);
96699 +
96700 +//debug_tree(gimple_call_fn(call_stmt));
96701 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
96702 + }
96703 + }
96704 +
96705 + return 0;
96706 +}
96707 +
96708 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
96709 +static void kernexec_instrument_retaddr_bts(rtx insn)
96710 +{
96711 + rtx btsq;
96712 + rtvec argvec, constraintvec, labelvec;
96713 + int line;
96714 +
96715 + // create asm volatile("btsq $63,(%%rsp)":::)
96716 + argvec = rtvec_alloc(0);
96717 + constraintvec = rtvec_alloc(0);
96718 + labelvec = rtvec_alloc(0);
96719 + line = expand_location(RTL_LOCATION(insn)).line;
96720 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
96721 + MEM_VOLATILE_P(btsq) = 1;
96722 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
96723 + emit_insn_before(btsq, insn);
96724 +}
96725 +
96726 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
96727 +static void kernexec_instrument_retaddr_or(rtx insn)
96728 +{
96729 + rtx orq;
96730 + rtvec argvec, constraintvec, labelvec;
96731 + int line;
96732 +
96733 + // create asm volatile("orq %%r10,(%%rsp)":::)
96734 + argvec = rtvec_alloc(0);
96735 + constraintvec = rtvec_alloc(0);
96736 + labelvec = rtvec_alloc(0);
96737 + line = expand_location(RTL_LOCATION(insn)).line;
96738 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
96739 + MEM_VOLATILE_P(orq) = 1;
96740 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
96741 + emit_insn_before(orq, insn);
96742 +}
96743 +
96744 +/*
96745 + * find all asm level function returns and forcibly set the highest bit of the return address
96746 + */
96747 +static unsigned int execute_kernexec_retaddr(void)
96748 +{
96749 + rtx insn;
96750 +
96751 + // 1. find function returns
96752 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
96753 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
96754 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
96755 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
96756 + rtx body;
96757 +
96758 + // is it a retn
96759 + if (!JUMP_P(insn))
96760 + continue;
96761 + body = PATTERN(insn);
96762 + if (GET_CODE(body) == PARALLEL)
96763 + body = XVECEXP(body, 0, 0);
96764 + if (!ANY_RETURN_P(body))
96765 + continue;
96766 + kernexec_instrument_retaddr(insn);
96767 + }
96768 +
96769 +// print_simple_rtl(stderr, get_insns());
96770 +// print_rtl(stderr, get_insns());
96771 +
96772 + return 0;
96773 +}
96774 +
96775 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
96776 +{
96777 + const char * const plugin_name = plugin_info->base_name;
96778 + const int argc = plugin_info->argc;
96779 + const struct plugin_argument * const argv = plugin_info->argv;
96780 + int i;
96781 + struct register_pass_info kernexec_reload_pass_info = {
96782 + .pass = &kernexec_reload_pass.pass,
96783 + .reference_pass_name = "ssa",
96784 + .ref_pass_instance_number = 1,
96785 + .pos_op = PASS_POS_INSERT_AFTER
96786 + };
96787 + struct register_pass_info kernexec_fptr_pass_info = {
96788 + .pass = &kernexec_fptr_pass.pass,
96789 + .reference_pass_name = "ssa",
96790 + .ref_pass_instance_number = 1,
96791 + .pos_op = PASS_POS_INSERT_AFTER
96792 + };
96793 + struct register_pass_info kernexec_retaddr_pass_info = {
96794 + .pass = &kernexec_retaddr_pass.pass,
96795 + .reference_pass_name = "pro_and_epilogue",
96796 + .ref_pass_instance_number = 1,
96797 + .pos_op = PASS_POS_INSERT_AFTER
96798 + };
96799 +
96800 + if (!plugin_default_version_check(version, &gcc_version)) {
96801 + error(G_("incompatible gcc/plugin versions"));
96802 + return 1;
96803 + }
96804 +
96805 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
96806 +
96807 + if (TARGET_64BIT == 0)
96808 + return 0;
96809 +
96810 + for (i = 0; i < argc; ++i) {
96811 + if (!strcmp(argv[i].key, "method")) {
96812 + if (!argv[i].value) {
96813 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96814 + continue;
96815 + }
96816 + if (!strcmp(argv[i].value, "bts")) {
96817 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
96818 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
96819 + } else if (!strcmp(argv[i].value, "or")) {
96820 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
96821 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
96822 + fix_register("r10", 1, 1);
96823 + } else
96824 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
96825 + continue;
96826 + }
96827 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
96828 + }
96829 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
96830 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
96831 +
96832 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
96833 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
96834 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
96835 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
96836 +
96837 + return 0;
96838 +}
96839 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
96840 new file mode 100644
96841 index 0000000..b5395ba
96842 --- /dev/null
96843 +++ b/tools/gcc/latent_entropy_plugin.c
96844 @@ -0,0 +1,327 @@
96845 +/*
96846 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
96847 + * Licensed under the GPL v2
96848 + *
96849 + * Note: the choice of the license means that the compilation process is
96850 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
96851 + * but for the kernel it doesn't matter since it doesn't link against
96852 + * any of the gcc libraries
96853 + *
96854 + * gcc plugin to help generate a little bit of entropy from program state,
96855 + * used during boot in the kernel
96856 + *
96857 + * TODO:
96858 + * - add ipa pass to identify not explicitly marked candidate functions
96859 + * - mix in more program state (function arguments/return values, loop variables, etc)
96860 + * - more instrumentation control via attribute parameters
96861 + *
96862 + * BUGS:
96863 + * - LTO needs -flto-partition=none for now
96864 + */
96865 +#include "gcc-plugin.h"
96866 +#include "config.h"
96867 +#include "system.h"
96868 +#include "coretypes.h"
96869 +#include "tree.h"
96870 +#include "tree-pass.h"
96871 +#include "flags.h"
96872 +#include "intl.h"
96873 +#include "toplev.h"
96874 +#include "plugin.h"
96875 +//#include "expr.h" where are you...
96876 +#include "diagnostic.h"
96877 +#include "plugin-version.h"
96878 +#include "tm.h"
96879 +#include "function.h"
96880 +#include "basic-block.h"
96881 +#include "gimple.h"
96882 +#include "rtl.h"
96883 +#include "emit-rtl.h"
96884 +#include "tree-flow.h"
96885 +#include "langhooks.h"
96886 +
96887 +#if BUILDING_GCC_VERSION >= 4008
96888 +#define TODO_dump_func 0
96889 +#endif
96890 +
96891 +int plugin_is_GPL_compatible;
96892 +
96893 +static tree latent_entropy_decl;
96894 +
96895 +static struct plugin_info latent_entropy_plugin_info = {
96896 + .version = "201303102320",
96897 + .help = NULL
96898 +};
96899 +
96900 +static unsigned int execute_latent_entropy(void);
96901 +static bool gate_latent_entropy(void);
96902 +
96903 +static struct gimple_opt_pass latent_entropy_pass = {
96904 + .pass = {
96905 + .type = GIMPLE_PASS,
96906 + .name = "latent_entropy",
96907 +#if BUILDING_GCC_VERSION >= 4008
96908 + .optinfo_flags = OPTGROUP_NONE,
96909 +#endif
96910 + .gate = gate_latent_entropy,
96911 + .execute = execute_latent_entropy,
96912 + .sub = NULL,
96913 + .next = NULL,
96914 + .static_pass_number = 0,
96915 + .tv_id = TV_NONE,
96916 + .properties_required = PROP_gimple_leh | PROP_cfg,
96917 + .properties_provided = 0,
96918 + .properties_destroyed = 0,
96919 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
96920 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
96921 + }
96922 +};
96923 +
96924 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
96925 +{
96926 + if (TREE_CODE(*node) != FUNCTION_DECL) {
96927 + *no_add_attrs = true;
96928 + error("%qE attribute only applies to functions", name);
96929 + }
96930 + return NULL_TREE;
96931 +}
96932 +
96933 +static struct attribute_spec latent_entropy_attr = {
96934 + .name = "latent_entropy",
96935 + .min_length = 0,
96936 + .max_length = 0,
96937 + .decl_required = true,
96938 + .type_required = false,
96939 + .function_type_required = false,
96940 + .handler = handle_latent_entropy_attribute,
96941 +#if BUILDING_GCC_VERSION >= 4007
96942 + .affects_type_identity = false
96943 +#endif
96944 +};
96945 +
96946 +static void register_attributes(void *event_data, void *data)
96947 +{
96948 + register_attribute(&latent_entropy_attr);
96949 +}
96950 +
96951 +static bool gate_latent_entropy(void)
96952 +{
96953 + tree latent_entropy_attr;
96954 +
96955 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
96956 + return latent_entropy_attr != NULL_TREE;
96957 +}
96958 +
96959 +static unsigned HOST_WIDE_INT seed;
96960 +static unsigned HOST_WIDE_INT get_random_const(void)
96961 +{
96962 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
96963 + return seed;
96964 +}
96965 +
96966 +static enum tree_code get_op(tree *rhs)
96967 +{
96968 + static enum tree_code op;
96969 + unsigned HOST_WIDE_INT random_const;
96970 +
96971 + random_const = get_random_const();
96972 +
96973 + switch (op) {
96974 + case BIT_XOR_EXPR:
96975 + op = PLUS_EXPR;
96976 + break;
96977 +
96978 + case PLUS_EXPR:
96979 + if (rhs) {
96980 + op = LROTATE_EXPR;
96981 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
96982 + break;
96983 + }
96984 +
96985 + case LROTATE_EXPR:
96986 + default:
96987 + op = BIT_XOR_EXPR;
96988 + break;
96989 + }
96990 + if (rhs)
96991 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
96992 + return op;
96993 +}
96994 +
96995 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
96996 +{
96997 + gimple_stmt_iterator gsi;
96998 + gimple assign;
96999 + tree addxorrol, rhs;
97000 + enum tree_code op;
97001 +
97002 + op = get_op(&rhs);
97003 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
97004 + assign = gimple_build_assign(local_entropy, addxorrol);
97005 +#if BUILDING_GCC_VERSION <= 4007
97006 + find_referenced_vars_in(assign);
97007 +#endif
97008 +//debug_bb(bb);
97009 + gsi = gsi_after_labels(bb);
97010 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
97011 + update_stmt(assign);
97012 +}
97013 +
97014 +static void perturb_latent_entropy(basic_block bb, tree rhs)
97015 +{
97016 + gimple_stmt_iterator gsi;
97017 + gimple assign;
97018 + tree addxorrol, temp;
97019 +
97020 + // 1. create temporary copy of latent_entropy
97021 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
97022 +#if BUILDING_GCC_VERSION <= 4007
97023 + add_referenced_var(temp);
97024 + mark_sym_for_renaming(temp);
97025 +#endif
97026 +
97027 + // 2. read...
97028 + assign = gimple_build_assign(temp, latent_entropy_decl);
97029 +#if BUILDING_GCC_VERSION <= 4007
97030 + find_referenced_vars_in(assign);
97031 +#endif
97032 + gsi = gsi_after_labels(bb);
97033 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
97034 + update_stmt(assign);
97035 +
97036 + // 3. ...modify...
97037 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
97038 + assign = gimple_build_assign(temp, addxorrol);
97039 +#if BUILDING_GCC_VERSION <= 4007
97040 + find_referenced_vars_in(assign);
97041 +#endif
97042 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
97043 + update_stmt(assign);
97044 +
97045 + // 4. ...write latent_entropy
97046 + assign = gimple_build_assign(latent_entropy_decl, temp);
97047 +#if BUILDING_GCC_VERSION <= 4007
97048 + find_referenced_vars_in(assign);
97049 +#endif
97050 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
97051 + update_stmt(assign);
97052 +}
97053 +
97054 +static unsigned int execute_latent_entropy(void)
97055 +{
97056 + basic_block bb;
97057 + gimple assign;
97058 + gimple_stmt_iterator gsi;
97059 + tree local_entropy;
97060 +
97061 + if (!latent_entropy_decl) {
97062 + struct varpool_node *node;
97063 +
97064 +#if BUILDING_GCC_VERSION <= 4007
97065 + for (node = varpool_nodes; node; node = node->next) {
97066 + tree var = node->decl;
97067 +#else
97068 + FOR_EACH_VARIABLE(node) {
97069 + tree var = node->symbol.decl;
97070 +#endif
97071 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
97072 + continue;
97073 + latent_entropy_decl = var;
97074 +// debug_tree(var);
97075 + break;
97076 + }
97077 + if (!latent_entropy_decl) {
97078 +// debug_tree(current_function_decl);
97079 + return 0;
97080 + }
97081 + }
97082 +
97083 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
97084 +
97085 + // 1. create local entropy variable
97086 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
97087 +#if BUILDING_GCC_VERSION <= 4007
97088 + add_referenced_var(local_entropy);
97089 + mark_sym_for_renaming(local_entropy);
97090 +#endif
97091 +
97092 + // 2. initialize local entropy variable
97093 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
97094 + if (dom_info_available_p(CDI_DOMINATORS))
97095 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
97096 + gsi = gsi_start_bb(bb);
97097 +
97098 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
97099 +// gimple_set_location(assign, loc);
97100 +#if BUILDING_GCC_VERSION <= 4007
97101 + find_referenced_vars_in(assign);
97102 +#endif
97103 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
97104 + update_stmt(assign);
97105 + bb = bb->next_bb;
97106 +
97107 + // 3. instrument each BB with an operation on the local entropy variable
97108 + while (bb != EXIT_BLOCK_PTR) {
97109 + perturb_local_entropy(bb, local_entropy);
97110 + bb = bb->next_bb;
97111 + };
97112 +
97113 + // 4. mix local entropy into the global entropy variable
97114 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
97115 + return 0;
97116 +}
97117 +
97118 +static void start_unit_callback(void *gcc_data, void *user_data)
97119 +{
97120 + tree latent_entropy_type;
97121 +
97122 +#if BUILDING_GCC_VERSION >= 4007
97123 + seed = get_random_seed(false);
97124 +#else
97125 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
97126 + seed *= seed;
97127 +#endif
97128 +
97129 + if (in_lto_p)
97130 + return;
97131 +
97132 + // extern volatile u64 latent_entropy
97133 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
97134 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
97135 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
97136 +
97137 + TREE_STATIC(latent_entropy_decl) = 1;
97138 + TREE_PUBLIC(latent_entropy_decl) = 1;
97139 + TREE_USED(latent_entropy_decl) = 1;
97140 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
97141 + DECL_EXTERNAL(latent_entropy_decl) = 1;
97142 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
97143 + DECL_INITIAL(latent_entropy_decl) = NULL;
97144 + lang_hooks.decls.pushdecl(latent_entropy_decl);
97145 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
97146 +// varpool_finalize_decl(latent_entropy_decl);
97147 +// varpool_mark_needed_node(latent_entropy_decl);
97148 +}
97149 +
97150 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
97151 +{
97152 + const char * const plugin_name = plugin_info->base_name;
97153 + struct register_pass_info latent_entropy_pass_info = {
97154 + .pass = &latent_entropy_pass.pass,
97155 + .reference_pass_name = "optimized",
97156 + .ref_pass_instance_number = 1,
97157 + .pos_op = PASS_POS_INSERT_BEFORE
97158 + };
97159 +
97160 + if (!plugin_default_version_check(version, &gcc_version)) {
97161 + error(G_("incompatible gcc/plugin versions"));
97162 + return 1;
97163 + }
97164 +
97165 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
97166 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
97167 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
97168 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
97169 +
97170 + return 0;
97171 +}
97172 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
97173 new file mode 100644
97174 index 0000000..b04803b
97175 --- /dev/null
97176 +++ b/tools/gcc/size_overflow_hash.data
97177 @@ -0,0 +1,6350 @@
97178 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
97179 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
97180 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
97181 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
97182 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
97183 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
97184 +padzero_55 padzero 1 55 &sel_read_policyvers_55
97185 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
97186 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
97187 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
97188 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
97189 +load_msg_95 load_msg 2 95 NULL
97190 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
97191 +init_q_132 init_q 4 132 NULL
97192 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
97193 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
97194 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
97195 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
97196 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
97197 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
97198 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
97199 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
97200 +br_port_info_size_268 br_port_info_size 0 268 NULL
97201 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
97202 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
97203 +SYSC_connect_304 SYSC_connect 3 304 NULL
97204 +syslog_print_307 syslog_print 2 307 NULL
97205 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
97206 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
97207 +next_node_allowed_318 next_node_allowed 1 318 NULL
97208 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
97209 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
97210 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
97211 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
97212 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
97213 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
97214 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
97215 +pidlist_resize_496 pidlist_resize 2 496 NULL
97216 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
97217 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
97218 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
97219 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
97220 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
97221 +dle_count_543 dle_count 0 543 NULL
97222 +devres_alloc_551 devres_alloc 2 551 NULL
97223 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
97224 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
97225 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
97226 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
97227 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
97228 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
97229 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
97230 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
97231 +isp1760_register_628 isp1760_register 1-2 628 NULL
97232 +clone_split_bio_633 clone_split_bio 6 633 NULL
97233 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
97234 +remap_to_cache_640 remap_to_cache 3 640 NULL
97235 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
97236 +unlink_queued_645 unlink_queued 3-4 645 NULL
97237 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
97238 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
97239 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
97240 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
97241 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
97242 +disk_max_parts_719 disk_max_parts 0 719 NULL
97243 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
97244 +dvb_video_write_754 dvb_video_write 3 754 NULL
97245 +if_writecmd_815 if_writecmd 2 815 NULL
97246 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
97247 +read_fifo_826 read_fifo 3 826 NULL
97248 +um_idi_read_850 um_idi_read 3 850 NULL
97249 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
97250 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
97251 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
97252 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
97253 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
97254 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
97255 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
97256 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
97257 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
97258 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
97259 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
97260 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
97261 +_do_truncate_1019 _do_truncate 2 1019 NULL
97262 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
97263 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
97264 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
97265 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
97266 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
97267 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
97268 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
97269 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
97270 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
97271 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
97272 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
97273 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
97274 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
97275 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
97276 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
97277 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
97278 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
97279 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
97280 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
97281 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
97282 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
97283 +nested_get_page_1252 nested_get_page 2 1252 NULL
97284 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
97285 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
97286 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
97287 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
97288 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
97289 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
97290 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
97291 +ffs_1322 ffs 0 1322 NULL
97292 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
97293 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
97294 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
97295 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
97296 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
97297 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
97298 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
97299 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
97300 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
97301 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
97302 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
97303 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
97304 +zone_page_state_1393 zone_page_state 0 1393 NULL
97305 +file_read_actor_1401 file_read_actor 4 1401 NULL
97306 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
97307 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
97308 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
97309 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
97310 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
97311 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
97312 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
97313 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
97314 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
97315 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
97316 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
97317 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
97318 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
97319 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
97320 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
97321 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
97322 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
97323 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
97324 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
97325 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
97326 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
97327 +rmap_add_1677 rmap_add 3 1677 NULL
97328 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
97329 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
97330 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
97331 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
97332 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
97333 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
97334 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
97335 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
97336 +cosa_write_1774 cosa_write 3 1774 NULL
97337 +update_macheader_1775 update_macheader 7 1775 NULL
97338 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
97339 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
97340 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
97341 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
97342 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
97343 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
97344 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
97345 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
97346 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
97347 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
97348 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
97349 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
97350 +read_swap_header_1957 read_swap_header 0 1957 NULL
97351 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
97352 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
97353 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
97354 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
97355 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
97356 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
97357 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
97358 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
97359 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
97360 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
97361 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
97362 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
97363 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
97364 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
97365 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
97366 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
97367 +audit_expand_2098 audit_expand 2 2098 NULL
97368 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
97369 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
97370 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
97371 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
97372 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
97373 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
97374 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
97375 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
97376 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
97377 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
97378 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
97379 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
97380 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
97381 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
97382 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
97383 +vhci_write_2224 vhci_write 3 2224 NULL
97384 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
97385 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
97386 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
97387 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
97388 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
97389 +do_update_counters_2259 do_update_counters 4 2259 NULL
97390 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
97391 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
97392 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
97393 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
97394 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
97395 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
97396 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
97397 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
97398 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
97399 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
97400 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
97401 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
97402 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
97403 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
97404 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
97405 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
97406 +raid1_size_2419 raid1_size 0-2 2419 NULL
97407 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
97408 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
97409 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
97410 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
97411 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
97412 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
97413 +update_pmkid_2481 update_pmkid 4 2481 NULL
97414 +wiphy_new_2482 wiphy_new 2 2482 NULL
97415 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
97416 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
97417 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
97418 +dm_write_2513 dm_write 3 2513 NULL
97419 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
97420 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
97421 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
97422 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
97423 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
97424 +slot_bytes_2609 slot_bytes 0 2609 NULL
97425 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
97426 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
97427 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
97428 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
97429 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
97430 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
97431 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
97432 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
97433 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
97434 +__next_cpu_2782 __next_cpu 1 2782 NULL
97435 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
97436 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
97437 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
97438 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
97439 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
97440 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
97441 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
97442 +mq_map_2871 mq_map 2 2871 NULL
97443 +nla_padlen_2883 nla_padlen 1 2883 NULL
97444 +cmm_write_2896 cmm_write 3 2896 NULL
97445 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
97446 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
97447 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
97448 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
97449 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
97450 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
97451 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
97452 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
97453 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
97454 +depth_write_3021 depth_write 3 3021 NULL
97455 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
97456 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
97457 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
97458 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
97459 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
97460 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
97461 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
97462 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
97463 +free_coherent_3082 free_coherent 4-2 3082 NULL
97464 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
97465 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
97466 +rb_alloc_3102 rb_alloc 1 3102 NULL
97467 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
97468 +print_time_3132 print_time 0 3132 NULL
97469 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
97470 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
97471 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
97472 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
97473 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
97474 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
97475 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
97476 +alloc_context_3194 alloc_context 1 3194 NULL
97477 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
97478 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
97479 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
97480 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
97481 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
97482 +key_key_read_3241 key_key_read 3 3241 NULL
97483 +number_3243 number 0 3243 NULL
97484 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
97485 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
97486 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
97487 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
97488 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
97489 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
97490 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
97491 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
97492 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
97493 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
97494 +scnprintf_3360 scnprintf 0-2 3360 NULL
97495 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
97496 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
97497 +send_stream_3397 send_stream 4 3397 NULL
97498 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
97499 +msix_map_region_3411 msix_map_region 3 3411 NULL
97500 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
97501 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
97502 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
97503 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
97504 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
97505 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
97506 +map_single_3449 map_single 0-2 3449 NULL
97507 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
97508 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
97509 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
97510 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
97511 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
97512 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
97513 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
97514 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
97515 +SyS_readv_3539 SyS_readv 3 3539 NULL
97516 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
97517 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
97518 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
97519 +evtchn_read_3569 evtchn_read 3 3569 NULL
97520 +vc_resize_3585 vc_resize 2-3 3585 NULL
97521 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
97522 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
97523 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
97524 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
97525 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
97526 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
97527 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
97528 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
97529 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
97530 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
97531 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
97532 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
97533 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
97534 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
97535 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
97536 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
97537 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
97538 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
97539 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
97540 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
97541 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
97542 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
97543 +get_fd_set_3866 get_fd_set 1 3866 NULL
97544 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
97545 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
97546 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
97547 +nvram_write_3894 nvram_write 3 3894 NULL
97548 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
97549 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
97550 +vcs_write_3910 vcs_write 3 3910 NULL
97551 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
97552 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
97553 +do_add_counters_3992 do_add_counters 3 3992 NULL
97554 +userspace_status_4004 userspace_status 4 4004 NULL
97555 +mei_write_4005 mei_write 3 4005 NULL nohasharray
97556 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
97557 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
97558 +mm_populate_4016 mm_populate 1 4016 NULL
97559 +blk_end_request_4024 blk_end_request 3 4024 NULL
97560 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
97561 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
97562 +read_file_queues_4078 read_file_queues 3 4078 NULL
97563 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
97564 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
97565 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
97566 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
97567 +tm6000_read_4151 tm6000_read 3 4151 NULL
97568 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
97569 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
97570 +get_alua_req_4166 get_alua_req 3 4166 NULL
97571 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
97572 +read_file_bool_4180 read_file_bool 3 4180 NULL
97573 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
97574 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
97575 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
97576 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
97577 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
97578 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
97579 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
97580 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
97581 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
97582 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
97583 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
97584 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
97585 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
97586 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
97587 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
97588 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
97589 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
97590 +memparse_4444 memparse 0 4444 NULL
97591 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
97592 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
97593 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
97594 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
97595 +set_link_security_4502 set_link_security 4 4502 NULL
97596 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
97597 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
97598 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
97599 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
97600 +tty_register_device_4544 tty_register_device 2 4544 NULL
97601 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
97602 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
97603 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
97604 +bch_alloc_4593 bch_alloc 1 4593 NULL
97605 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
97606 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
97607 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
97608 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
97609 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
97610 +kone_receive_4690 kone_receive 4 4690 NULL
97611 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
97612 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
97613 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
97614 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
97615 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
97616 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
97617 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
97618 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
97619 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
97620 +create_subvol_4791 create_subvol 4 4791 NULL
97621 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
97622 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
97623 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
97624 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
97625 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
97626 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
97627 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
97628 +sys_ipc_4889 sys_ipc 3 4889 NULL
97629 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
97630 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
97631 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
97632 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
97633 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
97634 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
97635 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
97636 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
97637 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
97638 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
97639 +do_mincore_5018 do_mincore 0-1 5018 NULL
97640 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
97641 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
97642 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
97643 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
97644 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
97645 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
97646 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
97647 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
97648 +sound_write_5102 sound_write 3 5102 NULL
97649 +clear_dirty_5105 clear_dirty 3 5105 NULL
97650 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
97651 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
97652 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
97653 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
97654 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
97655 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
97656 +skb_network_header_5203 skb_network_header 0 5203 NULL
97657 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
97658 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
97659 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
97660 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
97661 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
97662 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
97663 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
97664 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
97665 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
97666 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
97667 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
97668 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
97669 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
97670 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
97671 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
97672 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
97673 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
97674 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
97675 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
97676 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
97677 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
97678 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
97679 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
97680 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
97681 +tty_write_5494 tty_write 3 5494 NULL
97682 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
97683 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
97684 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
97685 +spidev_message_5518 spidev_message 3 5518 NULL
97686 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
97687 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
97688 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
97689 +le_readq_5557 le_readq 0 5557 NULL
97690 +inw_5558 inw 0 5558 NULL
97691 +fir16_create_5574 fir16_create 3 5574 NULL
97692 +bioset_create_5580 bioset_create 1 5580 NULL
97693 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
97694 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
97695 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
97696 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
97697 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
97698 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
97699 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
97700 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
97701 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
97702 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
97703 +get_arg_5694 get_arg 3 5694 NULL
97704 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
97705 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
97706 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
97707 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
97708 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
97709 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
97710 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
97711 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
97712 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
97713 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
97714 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
97715 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
97716 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
97717 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
97718 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
97719 +setup_req_5848 setup_req 3 5848 NULL
97720 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
97721 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
97722 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
97723 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
97724 +port_show_regs_5904 port_show_regs 3 5904 NULL
97725 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
97726 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
97727 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
97728 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
97729 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
97730 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
97731 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
97732 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
97733 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
97734 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
97735 +native_pte_val_5978 native_pte_val 0 5978 NULL
97736 +SyS_semop_5980 SyS_semop 3 5980 NULL
97737 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
97738 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
97739 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
97740 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
97741 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
97742 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
97743 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
97744 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
97745 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
97746 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
97747 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
97748 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
97749 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
97750 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
97751 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
97752 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
97753 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
97754 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
97755 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
97756 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
97757 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
97758 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
97759 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
97760 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
97761 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
97762 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
97763 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
97764 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
97765 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
97766 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
97767 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
97768 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
97769 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
97770 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
97771 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
97772 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
97773 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
97774 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
97775 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
97776 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
97777 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
97778 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
97779 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
97780 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
97781 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
97782 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
97783 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
97784 +mei_read_6507 mei_read 3 6507 NULL
97785 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
97786 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
97787 +wdm_read_6549 wdm_read 3 6549 NULL
97788 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
97789 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
97790 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
97791 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
97792 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
97793 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
97794 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
97795 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
97796 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
97797 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
97798 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
97799 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
97800 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
97801 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
97802 +mpeg_read_6708 mpeg_read 3 6708 NULL
97803 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
97804 +video_proc_write_6724 video_proc_write 3 6724 NULL
97805 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
97806 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
97807 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
97808 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
97809 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
97810 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
97811 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
97812 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
97813 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
97814 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
97815 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
97816 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
97817 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
97818 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
97819 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
97820 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
97821 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
97822 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
97823 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
97824 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
97825 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
97826 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
97827 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
97828 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
97829 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
97830 +request_key_async_6990 request_key_async 4 6990 NULL
97831 +tpl_write_6998 tpl_write 3 6998 NULL
97832 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
97833 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
97834 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
97835 +wimax_msg_7030 wimax_msg 4 7030 NULL
97836 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
97837 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
97838 +event_enable_read_7074 event_enable_read 3 7074 NULL
97839 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
97840 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
97841 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
97842 +check_header_7108 check_header 0 7108 NULL
97843 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
97844 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
97845 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
97846 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
97847 +get_param_h_7247 get_param_h 0 7247 NULL
97848 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
97849 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
97850 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
97851 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
97852 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
97853 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
97854 +mgmt_control_7349 mgmt_control 3 7349 NULL
97855 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
97856 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
97857 +hweight_long_7388 hweight_long 0-1 7388 NULL
97858 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
97859 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
97860 +readb_7401 readb 0 7401 NULL
97861 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
97862 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
97863 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
97864 +numa_emulation_7466 numa_emulation 2 7466 NULL
97865 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
97866 +garp_request_join_7471 garp_request_join 4 7471 NULL
97867 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
97868 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
97869 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
97870 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
97871 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
97872 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
97873 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
97874 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
97875 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
97876 +groups_alloc_7614 groups_alloc 1 7614 NULL
97877 +sg_virt_7616 sg_virt 0 7616 NULL
97878 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
97879 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
97880 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
97881 +dev_write_7708 dev_write 3 7708 NULL
97882 +unmap_region_7709 unmap_region 1 7709 NULL
97883 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
97884 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
97885 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
97886 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
97887 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
97888 +ioread32be_7773 ioread32be 0 7773 NULL
97889 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
97890 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
97891 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
97892 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
97893 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
97894 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
97895 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
97896 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
97897 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
97898 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
97899 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
97900 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
97901 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
97902 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
97903 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
97904 +sys_mbind_7990 sys_mbind 5 7990 NULL
97905 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
97906 +vcs_read_8017 vcs_read 3 8017 NULL
97907 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
97908 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
97909 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
97910 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
97911 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
97912 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
97913 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
97914 +venus_lookup_8121 venus_lookup 4 8121 NULL
97915 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
97916 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
97917 +ore_truncate_8181 ore_truncate 3 8181 NULL
97918 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
97919 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
97920 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
97921 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
97922 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
97923 +play_iframe_8219 play_iframe 3 8219 NULL
97924 +create_log_8225 create_log 2 8225 NULL nohasharray
97925 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
97926 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
97927 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
97928 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
97929 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
97930 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
97931 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
97932 +init_cdev_8274 init_cdev 1 8274 NULL
97933 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
97934 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
97935 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
97936 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
97937 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
97938 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
97939 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
97940 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
97941 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
97942 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
97943 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
97944 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
97945 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
97946 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
97947 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
97948 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
97949 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
97950 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
97951 +dev_config_8506 dev_config 3 8506 NULL
97952 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
97953 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
97954 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
97955 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
97956 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
97957 +user_on_off_8552 user_on_off 2 8552 NULL
97958 +profile_remove_8556 profile_remove 3 8556 NULL
97959 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
97960 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
97961 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
97962 +tower_write_8580 tower_write 3 8580 NULL
97963 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
97964 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
97965 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
97966 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
97967 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
97968 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
97969 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
97970 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
97971 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
97972 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
97973 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
97974 +arcfb_write_8702 arcfb_write 3 8702 NULL
97975 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
97976 +init_header_8703 init_header 0 8703 &i_size_read_8703
97977 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
97978 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
97979 +f_dupfd_8730 f_dupfd 1 8730 NULL
97980 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
97981 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
97982 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
97983 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
97984 +sys_prctl_8766 sys_prctl 4 8766 NULL
97985 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
97986 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
97987 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
97988 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
97989 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
97990 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
97991 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
97992 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
97993 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
97994 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
97995 +clear_bitset_8840 clear_bitset 2 8840 NULL
97996 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
97997 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
97998 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
97999 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
98000 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
98001 +layout_commit_8926 layout_commit 3 8926 NULL
98002 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
98003 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
98004 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
98005 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
98006 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
98007 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
98008 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
98009 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
98010 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
98011 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
98012 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
98013 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
98014 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
98015 +nla_put_9042 nla_put 3 9042 NULL
98016 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
98017 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
98018 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
98019 +string_9080 string 0 9080 NULL
98020 +create_queues_9088 create_queues 2-3 9088 NULL
98021 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
98022 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
98023 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
98024 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
98025 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
98026 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
98027 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
98028 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
98029 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
98030 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
98031 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
98032 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
98033 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
98034 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
98035 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
98036 +get_pfn_9207 get_pfn 1 9207 NULL
98037 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
98038 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
98039 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
98040 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
98041 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
98042 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
98043 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
98044 +flakey_status_9274 flakey_status 5 9274 NULL
98045 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
98046 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
98047 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
98048 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
98049 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
98050 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
98051 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
98052 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
98053 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
98054 +read_9397 read 3 9397 NULL
98055 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
98056 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
98057 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
98058 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
98059 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
98060 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
98061 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
98062 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
98063 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
98064 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
98065 +lp_write_9511 lp_write 3 9511 NULL
98066 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
98067 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
98068 +read_file_dma_9530 read_file_dma 3 9530 NULL
98069 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
98070 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
98071 +fw_node_create_9559 fw_node_create 2 9559 NULL
98072 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
98073 +kobj_map_9566 kobj_map 2-3 9566 NULL
98074 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
98075 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
98076 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
98077 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
98078 +do_sync_9604 do_sync 1 9604 NULL
98079 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
98080 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
98081 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
98082 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
98083 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
98084 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
98085 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
98086 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
98087 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
98088 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
98089 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
98090 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
98091 +is_hole_9694 is_hole 2 9694 NULL nohasharray
98092 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
98093 +fnb_9703 fnb 2-3 9703 NULL
98094 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
98095 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
98096 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
98097 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
98098 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
98099 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
98100 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
98101 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
98102 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
98103 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
98104 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
98105 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
98106 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
98107 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
98108 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
98109 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
98110 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
98111 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
98112 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
98113 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
98114 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
98115 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
98116 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
98117 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
98118 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
98119 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
98120 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
98121 +read_file_misc_9948 read_file_misc 3 9948 NULL
98122 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
98123 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
98124 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
98125 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
98126 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
98127 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
98128 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
98129 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
98130 +handle_request_10024 handle_request 9 10024 NULL
98131 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
98132 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
98133 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
98134 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
98135 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
98136 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
98137 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
98138 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
98139 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
98140 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
98141 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
98142 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
98143 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
98144 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
98145 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
98146 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
98147 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
98148 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
98149 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
98150 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
98151 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
98152 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
98153 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
98154 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
98155 +read_emulate_10310 read_emulate 2-4 10310 NULL
98156 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
98157 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
98158 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
98159 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
98160 +get_dump_page_10338 get_dump_page 1 10338 NULL
98161 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
98162 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
98163 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
98164 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
98165 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
98166 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
98167 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
98168 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
98169 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
98170 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
98171 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
98172 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
98173 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
98174 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
98175 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
98176 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
98177 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
98178 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
98179 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
98180 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
98181 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
98182 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
98183 +otp_read_10594 otp_read 2-4-5 10594 NULL
98184 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
98185 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
98186 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
98187 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
98188 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
98189 +parport_write_10669 parport_write 0 10669 NULL
98190 +inl_10708 inl 0 10708 NULL nohasharray
98191 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
98192 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
98193 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
98194 +spi_sync_10731 spi_sync 0 10731 NULL
98195 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
98196 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
98197 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
98198 +sys_syslog_10746 sys_syslog 3 10746 NULL
98199 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
98200 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
98201 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
98202 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
98203 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
98204 +sys_bind_10799 sys_bind 3 10799 NULL
98205 +compat_put_int_10828 compat_put_int 1 10828 NULL
98206 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
98207 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
98208 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
98209 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
98210 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
98211 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
98212 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
98213 +get_scq_10897 get_scq 2 10897 NULL
98214 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
98215 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
98216 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
98217 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
98218 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
98219 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
98220 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
98221 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
98222 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
98223 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
98224 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
98225 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
98226 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
98227 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
98228 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
98229 +count_argc_11083 count_argc 0 11083 NULL
98230 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
98231 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
98232 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
98233 +page_offset_11120 page_offset 0 11120 NULL
98234 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
98235 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
98236 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
98237 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
98238 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
98239 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
98240 +__swab16p_11220 __swab16p 0 11220 NULL
98241 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
98242 +mmap_region_11247 mmap_region 0-2 11247 NULL
98243 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
98244 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
98245 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
98246 +cru_detect_11272 cru_detect 1 11272 NULL
98247 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
98248 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
98249 +construct_key_11329 construct_key 3 11329 NULL nohasharray
98250 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
98251 +next_segment_11330 next_segment 0-2-1 11330 NULL
98252 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
98253 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
98254 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
98255 +sel_write_create_11353 sel_write_create 3 11353 NULL
98256 +handle_unit_11355 handle_unit 0-1 11355 NULL
98257 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
98258 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
98259 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
98260 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
98261 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
98262 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
98263 +str_to_user_11411 str_to_user 2 11411 NULL
98264 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
98265 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
98266 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
98267 +trace_options_read_11419 trace_options_read 3 11419 NULL
98268 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
98269 +prepare_image_11424 prepare_image 0 11424 NULL
98270 +vring_size_11426 vring_size 0-1-2 11426 NULL
98271 +bttv_read_11432 bttv_read 3 11432 NULL
98272 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
98273 +swp_offset_11475 swp_offset 0 11475 NULL
98274 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
98275 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
98276 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
98277 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
98278 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
98279 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
98280 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
98281 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
98282 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
98283 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
98284 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
98285 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
98286 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
98287 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
98288 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
98289 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
98290 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
98291 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
98292 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
98293 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
98294 +split_11691 split 2 11691 NULL
98295 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
98296 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
98297 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
98298 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
98299 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
98300 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
98301 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
98302 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
98303 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
98304 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
98305 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
98306 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
98307 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
98308 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
98309 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
98310 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
98311 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
98312 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
98313 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
98314 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
98315 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
98316 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
98317 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
98318 +atmel_read16_11981 atmel_read16 0 11981 NULL
98319 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
98320 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
98321 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
98322 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
98323 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
98324 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
98325 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
98326 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
98327 +set_powered_12129 set_powered 4 12129 NULL
98328 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
98329 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
98330 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
98331 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
98332 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
98333 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
98334 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
98335 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
98336 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
98337 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
98338 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
98339 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
98340 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
98341 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
98342 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
98343 +scaled_div_12201 scaled_div 1-2 12201 NULL
98344 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
98345 +receive_copy_12216 receive_copy 3 12216 NULL
98346 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
98347 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
98348 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
98349 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
98350 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
98351 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
98352 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
98353 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
98354 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
98355 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
98356 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
98357 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
98358 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
98359 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
98360 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
98361 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
98362 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
98363 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
98364 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
98365 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
98366 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
98367 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
98368 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
98369 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
98370 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
98371 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
98372 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
98373 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
98374 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
98375 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
98376 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
98377 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
98378 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
98379 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
98380 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
98381 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
98382 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
98383 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
98384 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
98385 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
98386 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
98387 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
98388 +wb_create_12651 wb_create 1 12651 NULL
98389 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
98390 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
98391 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
98392 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
98393 +ivtv_write_12721 ivtv_write 3 12721 NULL
98394 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
98395 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
98396 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
98397 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
98398 +listxattr_12769 listxattr 3 12769 NULL
98399 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
98400 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
98401 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
98402 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
98403 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
98404 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
98405 +readq_12825 readq 0 12825 NULL
98406 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
98407 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
98408 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
98409 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
98410 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
98411 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
98412 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
98413 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
98414 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
98415 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
98416 +bm_status_write_12964 bm_status_write 3 12964 NULL
98417 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
98418 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
98419 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
98420 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
98421 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
98422 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
98423 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
98424 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
98425 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
98426 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
98427 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
98428 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
98429 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
98430 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
98431 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
98432 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
98433 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
98434 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
98435 +blk_update_request_13146 blk_update_request 3 13146 NULL
98436 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
98437 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
98438 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
98439 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
98440 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
98441 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
98442 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
98443 +comedi_read_13199 comedi_read 3 13199 NULL
98444 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
98445 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
98446 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
98447 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
98448 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
98449 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
98450 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
98451 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
98452 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
98453 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
98454 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
98455 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
98456 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
98457 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
98458 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
98459 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
98460 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
98461 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
98462 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
98463 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
98464 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
98465 +cache_ctr_13364 cache_ctr 2 13364 NULL
98466 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
98467 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
98468 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
98469 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
98470 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
98471 +sky2_receive_13407 sky2_receive 2 13407 NULL
98472 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
98473 +keyring_read_13438 keyring_read 3 13438 NULL
98474 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
98475 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
98476 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
98477 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
98478 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
98479 +core_status_13515 core_status 4 13515 NULL
98480 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
98481 +bm_init_13529 bm_init 2 13529 NULL
98482 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
98483 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
98484 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
98485 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
98486 +sys_madvise_13569 sys_madvise 1 13569 NULL
98487 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
98488 +cache_write_13589 cache_write 3 13589 NULL
98489 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
98490 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
98491 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
98492 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
98493 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
98494 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
98495 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
98496 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
98497 +packet_snd_13634 packet_snd 3 13634 NULL
98498 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
98499 +cache_downcall_13666 cache_downcall 3 13666 NULL
98500 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
98501 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
98502 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
98503 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
98504 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
98505 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
98506 +random_read_13815 random_read 3 13815 NULL
98507 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
98508 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
98509 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
98510 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
98511 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
98512 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
98513 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
98514 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
98515 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
98516 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
98517 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
98518 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
98519 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
98520 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
98521 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
98522 +com90xx_found_13974 com90xx_found 3 13974 NULL
98523 +qcam_read_13977 qcam_read 3 13977 NULL
98524 +dsp_read_13980 dsp_read 2 13980 NULL
98525 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
98526 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
98527 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
98528 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
98529 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
98530 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
98531 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
98532 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
98533 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
98534 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
98535 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
98536 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
98537 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
98538 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
98539 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
98540 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
98541 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
98542 +em_canid_change_14150 em_canid_change 3 14150 NULL
98543 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
98544 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
98545 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
98546 +alloc_async_14208 alloc_async 1 14208 NULL
98547 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
98548 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
98549 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
98550 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
98551 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
98552 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
98553 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
98554 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
98555 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
98556 +rr_status_14293 rr_status 5 14293 NULL
98557 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
98558 +oo_objects_14319 oo_objects 0 14319 NULL
98559 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
98560 +scsi2int_14358 scsi2int 0 14358 NULL
98561 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
98562 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
98563 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
98564 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
98565 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
98566 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
98567 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
98568 +block_size_14443 block_size 0 14443 NULL
98569 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
98570 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
98571 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
98572 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
98573 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
98574 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
98575 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
98576 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
98577 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
98578 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
98579 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
98580 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
98581 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
98582 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
98583 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
98584 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
98585 +dbJoin_14644 dbJoin 0 14644 NULL
98586 +profile_replace_14652 profile_replace 3 14652 NULL
98587 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
98588 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
98589 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
98590 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
98591 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
98592 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
98593 +get_bio_block_14714 get_bio_block 0 14714 NULL
98594 +vfd_write_14717 vfd_write 3 14717 NULL
98595 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
98596 +raid1_resize_14740 raid1_resize 2 14740 NULL
98597 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
98598 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
98599 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
98600 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
98601 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
98602 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
98603 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
98604 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
98605 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
98606 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
98607 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
98608 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
98609 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
98610 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
98611 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
98612 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
98613 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
98614 +unifi_read_14899 unifi_read 3 14899 NULL
98615 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
98616 +krealloc_14908 krealloc 2 14908 NULL
98617 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
98618 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
98619 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
98620 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
98621 +queue_cnt_14951 queue_cnt 0 14951 NULL
98622 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
98623 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
98624 +setkey_14987 setkey 3 14987 NULL nohasharray
98625 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
98626 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
98627 +vmap_15025 vmap 2 15025 NULL
98628 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
98629 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
98630 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
98631 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
98632 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
98633 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
98634 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
98635 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
98636 +start_port_15124 start_port 0 15124 NULL
98637 +memchr_15126 memchr 0 15126 NULL
98638 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
98639 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
98640 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
98641 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
98642 +reserve_resources_15194 reserve_resources 3 15194 NULL
98643 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
98644 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
98645 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
98646 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
98647 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
98648 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
98649 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
98650 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
98651 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
98652 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
98653 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
98654 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
98655 +ioread16_15342 ioread16 0 15342 NULL
98656 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
98657 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
98658 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
98659 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
98660 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
98661 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
98662 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
98663 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
98664 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
98665 +get_modalias_15406 get_modalias 2 15406 NULL
98666 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
98667 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
98668 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
98669 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
98670 +memweight_15450 memweight 2 15450 NULL
98671 +vmalloc_15464 vmalloc 1 15464 NULL
98672 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
98673 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
98674 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
98675 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
98676 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
98677 +persistent_status_15574 persistent_status 4 15574 NULL
98678 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
98679 +vme_user_write_15587 vme_user_write 3 15587 NULL
98680 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
98681 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
98682 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
98683 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
98684 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
98685 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
98686 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
98687 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
98688 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
98689 +fs_path_add_15648 fs_path_add 3 15648 NULL
98690 +xsd_read_15653 xsd_read 3 15653 NULL
98691 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
98692 +unix_bind_15668 unix_bind 3 15668 NULL
98693 +dm_read_15674 dm_read 3 15674 NULL
98694 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
98695 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
98696 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
98697 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
98698 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
98699 +do_test_15766 do_test 1 15766 NULL
98700 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
98701 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
98702 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
98703 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
98704 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
98705 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
98706 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
98707 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
98708 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
98709 +table_size_15851 table_size 0-1-2 15851 NULL
98710 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
98711 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
98712 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
98713 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
98714 +native_read_msr_15905 native_read_msr 0 15905 NULL
98715 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
98716 +power_read_15939 power_read 3 15939 NULL
98717 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
98718 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
98719 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
98720 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
98721 +frame_alloc_15981 frame_alloc 4 15981 NULL
98722 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
98723 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
98724 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
98725 +got_frame_16028 got_frame 2 16028 NULL
98726 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
98727 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
98728 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
98729 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
98730 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
98731 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
98732 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
98733 +fsm_init_16134 fsm_init 2 16134 NULL
98734 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
98735 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
98736 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
98737 +mapping_level_16188 mapping_level 2 16188 NULL
98738 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
98739 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
98740 +create_table_16213 create_table 2 16213 NULL
98741 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
98742 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
98743 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
98744 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
98745 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
98746 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
98747 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
98748 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
98749 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
98750 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
98751 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
98752 +account_16283 account 0-2-4 16283 NULL nohasharray
98753 +mirror_status_16283 mirror_status 5 16283 &account_16283
98754 +retry_instruction_16285 retry_instruction 2 16285 NULL
98755 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
98756 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
98757 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
98758 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
98759 +wb_map_16301 wb_map 2 16301 NULL
98760 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
98761 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
98762 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
98763 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
98764 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
98765 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
98766 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
98767 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
98768 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
98769 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
98770 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
98771 +raid10_resize_16537 raid10_resize 2 16537 NULL
98772 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
98773 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
98774 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
98775 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
98776 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
98777 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
98778 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
98779 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
98780 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
98781 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
98782 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
98783 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
98784 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
98785 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
98786 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
98787 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
98788 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
98789 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
98790 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
98791 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
98792 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
98793 +st_write_16874 st_write 3 16874 NULL
98794 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
98795 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
98796 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
98797 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
98798 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
98799 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
98800 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
98801 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
98802 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
98803 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
98804 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
98805 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
98806 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
98807 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
98808 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
98809 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
98810 +mac_address_string_17091 mac_address_string 0 17091 NULL
98811 +entry_length_17093 entry_length 0 17093 NULL
98812 +sys_preadv_17100 sys_preadv 3 17100 NULL
98813 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
98814 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
98815 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
98816 +sep_read_17161 sep_read 3 17161 NULL
98817 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
98818 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
98819 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
98820 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
98821 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
98822 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
98823 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
98824 +to_oblock_17254 to_oblock 0-1 17254 NULL
98825 +unpack_value_17259 unpack_value 1 17259 NULL
98826 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
98827 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
98828 +alloc_ep_17269 alloc_ep 1 17269 NULL
98829 +pg_read_17276 pg_read 3 17276 NULL
98830 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
98831 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
98832 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
98833 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
98834 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
98835 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
98836 +skb_pad_17302 skb_pad 2 17302 NULL
98837 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
98838 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
98839 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
98840 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
98841 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
98842 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
98843 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
98844 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
98845 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
98846 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
98847 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
98848 +compat_cmd_17465 compat_cmd 2 17465 NULL
98849 +probe_bios_17467 probe_bios 1 17467 NULL
98850 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
98851 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
98852 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
98853 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
98854 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
98855 +copy_from_user_17559 copy_from_user 3 17559 NULL
98856 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
98857 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
98858 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
98859 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
98860 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
98861 +osst_execute_17607 osst_execute 7-6 17607 NULL
98862 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
98863 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
98864 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
98865 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
98866 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
98867 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
98868 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
98869 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
98870 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
98871 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
98872 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
98873 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
98874 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
98875 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
98876 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
98877 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
98878 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
98879 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
98880 +perf_clock_17787 perf_clock 0 17787 NULL
98881 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
98882 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
98883 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
98884 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
98885 +count_leafs_17842 count_leafs 0 17842 NULL
98886 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
98887 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
98888 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
98889 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
98890 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
98891 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
98892 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
98893 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
98894 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
98895 +recover_head_17904 recover_head 3 17904 NULL
98896 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
98897 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
98898 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
98899 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
98900 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
98901 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
98902 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
98903 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
98904 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
98905 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
98906 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
98907 +fill_read_18019 fill_read 0 18019 NULL
98908 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
98909 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
98910 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
98911 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
98912 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
98913 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
98914 +packet_came_18072 packet_came 3 18072 NULL
98915 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
98916 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
98917 +get_vm_area_18080 get_vm_area 1 18080 NULL
98918 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
98919 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
98920 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
98921 +svc_getnl_18120 svc_getnl 0 18120 NULL
98922 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
98923 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
98924 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
98925 +_has_tag_18169 _has_tag 2 18169 NULL
98926 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
98927 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
98928 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
98929 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
98930 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
98931 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
98932 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
98933 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
98934 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
98935 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
98936 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
98937 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
98938 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
98939 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
98940 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
98941 +um_idi_write_18293 um_idi_write 3 18293 NULL
98942 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
98943 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
98944 +vga_r_18310 vga_r 0 18310 NULL
98945 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
98946 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
98947 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
98948 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
98949 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
98950 +ep_io_18367 ep_io 0 18367 NULL
98951 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
98952 +ci_role_write_18388 ci_role_write 3 18388 NULL
98953 +__video_register_device_18399 __video_register_device 3 18399 NULL
98954 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
98955 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
98956 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
98957 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
98958 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
98959 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
98960 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
98961 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
98962 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
98963 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
98964 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
98965 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
98966 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
98967 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
98968 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
98969 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
98970 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
98971 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
98972 +debug_output_18575 debug_output 3 18575 NULL
98973 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
98974 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
98975 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
98976 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
98977 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
98978 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
98979 +from_buffer_18625 from_buffer 3 18625 NULL
98980 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
98981 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
98982 +unmap_page_18665 unmap_page 2-3 18665 NULL
98983 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
98984 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
98985 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
98986 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
98987 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
98988 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
98989 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
98990 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
98991 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
98992 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
98993 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
98994 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
98995 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
98996 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
98997 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
98998 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
98999 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
99000 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
99001 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
99002 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
99003 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
99004 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
99005 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
99006 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
99007 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
99008 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
99009 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
99010 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
99011 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
99012 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
99013 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
99014 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
99015 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
99016 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
99017 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
99018 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
99019 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
99020 +huge_page_size_19008 huge_page_size 0 19008 NULL
99021 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
99022 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
99023 +revalidate_19043 revalidate 2 19043 NULL
99024 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
99025 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
99026 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
99027 +msix_map_region_19072 msix_map_region 2 19072 NULL
99028 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
99029 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
99030 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
99031 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
99032 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
99033 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
99034 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
99035 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
99036 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
99037 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
99038 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
99039 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
99040 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
99041 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
99042 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
99043 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
99044 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
99045 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
99046 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
99047 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
99048 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
99049 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
99050 +qc_capture_19298 qc_capture 3 19298 NULL
99051 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
99052 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
99053 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
99054 +debug_read_19322 debug_read 3 19322 NULL
99055 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
99056 +closure_sub_19359 closure_sub 2 19359 NULL
99057 +read_zero_19366 read_zero 3 19366 NULL
99058 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
99059 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
99060 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
99061 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
99062 +__phys_addr_19434 __phys_addr 0 19434 NULL
99063 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
99064 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
99065 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
99066 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
99067 +sky2_read16_19475 sky2_read16 0 19475 NULL
99068 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
99069 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
99070 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
99071 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
99072 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
99073 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
99074 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
99075 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
99076 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
99077 +nfsd_read_19568 nfsd_read 5 19568 NULL
99078 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
99079 +bm_status_read_19583 bm_status_read 3 19583 NULL
99080 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
99081 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
99082 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
99083 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
99084 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
99085 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
99086 +bio_detain_19690 bio_detain 2 19690 NULL
99087 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
99088 +read_reg_19723 read_reg 0 19723 NULL
99089 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
99090 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
99091 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
99092 +p9_client_read_19750 p9_client_read 5 19750 NULL
99093 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
99094 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
99095 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
99096 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
99097 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
99098 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
99099 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
99100 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
99101 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
99102 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
99103 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
99104 +__nla_put_19857 __nla_put 3 19857 NULL
99105 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
99106 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
99107 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
99108 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
99109 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
99110 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
99111 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
99112 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
99113 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
99114 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
99115 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
99116 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
99117 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
99118 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
99119 +team_options_register_20091 team_options_register 3 20091 NULL
99120 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
99121 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
99122 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
99123 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
99124 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
99125 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
99126 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
99127 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
99128 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
99129 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
99130 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
99131 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
99132 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
99133 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
99134 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
99135 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
99136 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
99137 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
99138 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
99139 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
99140 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
99141 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
99142 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
99143 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
99144 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
99145 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
99146 +read_buf_20469 read_buf 2 20469 NULL
99147 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
99148 +fast_user_write_20494 fast_user_write 5 20494 NULL
99149 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
99150 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
99151 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
99152 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
99153 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
99154 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
99155 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
99156 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
99157 +venus_create_20555 venus_create 4 20555 NULL
99158 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
99159 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
99160 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
99161 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
99162 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
99163 +lirc_write_20604 lirc_write 3 20604 NULL
99164 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
99165 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
99166 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
99167 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
99168 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
99169 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
99170 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
99171 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
99172 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
99173 +cpumask_size_20683 cpumask_size 0 20683 NULL
99174 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
99175 +gru_vtop_20689 gru_vtop 2 20689 NULL
99176 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
99177 +__maestro_read_20700 __maestro_read 0 20700 NULL
99178 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
99179 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
99180 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
99181 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
99182 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
99183 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
99184 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
99185 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
99186 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
99187 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
99188 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
99189 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
99190 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
99191 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
99192 +sys_sendto_20809 sys_sendto 6 20809 NULL
99193 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
99194 +strndup_user_20819 strndup_user 2 20819 NULL
99195 +calc_layout_20829 calc_layout 3 20829 NULL
99196 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
99197 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
99198 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
99199 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
99200 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
99201 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
99202 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
99203 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
99204 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
99205 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
99206 +htable_bits_20933 htable_bits 0 20933 NULL
99207 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
99208 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
99209 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
99210 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
99211 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
99212 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
99213 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
99214 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
99215 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
99216 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
99217 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
99218 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
99219 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
99220 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
99221 +multipath_status_21094 multipath_status 5 21094 NULL
99222 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
99223 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
99224 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
99225 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
99226 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
99227 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
99228 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
99229 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
99230 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
99231 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
99232 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
99233 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
99234 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
99235 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
99236 +input_ff_create_21240 input_ff_create 2 21240 NULL
99237 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
99238 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
99239 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
99240 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
99241 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
99242 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
99243 +add_res_range_21310 add_res_range 4 21310 NULL
99244 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
99245 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
99246 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
99247 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
99248 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
99249 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
99250 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
99251 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
99252 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
99253 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
99254 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
99255 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
99256 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
99257 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
99258 +concat_writev_21451 concat_writev 3 21451 NULL
99259 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
99260 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
99261 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
99262 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
99263 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
99264 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
99265 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
99266 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
99267 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
99268 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
99269 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
99270 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
99271 +validate_nnode_21638 validate_nnode 0 21638 NULL
99272 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
99273 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
99274 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
99275 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
99276 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
99277 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
99278 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
99279 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
99280 +vm_brk_21739 vm_brk 1 21739 NULL
99281 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
99282 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
99283 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
99284 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
99285 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
99286 +min_odd_21802 min_odd 0 21802 NULL
99287 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
99288 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
99289 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
99290 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
99291 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
99292 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
99293 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
99294 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
99295 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
99296 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
99297 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
99298 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
99299 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
99300 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
99301 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
99302 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
99303 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
99304 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
99305 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
99306 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
99307 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
99308 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
99309 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
99310 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
99311 +write_opcode_22082 write_opcode 2 22082 NULL
99312 +mem_rw_22085 mem_rw 3 22085 NULL
99313 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
99314 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
99315 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
99316 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
99317 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
99318 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
99319 +compat_insn_22142 compat_insn 2 22142 NULL
99320 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
99321 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
99322 +fls_22210 fls 0 22210 NULL
99323 +mem_write_22232 mem_write 3 22232 NULL
99324 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
99325 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
99326 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
99327 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
99328 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
99329 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
99330 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
99331 +extend_brk_22301 extend_brk 0 22301 NULL
99332 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
99333 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
99334 +get_segment_base_22324 get_segment_base 0 22324 NULL
99335 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
99336 +atomic_read_22342 atomic_read 0 22342 NULL
99337 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
99338 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
99339 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
99340 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
99341 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
99342 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
99343 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
99344 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
99345 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
99346 +zoran_write_22404 zoran_write 3 22404 NULL
99347 +queue_reply_22416 queue_reply 3 22416 NULL
99348 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
99349 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
99350 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
99351 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
99352 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
99353 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
99354 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
99355 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
99356 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
99357 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
99358 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
99359 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
99360 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
99361 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
99362 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
99363 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
99364 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
99365 +snapshot_read_22601 snapshot_read 3 22601 NULL
99366 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
99367 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
99368 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
99369 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
99370 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
99371 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
99372 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
99373 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
99374 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
99375 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
99376 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
99377 +map_22700 map 2 22700 NULL
99378 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
99379 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
99380 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
99381 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
99382 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
99383 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
99384 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
99385 +print_frame_22769 print_frame 0 22769 NULL
99386 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
99387 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
99388 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
99389 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
99390 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
99391 +create_attr_set_22861 create_attr_set 1 22861 NULL
99392 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
99393 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
99394 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
99395 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
99396 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
99397 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
99398 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
99399 +vme_get_size_22964 vme_get_size 0 22964 NULL
99400 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
99401 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
99402 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
99403 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
99404 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
99405 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
99406 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
99407 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
99408 +st_status_23032 st_status 5 23032 NULL
99409 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
99410 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
99411 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
99412 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
99413 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
99414 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
99415 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
99416 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
99417 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
99418 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
99419 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
99420 +fls_long_23096 fls_long 0 23096 NULL
99421 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
99422 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
99423 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
99424 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
99425 +__clear_user_23118 __clear_user 0 23118 NULL
99426 +dm_write_async_23120 dm_write_async 3 23120 NULL
99427 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
99428 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
99429 +read_file_ani_23161 read_file_ani 3 23161 NULL
99430 +ioremap_23172 ioremap 1-2 23172 NULL
99431 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
99432 +usblp_write_23178 usblp_write 3 23178 NULL
99433 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
99434 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
99435 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
99436 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
99437 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
99438 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
99439 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
99440 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
99441 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
99442 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
99443 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
99444 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
99445 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
99446 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
99447 +doc_probe_23285 doc_probe 1 23285 NULL
99448 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
99449 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
99450 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
99451 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
99452 +page_readlink_23346 page_readlink 3 23346 NULL
99453 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
99454 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
99455 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
99456 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
99457 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
99458 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
99459 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
99460 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
99461 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
99462 +event_filter_read_23494 event_filter_read 3 23494 NULL
99463 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
99464 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
99465 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
99466 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
99467 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
99468 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
99469 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
99470 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
99471 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
99472 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
99473 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
99474 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
99475 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
99476 +sInW_23663 sInW 0 23663 NULL
99477 +SyS_connect_23669 SyS_connect 3 23669 NULL
99478 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
99479 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
99480 +cx18_read_23699 cx18_read 3 23699 NULL
99481 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
99482 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
99483 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
99484 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
99485 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
99486 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
99487 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
99488 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
99489 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
99490 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
99491 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
99492 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
99493 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
99494 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
99495 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
99496 +p54_init_common_23850 p54_init_common 1 23850 NULL
99497 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
99498 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
99499 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
99500 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
99501 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
99502 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
99503 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
99504 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
99505 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
99506 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
99507 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
99508 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
99509 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
99510 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
99511 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
99512 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
99513 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
99514 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
99515 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
99516 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
99517 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
99518 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
99519 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
99520 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
99521 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
99522 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
99523 +mpu401_read_24126 mpu401_read 3 24126 NULL
99524 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
99525 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
99526 +set_discard_24162 set_discard 2 24162 NULL
99527 +adu_read_24177 adu_read 3 24177 NULL
99528 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
99529 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
99530 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
99531 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
99532 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
99533 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
99534 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
99535 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
99536 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
99537 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
99538 +thin_status_24278 thin_status 5 24278 NULL
99539 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
99540 +msg_size_24288 msg_size 0 24288 NULL
99541 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
99542 +map_page_24298 map_page 3-4 24298 NULL
99543 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
99544 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
99545 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
99546 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
99547 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
99548 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
99549 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
99550 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
99551 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
99552 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
99553 +igetword_24373 igetword 0 24373 NULL
99554 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
99555 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
99556 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
99557 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
99558 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
99559 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
99560 +smk_user_access_24440 smk_user_access 3 24440 NULL
99561 +page_address_24444 page_address 0 24444 NULL
99562 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
99563 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
99564 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
99565 +pd_video_read_24510 pd_video_read 3 24510 NULL
99566 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
99567 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
99568 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
99569 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
99570 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
99571 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
99572 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
99573 +count_preds_24600 count_preds 0 24600 NULL
99574 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
99575 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
99576 +context_alloc_24645 context_alloc 3 24645 NULL
99577 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
99578 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
99579 +read_fs_24717 read_fs 0 24717 NULL
99580 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
99581 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
99582 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
99583 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
99584 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
99585 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
99586 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
99587 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
99588 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
99589 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
99590 +cache_read_24790 cache_read 3 24790 NULL
99591 +unpack_str_24798 unpack_str 0 24798 NULL
99592 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
99593 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
99594 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
99595 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
99596 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
99597 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
99598 +setup_buffering_24872 setup_buffering 3 24872 NULL
99599 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
99600 +queues_read_24877 queues_read 3 24877 NULL nohasharray
99601 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
99602 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
99603 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
99604 +next_token_24929 next_token 0 24929 NULL
99605 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
99606 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
99607 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
99608 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
99609 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
99610 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
99611 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
99612 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
99613 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
99614 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
99615 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
99616 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
99617 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
99618 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
99619 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
99620 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
99621 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
99622 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
99623 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
99624 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
99625 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
99626 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
99627 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
99628 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
99629 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
99630 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
99631 +stripe_status_25259 stripe_status 5 25259 NULL
99632 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
99633 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
99634 +vfs_writev_25278 vfs_writev 3 25278 NULL
99635 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
99636 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
99637 +help_25316 help 5 25316 NULL nohasharray
99638 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
99639 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
99640 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
99641 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
99642 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
99643 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
99644 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
99645 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
99646 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
99647 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
99648 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
99649 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
99650 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
99651 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
99652 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
99653 +sb_permission_25523 sb_permission 0 25523 NULL
99654 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
99655 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
99656 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
99657 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
99658 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
99659 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
99660 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
99661 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
99662 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
99663 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
99664 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
99665 +__direct_map_25647 __direct_map 5-6 25647 NULL
99666 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
99667 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
99668 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
99669 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
99670 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
99671 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
99672 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
99673 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
99674 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
99675 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
99676 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
99677 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
99678 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
99679 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
99680 +sg_read_25799 sg_read 3 25799 NULL
99681 +system_enable_read_25815 system_enable_read 3 25815 NULL
99682 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
99683 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
99684 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
99685 +parport_read_25855 parport_read 0 25855 NULL
99686 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
99687 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
99688 +key_attr_size_25865 key_attr_size 0 25865 NULL
99689 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
99690 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
99691 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
99692 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
99693 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
99694 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
99695 +rcname_read_25919 rcname_read 3 25919 NULL
99696 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
99697 +key_flags_read_25931 key_flags_read 3 25931 NULL
99698 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
99699 +flush_25957 flush 2 25957 NULL
99700 +video_register_device_25971 video_register_device 3 25971 NULL
99701 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
99702 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
99703 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
99704 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
99705 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
99706 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
99707 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
99708 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
99709 +tun_do_read_26047 tun_do_read 5 26047 NULL
99710 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
99711 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
99712 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
99713 +skb_cow_26138 skb_cow 2 26138 NULL
99714 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
99715 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
99716 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
99717 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
99718 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
99719 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
99720 +disk_devt_26180 disk_devt 0 26180 NULL
99721 +get_registers_26187 get_registers 3 26187 NULL
99722 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
99723 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
99724 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
99725 +mce_write_26201 mce_write 3 26201 NULL
99726 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
99727 +bio_split_26235 bio_split 2 26235 NULL
99728 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
99729 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
99730 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
99731 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
99732 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
99733 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
99734 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
99735 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
99736 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
99737 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
99738 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
99739 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
99740 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
99741 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
99742 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
99743 +read_vmcore_26501 read_vmcore 3 26501 NULL
99744 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
99745 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
99746 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
99747 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
99748 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
99749 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
99750 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
99751 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
99752 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
99753 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
99754 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
99755 +pack_value_26625 pack_value 1 26625 NULL
99756 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
99757 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
99758 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
99759 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
99760 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
99761 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
99762 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
99763 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
99764 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
99765 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
99766 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
99767 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
99768 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
99769 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
99770 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
99771 +smk_write_load_26829 smk_write_load 3 26829 NULL
99772 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
99773 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
99774 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
99775 +scnprint_id_26842 scnprint_id 3 26842 NULL
99776 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
99777 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
99778 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
99779 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
99780 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
99781 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
99782 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
99783 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
99784 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
99785 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
99786 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
99787 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
99788 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
99789 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
99790 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
99791 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
99792 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
99793 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
99794 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
99795 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
99796 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
99797 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
99798 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
99799 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
99800 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
99801 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
99802 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
99803 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
99804 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
99805 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
99806 +pms_capture_27142 pms_capture 4 27142 NULL
99807 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
99808 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
99809 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
99810 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
99811 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
99812 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
99813 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
99814 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
99815 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
99816 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
99817 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
99818 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
99819 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
99820 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
99821 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
99822 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
99823 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
99824 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
99825 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
99826 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
99827 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
99828 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
99829 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
99830 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
99831 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
99832 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
99833 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
99834 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
99835 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
99836 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
99837 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
99838 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
99839 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
99840 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
99841 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
99842 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
99843 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
99844 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
99845 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
99846 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
99847 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
99848 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
99849 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
99850 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
99851 +qword_get_27670 qword_get 0 27670 NULL
99852 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
99853 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
99854 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
99855 +evm_write_key_27715 evm_write_key 3 27715 NULL
99856 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
99857 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
99858 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
99859 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
99860 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
99861 +kcalloc_27770 kcalloc 1-2 27770 NULL
99862 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
99863 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
99864 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
99865 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
99866 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
99867 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
99868 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
99869 +read_profile_27859 read_profile 3 27859 NULL
99870 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
99871 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
99872 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
99873 +gluebi_write_27905 gluebi_write 3 27905 NULL
99874 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
99875 +bm_find_next_27929 bm_find_next 2 27929 NULL
99876 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
99877 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
99878 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
99879 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
99880 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
99881 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
99882 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
99883 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
99884 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
99885 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
99886 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
99887 +pool_status_28055 pool_status 5 28055 NULL
99888 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
99889 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
99890 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
99891 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
99892 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
99893 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
99894 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
99895 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
99896 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
99897 +video_read_28148 video_read 3 28148 NULL
99898 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
99899 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
99900 +vread_28173 vread 0 28173 NULL
99901 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
99902 +d_path_28198 d_path 0 28198 NULL
99903 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
99904 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
99905 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
99906 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
99907 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
99908 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
99909 +usemap_size_28281 usemap_size 0 28281 NULL
99910 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
99911 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
99912 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
99913 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
99914 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
99915 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
99916 +snapshot_write_28351 snapshot_write 3 28351 NULL
99917 +sys_writev_28384 sys_writev 3 28384 NULL
99918 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
99919 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
99920 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
99921 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
99922 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
99923 +__split_large_page_28429 __split_large_page 2 28429 NULL
99924 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
99925 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
99926 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
99927 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
99928 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
99929 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
99930 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
99931 +max_response_pages_28492 max_response_pages 0 28492 NULL
99932 +clear_discard_28494 clear_discard 2 28494 NULL
99933 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
99934 +__next_node_28521 __next_node 1 28521 NULL
99935 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
99936 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
99937 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
99938 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
99939 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
99940 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
99941 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
99942 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
99943 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
99944 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
99945 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
99946 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
99947 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
99948 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
99949 +_set_range_28627 _set_range 3 28627 NULL
99950 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
99951 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
99952 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
99953 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
99954 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
99955 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
99956 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
99957 +spi_execute_28736 spi_execute 5 28736 NULL
99958 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
99959 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
99960 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
99961 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
99962 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
99963 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
99964 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
99965 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
99966 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
99967 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
99968 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
99969 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
99970 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
99971 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
99972 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
99973 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
99974 +to_cblock_28899 to_cblock 0-1 28899 NULL
99975 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
99976 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
99977 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
99978 +push_rx_28939 push_rx 3 28939 NULL
99979 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
99980 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
99981 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
99982 +bin_uuid_28999 bin_uuid 3 28999 NULL
99983 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
99984 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
99985 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
99986 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
99987 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
99988 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
99989 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
99990 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
99991 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
99992 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
99993 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
99994 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
99995 +snprintf_29125 snprintf 0 29125 NULL
99996 +iov_shorten_29130 iov_shorten 0 29130 NULL
99997 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
99998 +reshape_ring_29147 reshape_ring 2 29147 NULL
99999 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
100000 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
100001 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
100002 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
100003 +__mm_populate_29204 __mm_populate 1 29204 NULL
100004 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
100005 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
100006 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
100007 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
100008 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
100009 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
100010 +recover_peb_29238 recover_peb 6-7 29238 NULL
100011 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
100012 +block_div_29268 block_div 0-1-2 29268 NULL
100013 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
100014 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
100015 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
100016 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
100017 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
100018 +tun_put_user_29337 tun_put_user 5 29337 NULL
100019 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
100020 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
100021 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
100022 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
100023 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
100024 +mempool_create_29437 mempool_create 1 29437 NULL
100025 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
100026 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
100027 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
100028 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
100029 +do_register_entry_29478 do_register_entry 4 29478 NULL
100030 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
100031 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
100032 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
100033 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
100034 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
100035 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
100036 +set_brk_29551 set_brk 1 29551 NULL nohasharray
100037 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
100038 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
100039 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
100040 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
100041 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
100042 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
100043 +slots_per_page_29601 slots_per_page 0 29601 NULL
100044 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
100045 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
100046 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
100047 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
100048 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
100049 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
100050 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
100051 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
100052 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
100053 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
100054 +probes_write_29711 probes_write 3 29711 NULL
100055 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
100056 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
100057 +std_nic_write_29752 std_nic_write 3 29752 NULL
100058 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
100059 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
100060 +dbAlloc_29794 dbAlloc 0 29794 NULL
100061 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
100062 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
100063 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
100064 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
100065 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
100066 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
100067 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
100068 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
100069 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
100070 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
100071 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
100072 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
100073 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
100074 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
100075 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
100076 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
100077 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
100078 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
100079 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
100080 +drp_wmove_30043 drp_wmove 4 30043 NULL
100081 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
100082 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
100083 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
100084 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
100085 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
100086 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
100087 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
100088 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
100089 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
100090 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
100091 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
100092 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
100093 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
100094 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
100095 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
100096 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
100097 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
100098 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
100099 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
100100 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
100101 +compat_readv_30273 compat_readv 3 30273 NULL
100102 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
100103 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
100104 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
100105 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
100106 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
100107 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
100108 +resource_from_user_30341 resource_from_user 3 30341 NULL
100109 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
100110 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
100111 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
100112 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
100113 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
100114 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
100115 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
100116 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
100117 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
100118 +mq_create_30425 mq_create 1 30425 NULL
100119 +enable_write_30456 enable_write 3 30456 NULL
100120 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
100121 +urandom_read_30462 urandom_read 3 30462 NULL
100122 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
100123 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
100124 +write_head_30481 write_head 4 30481 NULL
100125 +adu_write_30487 adu_write 3 30487 NULL
100126 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
100127 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
100128 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
100129 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
100130 +set_le_30581 set_le 4 30581 NULL
100131 +from_cblock_30582 from_cblock 0-1 30582 NULL
100132 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
100133 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
100134 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
100135 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
100136 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
100137 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
100138 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
100139 +agp_remap_30665 agp_remap 2 30665 NULL
100140 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
100141 +il_free_pages_30692 il_free_pages 2 30692 NULL
100142 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
100143 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
100144 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
100145 +snapshot_status_30744 snapshot_status 5 30744 NULL
100146 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
100147 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
100148 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
100149 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
100150 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
100151 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
100152 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
100153 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
100154 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
100155 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
100156 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
100157 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
100158 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
100159 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
100160 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
100161 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
100162 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
100163 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
100164 +sys_mincore_31079 sys_mincore 1 31079 NULL
100165 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
100166 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
100167 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
100168 +depth_read_31112 depth_read 3 31112 NULL
100169 +ssb_read16_31139 ssb_read16 0 31139 NULL
100170 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
100171 +size_inside_page_31141 size_inside_page 0 31141 NULL
100172 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
100173 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
100174 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
100175 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
100176 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
100177 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
100178 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
100179 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
100180 +__read_reg_31216 __read_reg 0 31216 NULL
100181 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
100182 +cyy_readb_31240 cyy_readb 0 31240 NULL
100183 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
100184 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
100185 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
100186 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
100187 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
100188 +command_file_write_31318 command_file_write 3 31318 NULL
100189 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
100190 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
100191 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
100192 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
100193 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
100194 +inb_31388 inb 0 31388 NULL
100195 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
100196 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
100197 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
100198 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
100199 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
100200 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
100201 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
100202 +do_fcntl_31468 do_fcntl 3 31468 NULL
100203 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
100204 +alg_setkey_31485 alg_setkey 3 31485 NULL
100205 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
100206 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
100207 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
100208 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
100209 +hidraw_write_31536 hidraw_write 3 31536 NULL
100210 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
100211 +usbvision_read_31555 usbvision_read 3 31555 NULL
100212 +normalize_31566 normalize 0-1-2 31566 NULL
100213 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
100214 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
100215 +osst_write_31581 osst_write 3 31581 NULL
100216 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
100217 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
100218 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
100219 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
100220 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
100221 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
100222 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
100223 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
100224 +__lgread_31668 __lgread 4 31668 NULL
100225 +symbol_string_31670 symbol_string 0 31670 NULL
100226 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
100227 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
100228 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
100229 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
100230 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
100231 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
100232 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
100233 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
100234 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
100235 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
100236 +muldiv64_31743 muldiv64 2-3 31743 NULL
100237 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
100238 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
100239 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
100240 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
100241 +get_count_order_31800 get_count_order 0 31800 NULL
100242 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
100243 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
100244 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
100245 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
100246 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
100247 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
100248 +xattr_permission_31907 xattr_permission 0 31907 NULL
100249 +new_dir_31919 new_dir 3 31919 NULL
100250 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
100251 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
100252 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
100253 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
100254 +vb2_write_31948 vb2_write 3 31948 NULL
100255 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
100256 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
100257 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
100258 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
100259 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
100260 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
100261 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
100262 +calc_hmac_32010 calc_hmac 3 32010 NULL
100263 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
100264 +aead_len_32021 aead_len 0 32021 NULL
100265 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
100266 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
100267 +stk_read_32038 stk_read 3 32038 NULL
100268 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
100269 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
100270 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
100271 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
100272 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
100273 +bio_alloc_32095 bio_alloc 2 32095 NULL
100274 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
100275 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
100276 +disk_status_32120 disk_status 4 32120 NULL
100277 +venus_link_32165 venus_link 5 32165 NULL
100278 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
100279 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
100280 +load_header_32183 load_header 0 32183 NULL
100281 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
100282 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
100283 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
100284 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
100285 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
100286 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
100287 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
100288 +hex_string_32310 hex_string 0 32310 NULL
100289 +SyS_select_32319 SyS_select 1 32319 NULL
100290 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
100291 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
100292 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
100293 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
100294 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
100295 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
100296 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
100297 +local_clock_32385 local_clock 0 32385 NULL
100298 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
100299 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
100300 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
100301 +log_text_32428 log_text 0 32428 NULL
100302 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
100303 +hid_input_report_32458 hid_input_report 4 32458 NULL
100304 +cache_status_32462 cache_status 5 32462 NULL
100305 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
100306 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
100307 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
100308 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
100309 +disconnect_32521 disconnect 4 32521 NULL
100310 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
100311 +ilo_read_32531 ilo_read 3 32531 NULL
100312 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
100313 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
100314 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
100315 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
100316 +__first_node_32558 __first_node 0 32558 NULL
100317 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
100318 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
100319 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
100320 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
100321 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
100322 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
100323 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
100324 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
100325 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
100326 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
100327 +kvmalloc_32646 kvmalloc 1 32646 NULL
100328 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
100329 +generic_readlink_32654 generic_readlink 3 32654 NULL
100330 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
100331 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
100332 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
100333 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
100334 +get_arg_page_32746 get_arg_page 2 32746 NULL
100335 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
100336 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
100337 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
100338 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
100339 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
100340 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
100341 +vga_rseq_32848 vga_rseq 0 32848 NULL
100342 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
100343 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
100344 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
100345 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
100346 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
100347 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
100348 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
100349 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
100350 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
100351 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
100352 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
100353 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
100354 +compat_filldir_32999 compat_filldir 3 32999 NULL
100355 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
100356 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
100357 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
100358 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
100359 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
100360 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
100361 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
100362 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
100363 +alloc_tio_33077 alloc_tio 3 33077 NULL
100364 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
100365 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
100366 +write_node_33121 write_node 4 33121 NULL
100367 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
100368 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
100369 +__len_within_target_33132 __len_within_target 0 33132 NULL
100370 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
100371 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
100372 +pp_read_33210 pp_read 3 33210 NULL
100373 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
100374 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
100375 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
100376 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
100377 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
100378 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
100379 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
100380 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
100381 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
100382 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
100383 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
100384 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
100385 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
100386 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
100387 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
100388 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
100389 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
100390 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
100391 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
100392 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
100393 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
100394 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
100395 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
100396 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
100397 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
100398 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
100399 +create_entry_33479 create_entry 2 33479 NULL
100400 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
100401 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
100402 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
100403 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
100404 +res_counter_read_33499 res_counter_read 4 33499 NULL
100405 +fb_read_33506 fb_read 3 33506 NULL
100406 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
100407 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
100408 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
100409 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
100410 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
100411 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
100412 +dup_array_33551 dup_array 3 33551 NULL
100413 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
100414 +count_subheaders_33591 count_subheaders 0 33591 NULL
100415 +scsi_execute_33596 scsi_execute 5 33596 NULL
100416 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
100417 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
100418 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
100419 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
100420 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
100421 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
100422 +inw_p_33668 inw_p 0 33668 NULL
100423 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
100424 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
100425 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
100426 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
100427 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
100428 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
100429 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
100430 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
100431 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
100432 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
100433 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
100434 +Read_hfc_33755 Read_hfc 0 33755 NULL
100435 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
100436 +hashtab_create_33769 hashtab_create 3 33769 NULL
100437 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
100438 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
100439 +find_next_offset_33804 find_next_offset 3 33804 NULL
100440 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
100441 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
100442 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
100443 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
100444 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
100445 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
100446 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
100447 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
100448 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
100449 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
100450 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
100451 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
100452 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
100453 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
100454 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
100455 +ppp_write_34034 ppp_write 3 34034 NULL
100456 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
100457 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
100458 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
100459 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
100460 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
100461 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
100462 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
100463 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
100464 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
100465 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
100466 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
100467 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
100468 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
100469 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
100470 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
100471 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
100472 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
100473 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
100474 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
100475 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
100476 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
100477 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
100478 +__insert_34349 __insert 2-3 34349 NULL
100479 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
100480 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
100481 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
100482 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
100483 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
100484 +ea_read_34378 ea_read 0 34378 NULL
100485 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
100486 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
100487 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
100488 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
100489 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
100490 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
100491 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
100492 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
100493 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
100494 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
100495 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
100496 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
100497 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
100498 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
100499 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
100500 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
100501 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
100502 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
100503 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
100504 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
100505 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
100506 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
100507 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
100508 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
100509 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
100510 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
100511 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
100512 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
100513 +port_print_34704 port_print 3 34704 NULL
100514 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
100515 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
100516 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
100517 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
100518 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
100519 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
100520 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
100521 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
100522 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
100523 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
100524 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
100525 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
100526 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
100527 +msg_print_text_34889 msg_print_text 0 34889 NULL
100528 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
100529 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
100530 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
100531 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
100532 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
100533 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
100534 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
100535 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
100536 +Realloc_34961 Realloc 2 34961 NULL
100537 +mq_lookup_34990 mq_lookup 2 34990 NULL
100538 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
100539 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
100540 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
100541 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
100542 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
100543 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
100544 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
100545 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
100546 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
100547 +store_ifalias_35088 store_ifalias 4 35088 NULL
100548 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
100549 +capi_write_35104 capi_write 3 35104 NULL nohasharray
100550 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
100551 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
100552 +pointer_35138 pointer 0 35138 NULL
100553 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
100554 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
100555 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
100556 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
100557 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
100558 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
100559 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
100560 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
100561 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
100562 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
100563 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
100564 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
100565 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
100566 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
100567 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
100568 +set_fd_set_35249 set_fd_set 1 35249 NULL
100569 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
100570 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
100571 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
100572 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
100573 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
100574 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
100575 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
100576 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
100577 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
100578 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
100579 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
100580 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
100581 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
100582 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
100583 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
100584 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
100585 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
100586 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
100587 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
100588 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
100589 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
100590 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
100591 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
100592 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
100593 +async_setkey_35521 async_setkey 3 35521 NULL
100594 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
100595 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
100596 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
100597 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
100598 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
100599 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
100600 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
100601 +ReadZReg_35604 ReadZReg 0 35604 NULL
100602 +kernel_readv_35617 kernel_readv 3 35617 NULL
100603 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
100604 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
100605 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
100606 +store_debug_level_35652 store_debug_level 3 35652 NULL
100607 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
100608 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
100609 +dm_table_create_35687 dm_table_create 3 35687 NULL
100610 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
100611 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
100612 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
100613 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
100614 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
100615 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
100616 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
100617 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
100618 +fls64_35862 fls64 0 35862 NULL
100619 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
100620 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
100621 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
100622 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
100623 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
100624 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
100625 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
100626 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
100627 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
100628 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
100629 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
100630 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
100631 +acl_alloc_35979 acl_alloc 1 35979 NULL
100632 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
100633 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
100634 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
100635 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
100636 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
100637 +account_shadowed_36048 account_shadowed 2 36048 NULL
100638 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
100639 +write_emulate_36065 write_emulate 2-4 36065 NULL
100640 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
100641 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
100642 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
100643 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
100644 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
100645 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
100646 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
100647 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
100648 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
100649 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
100650 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
100651 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
100652 +twl_set_36154 twl_set 2 36154 NULL
100653 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
100654 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
100655 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
100656 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
100657 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
100658 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
100659 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
100660 +is_dirty_36223 is_dirty 2 36223 NULL
100661 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
100662 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
100663 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
100664 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
100665 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
100666 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
100667 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
100668 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
100669 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
100670 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
100671 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
100672 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
100673 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
100674 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
100675 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
100676 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
100677 +lc_create_36332 lc_create 4 36332 NULL
100678 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
100679 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
100680 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
100681 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
100682 +to_sector_36361 to_sector 0-1 36361 NULL
100683 +tunables_read_36385 tunables_read 3 36385 NULL
100684 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
100685 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
100686 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
100687 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
100688 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
100689 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
100690 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
100691 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
100692 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
100693 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
100694 +get_param_l_36518 get_param_l 0 36518 NULL
100695 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
100696 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
100697 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
100698 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
100699 +get_entry_len_36549 get_entry_len 0 36549 NULL
100700 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
100701 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
100702 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
100703 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
100704 +__erst_read_36579 __erst_read 0 36579 NULL
100705 +put_cmsg_36589 put_cmsg 4 36589 NULL
100706 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
100707 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
100708 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
100709 +format_decode_36638 format_decode 0 36638 NULL
100710 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
100711 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
100712 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
100713 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
100714 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
100715 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
100716 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
100717 +sched_clock_36717 sched_clock 0 36717 NULL
100718 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
100719 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
100720 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
100721 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
100722 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
100723 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
100724 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
100725 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
100726 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
100727 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
100728 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
100729 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
100730 +cm_write_36858 cm_write 3 36858 NULL
100731 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
100732 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
100733 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
100734 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
100735 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
100736 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
100737 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
100738 +build_key_36931 build_key 1 36931 NULL
100739 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
100740 +write_leb_36957 write_leb 5 36957 NULL
100741 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
100742 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
100743 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
100744 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
100745 +setxattr_37006 setxattr 4 37006 NULL
100746 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
100747 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
100748 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
100749 +parse_command_37079 parse_command 2 37079 NULL
100750 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
100751 +tun_get_user_37094 tun_get_user 5 37094 NULL
100752 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
100753 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
100754 +msg_word_37164 msg_word 0 37164 NULL
100755 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
100756 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
100757 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
100758 +__do_replace_37227 __do_replace 5 37227 NULL
100759 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
100760 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
100761 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
100762 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
100763 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
100764 +c101_run_37279 c101_run 2 37279 NULL
100765 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
100766 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
100767 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
100768 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
100769 +send_msg_37323 send_msg 4 37323 NULL
100770 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
100771 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
100772 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
100773 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
100774 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
100775 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
100776 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
100777 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
100778 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
100779 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
100780 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
100781 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
100782 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
100783 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
100784 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
100785 +__remove_37457 __remove 2 37457 NULL
100786 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
100787 +get_est_timing_37484 get_est_timing 0 37484 NULL
100788 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
100789 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
100790 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
100791 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
100792 +hdr_size_37536 hdr_size 0 37536 NULL
100793 +a2p_37544 a2p 0-1 37544 NULL
100794 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
100795 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
100796 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
100797 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
100798 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
100799 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
100800 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
100801 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
100802 +check_pt_base_37635 check_pt_base 3 37635 NULL
100803 +alloc_fd_37637 alloc_fd 1 37637 NULL
100804 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
100805 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
100806 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
100807 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
100808 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
100809 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
100810 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
100811 +nametbl_header_37698 nametbl_header 2 37698 NULL
100812 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
100813 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
100814 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
100815 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
100816 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
100817 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
100818 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
100819 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
100820 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
100821 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
100822 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
100823 +deny_write_access_37813 deny_write_access 0 37813 NULL
100824 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
100825 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
100826 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
100827 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
100828 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
100829 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
100830 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
100831 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
100832 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
100833 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
100834 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
100835 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
100836 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
100837 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
100838 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
100839 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
100840 +vfs_readv_38011 vfs_readv 3 38011 NULL
100841 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
100842 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
100843 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
100844 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
100845 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
100846 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
100847 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
100848 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
100849 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
100850 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
100851 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
100852 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
100853 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
100854 +ep0_read_38095 ep0_read 3 38095 NULL
100855 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
100856 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
100857 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
100858 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
100859 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
100860 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
100861 +cdev_add_38176 cdev_add 2-3 38176 NULL
100862 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
100863 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
100864 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
100865 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
100866 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
100867 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
100868 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
100869 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
100870 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
100871 +from_dblock_38256 from_dblock 0-1 38256 NULL
100872 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
100873 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
100874 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
100875 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
100876 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
100877 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
100878 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
100879 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
100880 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
100881 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
100882 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
100883 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
100884 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
100885 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
100886 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
100887 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
100888 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
100889 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
100890 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
100891 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
100892 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
100893 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
100894 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
100895 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
100896 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
100897 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
100898 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
100899 +dev_names_read_38509 dev_names_read 3 38509 NULL
100900 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
100901 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
100902 +set_queue_count_38519 set_queue_count 0 38519 NULL
100903 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
100904 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
100905 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
100906 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
100907 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
100908 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
100909 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
100910 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
100911 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
100912 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
100913 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
100914 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
100915 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
100916 +cma_create_area_38642 cma_create_area 2 38642 NULL
100917 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
100918 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
100919 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
100920 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
100921 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
100922 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
100923 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
100924 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
100925 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
100926 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
100927 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
100928 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
100929 +udf_readpages_38761 udf_readpages 4 38761 NULL
100930 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
100931 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
100932 +err_decode_38804 err_decode 2 38804 NULL
100933 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
100934 +sys_select_38827 sys_select 1 38827 NULL
100935 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
100936 +direct_entry_38836 direct_entry 3 38836 NULL
100937 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
100938 +interfaces_38859 interfaces 2 38859 NULL
100939 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
100940 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
100941 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
100942 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
100943 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
100944 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
100945 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
100946 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
100947 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
100948 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
100949 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
100950 +udf_new_block_38999 udf_new_block 4 38999 NULL
100951 +get_nodes_39012 get_nodes 3 39012 NULL
100952 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
100953 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
100954 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
100955 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
100956 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
100957 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
100958 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
100959 +ea_foreach_39133 ea_foreach 0 39133 NULL
100960 +generic_permission_39150 generic_permission 0 39150 NULL
100961 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
100962 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
100963 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
100964 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
100965 +init_list_set_39188 init_list_set 2-3 39188 NULL
100966 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
100967 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
100968 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
100969 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
100970 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
100971 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
100972 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
100973 +drm_order_39244 drm_order 0 39244 NULL
100974 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
100975 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
100976 +__skb_cow_39254 __skb_cow 2 39254 NULL
100977 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
100978 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
100979 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
100980 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
100981 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
100982 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
100983 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
100984 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
100985 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
100986 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
100987 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
100988 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
100989 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
100990 +__send_to_port_39386 __send_to_port 3 39386 NULL
100991 +user_power_read_39414 user_power_read 3 39414 NULL
100992 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
100993 +sys_semop_39457 sys_semop 3 39457 NULL
100994 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
100995 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
100996 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
100997 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
100998 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
100999 +int_proc_write_39542 int_proc_write 3 39542 NULL
101000 +pp_write_39554 pp_write 3 39554 NULL
101001 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
101002 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
101003 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
101004 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
101005 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
101006 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
101007 +ext_depth_39607 ext_depth 0 39607 NULL
101008 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
101009 +sdio_readb_39618 sdio_readb 0 39618 NULL
101010 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
101011 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
101012 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
101013 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
101014 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
101015 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
101016 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
101017 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
101018 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
101019 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
101020 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
101021 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
101022 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
101023 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
101024 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
101025 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
101026 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
101027 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
101028 +pkt_add_39897 pkt_add 3 39897 NULL
101029 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
101030 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
101031 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
101032 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
101033 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
101034 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
101035 +__spi_async_39932 __spi_async 0 39932 NULL
101036 +__get_order_39935 __get_order 0 39935 NULL
101037 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
101038 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
101039 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
101040 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
101041 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
101042 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
101043 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
101044 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
101045 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
101046 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
101047 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
101048 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
101049 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
101050 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
101051 +add_tty_40055 add_tty 1 40055 NULL nohasharray
101052 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
101053 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
101054 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
101055 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
101056 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
101057 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
101058 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
101059 +pt_write_40159 pt_write 3 40159 NULL
101060 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
101061 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
101062 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
101063 +allocate_probes_40204 allocate_probes 1 40204 NULL
101064 +compat_put_long_40214 compat_put_long 1 40214 NULL
101065 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
101066 +osst_read_40237 osst_read 3 40237 NULL
101067 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
101068 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
101069 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
101070 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
101071 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
101072 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
101073 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
101074 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
101075 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
101076 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
101077 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
101078 +mmio_read_40348 mmio_read 4 40348 NULL
101079 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
101080 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
101081 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
101082 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
101083 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
101084 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
101085 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
101086 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
101087 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
101088 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
101089 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
101090 +tty_write_room_40495 tty_write_room 0 40495 NULL
101091 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
101092 +sg_phys_40507 sg_phys 0 40507 NULL
101093 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
101094 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
101095 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
101096 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
101097 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
101098 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
101099 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
101100 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
101101 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
101102 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
101103 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
101104 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
101105 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
101106 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
101107 +fops_read_40672 fops_read 3 40672 NULL
101108 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
101109 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
101110 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
101111 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
101112 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
101113 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
101114 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
101115 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
101116 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
101117 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
101118 +card_send_command_40757 card_send_command 3 40757 NULL
101119 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
101120 +pg_write_40766 pg_write 3 40766 NULL
101121 +show_list_40775 show_list 3 40775 NULL
101122 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
101123 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
101124 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
101125 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
101126 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
101127 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
101128 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
101129 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
101130 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
101131 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
101132 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
101133 +read_file_queue_40895 read_file_queue 3 40895 NULL
101134 +waiters_read_40902 waiters_read 3 40902 NULL
101135 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
101136 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
101137 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
101138 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
101139 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
101140 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
101141 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
101142 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
101143 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
101144 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
101145 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
101146 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
101147 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
101148 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
101149 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
101150 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
101151 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
101152 +dma_attach_41094 dma_attach 5-6 41094 NULL
101153 +provide_user_output_41105 provide_user_output 3 41105 NULL
101154 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
101155 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
101156 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
101157 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
101158 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
101159 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
101160 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
101161 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
101162 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
101163 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
101164 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
101165 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
101166 +erst_read_41260 erst_read 0 41260 NULL
101167 +__fprog_create_41263 __fprog_create 2 41263 NULL
101168 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
101169 +alloc_context_41283 alloc_context 1 41283 NULL
101170 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
101171 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
101172 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
101173 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
101174 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
101175 +kmp_init_41373 kmp_init 2 41373 NULL
101176 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
101177 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
101178 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
101179 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
101180 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
101181 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
101182 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
101183 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
101184 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
101185 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
101186 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
101187 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
101188 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
101189 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
101190 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
101191 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
101192 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
101193 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
101194 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
101195 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
101196 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
101197 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
101198 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
101199 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
101200 +vga_io_r_41609 vga_io_r 0 41609 NULL
101201 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
101202 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
101203 +a2mp_send_41615 a2mp_send 4 41615 NULL
101204 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
101205 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
101206 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
101207 +get_std_timing_41654 get_std_timing 0 41654 NULL
101208 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
101209 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
101210 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
101211 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
101212 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
101213 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
101214 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
101215 +fillonedir_41746 fillonedir 3 41746 NULL
101216 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
101217 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
101218 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
101219 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
101220 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
101221 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
101222 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
101223 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
101224 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
101225 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
101226 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
101227 +get_packet_41914 get_packet 3 41914 NULL
101228 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
101229 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
101230 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
101231 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
101232 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
101233 +read_gssp_41947 read_gssp 3 41947 NULL
101234 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
101235 +portnames_read_41958 portnames_read 3 41958 NULL
101236 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
101237 +dst_mtu_41969 dst_mtu 0 41969 NULL
101238 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
101239 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
101240 +lguest_map_42008 lguest_map 1-2 42008 NULL
101241 +pool_allocate_42012 pool_allocate 3 42012 NULL
101242 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
101243 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
101244 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
101245 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
101246 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
101247 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
101248 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
101249 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
101250 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
101251 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
101252 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
101253 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
101254 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
101255 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
101256 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
101257 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
101258 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
101259 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
101260 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
101261 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
101262 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
101263 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
101264 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
101265 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
101266 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
101267 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
101268 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
101269 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
101270 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
101271 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
101272 +free_cblock_42318 free_cblock 2 42318 NULL
101273 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
101274 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
101275 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
101276 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
101277 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
101278 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
101279 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
101280 +krng_get_random_42420 krng_get_random 3 42420 NULL
101281 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
101282 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
101283 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
101284 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
101285 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
101286 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
101287 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
101288 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
101289 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
101290 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
101291 +bypass_write_42498 bypass_write 3 42498 NULL
101292 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
101293 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
101294 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
101295 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
101296 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
101297 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
101298 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
101299 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
101300 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
101301 +map_state_42602 map_state 1 42602 NULL nohasharray
101302 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
101303 +nd_get_link_42603 nd_get_link 0 42603 NULL
101304 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
101305 +resp_write_42628 resp_write 2 42628 NULL
101306 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
101307 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
101308 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
101309 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
101310 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
101311 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
101312 +vb2_read_42703 vb2_read 3 42703 NULL
101313 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
101314 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
101315 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
101316 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
101317 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
101318 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
101319 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
101320 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
101321 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
101322 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
101323 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
101324 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
101325 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
101326 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
101327 +set_arg_42824 set_arg 3 42824 NULL
101328 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
101329 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
101330 +prandom_u32_42853 prandom_u32 0 42853 NULL
101331 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
101332 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
101333 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
101334 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
101335 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
101336 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
101337 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
101338 +hd_end_request_42904 hd_end_request 2 42904 NULL
101339 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
101340 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
101341 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
101342 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
101343 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
101344 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
101345 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
101346 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
101347 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
101348 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
101349 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
101350 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
101351 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
101352 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
101353 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
101354 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
101355 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
101356 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
101357 +uuid_string_43154 uuid_string 0 43154 NULL
101358 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
101359 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
101360 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
101361 +process_measurement_43190 process_measurement 0 43190 NULL
101362 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
101363 +uio_write_43202 uio_write 3 43202 NULL
101364 +iso_callback_43208 iso_callback 3 43208 NULL
101365 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
101366 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
101367 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
101368 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
101369 +fixup_leb_43256 fixup_leb 3 43256 NULL
101370 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
101371 +evtchn_write_43278 evtchn_write 3 43278 NULL
101372 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
101373 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
101374 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
101375 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
101376 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
101377 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
101378 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
101379 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
101380 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
101381 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
101382 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
101383 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
101384 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
101385 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
101386 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
101387 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
101388 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
101389 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
101390 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
101391 +do_readlink_43518 do_readlink 2 43518 NULL
101392 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
101393 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
101394 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
101395 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
101396 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
101397 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
101398 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
101399 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
101400 +proc_read_43614 proc_read 3 43614 NULL
101401 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
101402 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
101403 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
101404 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
101405 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
101406 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
101407 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
101408 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
101409 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
101410 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
101411 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
101412 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
101413 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
101414 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
101415 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
101416 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
101417 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
101418 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
101419 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
101420 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
101421 +read_flush_43851 read_flush 3 43851 NULL
101422 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
101423 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
101424 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
101425 +SendString_43928 SendString 3 43928 NULL
101426 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
101427 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
101428 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
101429 +nla_reserve_43984 nla_reserve 3 43984 NULL
101430 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
101431 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
101432 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
101433 +emit_flags_44006 emit_flags 4-3 44006 NULL
101434 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
101435 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
101436 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
101437 +load_discard_44083 load_discard 3 44083 NULL
101438 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
101439 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
101440 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
101441 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
101442 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
101443 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
101444 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
101445 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
101446 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
101447 +__set_free_44211 __set_free 2 44211 NULL
101448 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
101449 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
101450 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
101451 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
101452 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
101453 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
101454 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
101455 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
101456 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
101457 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
101458 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
101459 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
101460 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
101461 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
101462 +__is_discarded_44359 __is_discarded 2 44359 NULL
101463 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
101464 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
101465 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
101466 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
101467 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
101468 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
101469 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
101470 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
101471 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
101472 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
101473 +bio_advance_44496 bio_advance 2 44496 NULL
101474 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
101475 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
101476 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
101477 +spidev_write_44510 spidev_write 3 44510 NULL
101478 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
101479 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
101480 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
101481 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
101482 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
101483 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
101484 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
101485 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
101486 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
101487 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
101488 +mpi_resize_44674 mpi_resize 2 44674 NULL
101489 +ts_read_44687 ts_read 3 44687 NULL
101490 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
101491 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
101492 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
101493 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
101494 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
101495 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
101496 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
101497 +set_brk_44749 set_brk 1 44749 NULL
101498 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
101499 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
101500 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
101501 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
101502 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
101503 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
101504 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
101505 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
101506 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
101507 +sisusb_write_44834 sisusb_write 3 44834 NULL
101508 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
101509 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
101510 +cubic_root_44848 cubic_root 1 44848 NULL
101511 +copydesc_user_44855 copydesc_user 3 44855 NULL
101512 +skb_availroom_44883 skb_availroom 0 44883 NULL
101513 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
101514 +do_tty_write_44896 do_tty_write 5 44896 NULL
101515 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
101516 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
101517 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
101518 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
101519 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
101520 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
101521 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
101522 +sel_write_user_45060 sel_write_user 3 45060 NULL
101523 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
101524 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
101525 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
101526 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
101527 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
101528 +usbdev_read_45114 usbdev_read 3 45114 NULL
101529 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
101530 +send_to_tty_45141 send_to_tty 3 45141 NULL
101531 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
101532 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
101533 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
101534 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
101535 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
101536 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
101537 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
101538 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
101539 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
101540 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
101541 +add_child_45201 add_child 4 45201 NULL
101542 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
101543 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
101544 +__dirty_45228 __dirty 2 45228 NULL
101545 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
101546 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
101547 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
101548 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
101549 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
101550 +pte_val_45313 pte_val 0 45313 NULL
101551 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
101552 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
101553 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
101554 +keymap_store_45406 keymap_store 4 45406 NULL
101555 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
101556 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
101557 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
101558 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
101559 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
101560 +__node_remap_45458 __node_remap 4 45458 NULL
101561 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
101562 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
101563 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
101564 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
101565 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
101566 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
101567 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
101568 +copy_macs_45534 copy_macs 4 45534 NULL
101569 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
101570 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
101571 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
101572 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
101573 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
101574 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
101575 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
101576 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
101577 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
101578 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
101579 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
101580 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
101581 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
101582 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
101583 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
101584 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
101585 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
101586 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
101587 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
101588 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
101589 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
101590 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
101591 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
101592 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
101593 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
101594 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
101595 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
101596 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
101597 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
101598 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
101599 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
101600 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
101601 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
101602 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
101603 +isdn_write_45863 isdn_write 3 45863 NULL
101604 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
101605 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
101606 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
101607 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
101608 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
101609 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
101610 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
101611 +alloc_mr_45935 alloc_mr 1 45935 NULL
101612 +split_large_page_45941 split_large_page 2 45941 NULL
101613 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
101614 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
101615 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
101616 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
101617 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
101618 +get_free_entries_46030 get_free_entries 1 46030 NULL
101619 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
101620 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
101621 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
101622 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
101623 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
101624 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
101625 +slhc_toss_46066 slhc_toss 0 46066 NULL
101626 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
101627 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
101628 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
101629 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
101630 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
101631 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
101632 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
101633 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
101634 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
101635 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
101636 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
101637 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
101638 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
101639 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
101640 +add_conn_list_46197 add_conn_list 3 46197 NULL
101641 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
101642 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
101643 +dsp_write_46218 dsp_write 2 46218 NULL
101644 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
101645 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
101646 +ReadReg_46277 ReadReg 0 46277 NULL
101647 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
101648 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
101649 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
101650 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
101651 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
101652 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
101653 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
101654 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
101655 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
101656 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
101657 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
101658 +filldir64_46469 filldir64 3 46469 NULL
101659 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
101660 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
101661 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
101662 +kmsg_read_46514 kmsg_read 3 46514 NULL
101663 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
101664 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
101665 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
101666 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
101667 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
101668 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
101669 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
101670 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
101671 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
101672 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
101673 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
101674 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
101675 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
101676 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
101677 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
101678 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
101679 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
101680 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
101681 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
101682 +prepare_copy_46725 prepare_copy 2 46725 NULL
101683 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
101684 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
101685 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
101686 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
101687 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
101688 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
101689 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
101690 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
101691 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
101692 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
101693 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
101694 +spi_async_46857 spi_async 0 46857 NULL
101695 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
101696 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
101697 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
101698 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
101699 +rvmalloc_46873 rvmalloc 1 46873 NULL
101700 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
101701 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
101702 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
101703 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
101704 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
101705 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
101706 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
101707 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
101708 +fb_write_46924 fb_write 3 46924 NULL
101709 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
101710 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
101711 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
101712 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
101713 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
101714 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
101715 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
101716 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
101717 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
101718 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
101719 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
101720 +__map_single_47020 __map_single 3-4-7 47020 NULL
101721 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
101722 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
101723 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
101724 +fs_path_len_47060 fs_path_len 0 47060 NULL
101725 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
101726 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
101727 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
101728 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
101729 +mousedev_read_47123 mousedev_read 3 47123 NULL
101730 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
101731 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
101732 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
101733 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
101734 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
101735 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
101736 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
101737 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
101738 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
101739 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
101740 +l2headersize_47238 l2headersize 0 47238 NULL
101741 +options_write_47243 options_write 3 47243 NULL
101742 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
101743 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
101744 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
101745 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
101746 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
101747 +vsnprintf_47291 vsnprintf 0 47291 NULL
101748 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
101749 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
101750 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
101751 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
101752 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
101753 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
101754 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
101755 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
101756 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
101757 +nametbl_list_47391 nametbl_list 2 47391 NULL
101758 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
101759 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
101760 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
101761 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
101762 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
101763 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
101764 +vzalloc_47421 vzalloc 1 47421 NULL
101765 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
101766 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
101767 +__load_mapping_47460 __load_mapping 2 47460 NULL
101768 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
101769 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
101770 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
101771 +core_sys_select_47494 core_sys_select 1 47494 NULL
101772 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
101773 +unlink_simple_47506 unlink_simple 3 47506 NULL
101774 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
101775 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
101776 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
101777 +oz_events_read_47535 oz_events_read 3 47535 NULL
101778 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
101779 +read_ldt_47570 read_ldt 2 47570 NULL
101780 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
101781 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
101782 +pci_iomap_47575 pci_iomap 3 47575 NULL
101783 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
101784 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
101785 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
101786 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
101787 +uea_request_47613 uea_request 4 47613 NULL
101788 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
101789 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
101790 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
101791 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
101792 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
101793 +save_microcode_47717 save_microcode 3 47717 NULL
101794 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
101795 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
101796 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
101797 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
101798 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
101799 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
101800 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
101801 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
101802 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
101803 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
101804 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
101805 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
101806 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
101807 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
101808 +vhci_read_47878 vhci_read 3 47878 NULL
101809 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
101810 +load_mapping_47904 load_mapping 3 47904 NULL
101811 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
101812 +comedi_write_47926 comedi_write 3 47926 NULL
101813 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
101814 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
101815 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
101816 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
101817 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
101818 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
101819 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
101820 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
101821 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
101822 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
101823 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
101824 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
101825 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
101826 +disc_write_48070 disc_write 3 48070 NULL
101827 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
101828 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
101829 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
101830 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
101831 +set_discoverable_48141 set_discoverable 4 48141 NULL
101832 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
101833 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
101834 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
101835 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
101836 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
101837 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
101838 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
101839 +init_ipath_48187 init_ipath 1 48187 NULL
101840 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
101841 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
101842 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
101843 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
101844 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
101845 +read_file_recv_48232 read_file_recv 3 48232 NULL
101846 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
101847 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
101848 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
101849 +send_set_info_48288 send_set_info 7 48288 NULL
101850 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
101851 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
101852 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
101853 +hash_setkey_48310 hash_setkey 3 48310 NULL
101854 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
101855 +skb_add_data_48363 skb_add_data 3 48363 NULL
101856 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
101857 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
101858 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
101859 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
101860 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
101861 +print_filtered_48442 print_filtered 2-0 48442 NULL
101862 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
101863 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
101864 +send_control_msg_48498 send_control_msg 6 48498 NULL
101865 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
101866 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
101867 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
101868 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
101869 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
101870 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
101871 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
101872 +named_distribute_48544 named_distribute 4 48544 NULL
101873 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
101874 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
101875 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
101876 +mtd_read_48655 mtd_read 0 48655 NULL
101877 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
101878 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
101879 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
101880 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
101881 +altera_drscan_48698 altera_drscan 2 48698 NULL
101882 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
101883 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
101884 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
101885 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
101886 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
101887 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
101888 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
101889 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
101890 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
101891 +azx_get_position_48841 azx_get_position 0 48841 NULL
101892 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
101893 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
101894 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
101895 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
101896 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
101897 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
101898 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
101899 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
101900 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
101901 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
101902 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
101903 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
101904 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
101905 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
101906 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
101907 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
101908 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
101909 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
101910 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
101911 +transient_status_49027 transient_status 4 49027 NULL
101912 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
101913 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
101914 +ubi_read_49061 ubi_read 0 49061 NULL
101915 +scsi_register_49094 scsi_register 2 49094 NULL
101916 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
101917 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
101918 +check_exists_49119 check_exists 2 49119 NULL nohasharray
101919 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
101920 +pt_read_49136 pt_read 3 49136 NULL
101921 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
101922 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
101923 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
101924 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
101925 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
101926 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
101927 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
101928 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
101929 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
101930 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
101931 +resp_write_same_49217 resp_write_same 2 49217 NULL
101932 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
101933 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
101934 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
101935 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
101936 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
101937 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
101938 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
101939 +uio_read_49300 uio_read 3 49300 NULL
101940 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
101941 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
101942 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
101943 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
101944 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
101945 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
101946 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
101947 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
101948 +px_raw_event_49371 px_raw_event 4 49371 NULL
101949 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
101950 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
101951 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
101952 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
101953 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
101954 +md_domain_init_49432 md_domain_init 2 49432 NULL
101955 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
101956 +get_lru_size_49441 get_lru_size 0 49441 NULL
101957 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
101958 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
101959 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
101960 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
101961 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
101962 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
101963 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
101964 +smk_write_access_49561 smk_write_access 3 49561 NULL
101965 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
101966 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
101967 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
101968 +tap_write_49595 tap_write 3 49595 NULL
101969 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
101970 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
101971 +heap_init_49617 heap_init 2 49617 NULL
101972 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
101973 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
101974 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
101975 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
101976 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
101977 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
101978 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
101979 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
101980 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
101981 +check_frame_49741 check_frame 0 49741 NULL
101982 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
101983 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
101984 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
101985 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
101986 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
101987 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
101988 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
101989 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
101990 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
101991 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
101992 +add_uuid_49831 add_uuid 4 49831 NULL
101993 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
101994 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
101995 +twl4030_write_49846 twl4030_write 2 49846 NULL
101996 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
101997 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
101998 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
101999 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
102000 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
102001 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
102002 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
102003 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
102004 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
102005 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
102006 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
102007 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
102008 +__module_alloc_50004 __module_alloc 1 50004 NULL
102009 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
102010 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
102011 +isdn_read_50021 isdn_read 3 50021 NULL
102012 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
102013 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
102014 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
102015 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
102016 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
102017 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
102018 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
102019 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
102020 +read_file_slot_50111 read_file_slot 3 50111 NULL
102021 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
102022 +copy_items_50140 copy_items 6 50140 NULL
102023 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
102024 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
102025 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
102026 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
102027 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
102028 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
102029 +odev_update_50169 odev_update 2 50169 NULL
102030 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
102031 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
102032 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
102033 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
102034 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
102035 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
102036 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
102037 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
102038 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
102039 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
102040 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
102041 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
102042 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
102043 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
102044 +do_launder_page_50329 do_launder_page 0 50329 NULL
102045 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
102046 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
102047 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
102048 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
102049 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
102050 +tpm_read_50344 tpm_read 3 50344 NULL
102051 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
102052 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
102053 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
102054 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
102055 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
102056 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
102057 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
102058 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
102059 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
102060 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
102061 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
102062 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
102063 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
102064 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
102065 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
102066 +force_mapping_50464 force_mapping 2 50464 NULL
102067 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
102068 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
102069 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
102070 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
102071 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
102072 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
102073 +fat_readpages_50582 fat_readpages 4 50582 NULL
102074 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
102075 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
102076 +sge_rx_50594 sge_rx 3 50594 NULL
102077 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
102078 +__ffs_50625 __ffs 0 50625 NULL
102079 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
102080 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
102081 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
102082 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
102083 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
102084 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
102085 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
102086 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
102087 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
102088 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
102089 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
102090 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
102091 +skb_padto_50759 skb_padto 2 50759 NULL
102092 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
102093 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
102094 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
102095 +tpm_write_50798 tpm_write 3 50798 NULL
102096 +write_flush_50803 write_flush 3 50803 NULL
102097 +dvb_play_50814 dvb_play 3 50814 NULL
102098 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
102099 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
102100 +SetArea_50835 SetArea 4 50835 NULL nohasharray
102101 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
102102 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
102103 +self_check_write_50856 self_check_write 5 50856 NULL
102104 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
102105 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
102106 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
102107 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
102108 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
102109 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
102110 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
102111 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
102112 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
102113 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
102114 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
102115 +timeout_write_50991 timeout_write 3 50991 NULL
102116 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
102117 +proc_write_51003 proc_write 3 51003 NULL
102118 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
102119 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
102120 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
102121 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
102122 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
102123 +dump_midi_51040 dump_midi 3 51040 NULL
102124 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
102125 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
102126 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
102127 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
102128 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
102129 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
102130 +ti_recv_51110 ti_recv 3 51110 NULL
102131 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
102132 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
102133 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
102134 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
102135 +set_dirty_51144 set_dirty 3 51144 NULL
102136 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
102137 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
102138 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
102139 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
102140 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
102141 +tipc_send_51238 tipc_send 4 51238 NULL
102142 +drm_property_create_51239 drm_property_create 4 51239 NULL
102143 +st_read_51251 st_read 3 51251 NULL
102144 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
102145 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
102146 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
102147 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
102148 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
102149 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
102150 +get_cell_51316 get_cell 2 51316 NULL
102151 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
102152 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
102153 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
102154 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
102155 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
102156 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
102157 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
102158 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
102159 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
102160 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
102161 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
102162 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
102163 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
102164 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
102165 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
102166 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
102167 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
102168 +vaddr_51480 vaddr 0 51480 NULL
102169 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
102170 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
102171 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
102172 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
102173 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
102174 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
102175 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
102176 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
102177 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
102178 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
102179 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
102180 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
102181 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
102182 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
102183 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
102184 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
102185 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
102186 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
102187 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
102188 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
102189 +sel_write_access_51704 sel_write_access 3 51704 NULL
102190 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
102191 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
102192 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
102193 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
102194 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
102195 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
102196 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
102197 +if_write_51756 if_write 3 51756 NULL
102198 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
102199 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
102200 +to_ratio_51809 to_ratio 2-1 51809 NULL
102201 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
102202 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
102203 +ioread32_51847 ioread32 0 51847 NULL nohasharray
102204 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
102205 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
102206 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
102207 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
102208 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
102209 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
102210 +user_read_51881 user_read 3 51881 NULL
102211 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
102212 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
102213 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
102214 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
102215 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
102216 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
102217 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
102218 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
102219 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
102220 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
102221 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
102222 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
102223 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
102224 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
102225 +rdmalt_52022 rdmalt 0 52022 NULL
102226 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
102227 +override_release_52032 override_release 2 52032 NULL
102228 +end_port_52042 end_port 0 52042 NULL
102229 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
102230 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
102231 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
102232 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
102233 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
102234 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
102235 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
102236 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
102237 +retry_count_read_52129 retry_count_read 3 52129 NULL
102238 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
102239 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
102240 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
102241 +htable_size_52148 htable_size 0-1 52148 NULL
102242 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
102243 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
102244 +alix_present_52165 alix_present 1 52165 NULL
102245 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
102246 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
102247 +print_prefix_52176 print_prefix 0 52176 NULL
102248 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
102249 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
102250 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
102251 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
102252 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
102253 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
102254 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
102255 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
102256 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
102257 +atomic64_read_52300 atomic64_read 0 52300 NULL
102258 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
102259 +read_file_reset_52310 read_file_reset 3 52310 NULL
102260 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
102261 +hwflags_read_52318 hwflags_read 3 52318 NULL
102262 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
102263 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
102264 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
102265 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
102266 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
102267 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
102268 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
102269 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
102270 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
102271 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
102272 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
102273 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
102274 +delay_status_52431 delay_status 5 52431 NULL
102275 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
102276 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
102277 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
102278 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
102279 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
102280 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
102281 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
102282 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
102283 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
102284 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
102285 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
102286 +from_oblock_52546 from_oblock 0-1 52546 NULL
102287 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
102288 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
102289 +emit_code_52583 emit_code 0-3 52583 NULL
102290 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
102291 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
102292 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
102293 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
102294 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
102295 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
102296 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
102297 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
102298 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
102299 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
102300 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
102301 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
102302 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
102303 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
102304 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
102305 +twlreg_write_52880 twlreg_write 3 52880 NULL
102306 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
102307 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
102308 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
102309 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
102310 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
102311 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
102312 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
102313 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
102314 +send_packet_52960 send_packet 4 52960 NULL
102315 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
102316 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
102317 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
102318 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
102319 +num_node_state_52989 num_node_state 0 52989 NULL
102320 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
102321 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
102322 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
102323 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
102324 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
102325 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
102326 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
102327 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
102328 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
102329 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
102330 +verity_status_53120 verity_status 5 53120 NULL
102331 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
102332 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
102333 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
102334 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
102335 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
102336 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
102337 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
102338 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
102339 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
102340 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
102341 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
102342 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
102343 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
102344 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
102345 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
102346 +vm_mmap_53339 vm_mmap 0 53339 NULL
102347 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
102348 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
102349 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
102350 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
102351 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
102352 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
102353 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
102354 +n2_run_53459 n2_run 3 53459 NULL
102355 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
102356 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
102357 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
102358 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
102359 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
102360 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
102361 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
102362 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
102363 +check_acl_53512 check_acl 0 53512 NULL
102364 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
102365 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
102366 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
102367 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
102368 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
102369 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
102370 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
102371 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
102372 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
102373 +_preload_range_53676 _preload_range 2-3 53676 NULL
102374 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
102375 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
102376 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
102377 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
102378 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
102379 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
102380 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
102381 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
102382 +wdm_write_53735 wdm_write 3 53735 NULL
102383 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
102384 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
102385 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
102386 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
102387 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
102388 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
102389 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
102390 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
102391 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
102392 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
102393 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
102394 +pms_read_53873 pms_read 3 53873 NULL
102395 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
102396 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
102397 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
102398 +proc_file_read_53905 proc_file_read 3 53905 NULL
102399 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
102400 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
102401 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
102402 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
102403 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
102404 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
102405 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
102406 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
102407 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
102408 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
102409 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
102410 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
102411 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
102412 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
102413 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
102414 +_malloc_54077 _malloc 1 54077 NULL
102415 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
102416 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
102417 +create_xattr_54106 create_xattr 5 54106 NULL
102418 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
102419 +strn_len_54122 strn_len 0 54122 NULL
102420 +isku_receive_54130 isku_receive 4 54130 NULL
102421 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
102422 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
102423 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
102424 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
102425 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
102426 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
102427 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
102428 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
102429 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
102430 +reada_add_block_54247 reada_add_block 2 54247 NULL
102431 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
102432 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
102433 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
102434 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
102435 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
102436 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
102437 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
102438 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
102439 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
102440 +sprintf_54306 sprintf 0 54306 NULL
102441 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
102442 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
102443 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
102444 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
102445 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
102446 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
102447 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
102448 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
102449 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
102450 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
102451 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
102452 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
102453 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
102454 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
102455 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
102456 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
102457 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
102458 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
102459 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
102460 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
102461 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
102462 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
102463 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
102464 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
102465 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
102466 +viacam_read_54526 viacam_read 3 54526 NULL
102467 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
102468 +setsockopt_54539 setsockopt 5 54539 NULL
102469 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
102470 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
102471 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
102472 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
102473 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
102474 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
102475 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
102476 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
102477 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
102478 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
102479 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
102480 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
102481 +evm_read_key_54674 evm_read_key 3 54674 NULL
102482 +resource_string_54699 resource_string 0 54699 NULL
102483 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
102484 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
102485 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
102486 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
102487 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
102488 +kzalloc_54740 kzalloc 1 54740 NULL
102489 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
102490 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
102491 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
102492 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
102493 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
102494 +domain_init_54797 domain_init 2 54797 NULL
102495 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
102496 +get_dev_size_54807 get_dev_size 0 54807 NULL
102497 +nfsd_write_54809 nfsd_write 6 54809 NULL
102498 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
102499 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
102500 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
102501 +write_rio_54837 write_rio 3 54837 NULL
102502 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
102503 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
102504 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
102505 +printer_read_54851 printer_read 3 54851 NULL
102506 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
102507 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
102508 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
102509 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
102510 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
102511 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
102512 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
102513 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
102514 +add_port_54941 add_port 2 54941 NULL
102515 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
102516 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
102517 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
102518 +c4_add_card_54968 c4_add_card 3 54968 NULL
102519 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
102520 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
102521 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
102522 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
102523 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
102524 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
102525 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
102526 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
102527 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
102528 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
102529 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
102530 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
102531 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
102532 +corrupt_data_55120 corrupt_data 0 55120 NULL
102533 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
102534 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
102535 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
102536 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
102537 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
102538 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
102539 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
102540 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
102541 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
102542 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
102543 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
102544 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
102545 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
102546 +dump_command_55220 dump_command 1 55220 NULL
102547 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
102548 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
102549 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
102550 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
102551 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
102552 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
102553 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
102554 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
102555 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
102556 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
102557 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
102558 +do_shmat_55336 do_shmat 5 55336 NULL
102559 +vme_user_read_55338 vme_user_read 3 55338 NULL
102560 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
102561 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
102562 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
102563 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
102564 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
102565 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
102566 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
102567 +alloc_skb_55439 alloc_skb 1 55439 NULL
102568 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
102569 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
102570 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
102571 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
102572 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
102573 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
102574 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
102575 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
102576 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
102577 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
102578 +ea_get_55522 ea_get 0 55522 NULL
102579 +buffer_size_55534 buffer_size 0 55534 NULL
102580 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
102581 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
102582 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
102583 +add_partition_55588 add_partition 2 55588 NULL
102584 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
102585 +free_pages_55603 free_pages 1 55603 NULL
102586 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
102587 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
102588 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
102589 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
102590 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
102591 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
102592 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
102593 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
102594 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
102595 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
102596 +read_oldmem_55658 read_oldmem 3 55658 NULL
102597 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
102598 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
102599 +get_info_55681 get_info 3 55681 NULL
102600 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
102601 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
102602 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
102603 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
102604 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
102605 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
102606 +set_local_name_55757 set_local_name 4 55757 NULL
102607 +strlen_55778 strlen 0 55778 NULL
102608 +set_spte_55783 set_spte 5-4 55783 NULL
102609 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
102610 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
102611 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
102612 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
102613 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
102614 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
102615 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
102616 +hsc_write_55875 hsc_write 3 55875 NULL
102617 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
102618 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
102619 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
102620 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
102621 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
102622 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
102623 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
102624 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
102625 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
102626 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
102627 +__set_discard_56081 __set_discard 2 56081 NULL
102628 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
102629 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
102630 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
102631 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
102632 +map_addr_56144 map_addr 7 56144 NULL
102633 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
102634 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
102635 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
102636 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
102637 +skb_headroom_56200 skb_headroom 0 56200 NULL
102638 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
102639 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
102640 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
102641 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
102642 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
102643 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
102644 +fd_copyin_56247 fd_copyin 3 56247 NULL
102645 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
102646 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
102647 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
102648 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
102649 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
102650 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
102651 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
102652 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
102653 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
102654 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
102655 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
102656 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
102657 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
102658 +dev_read_56369 dev_read 3 56369 NULL
102659 +write_gssp_56404 write_gssp 3 56404 NULL
102660 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
102661 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
102662 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
102663 +store_msg_56417 store_msg 3 56417 NULL
102664 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
102665 +fl_create_56435 fl_create 5 56435 NULL
102666 +gnttab_map_56439 gnttab_map 2 56439 NULL
102667 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
102668 +set_connectable_56458 set_connectable 4 56458 NULL
102669 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
102670 +putused_user_56467 putused_user 3 56467 NULL
102671 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
102672 +global_rt_period_56476 global_rt_period 0 56476 NULL
102673 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
102674 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
102675 +init_map_ip_56508 init_map_ip 5 56508 NULL
102676 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
102677 +ip_options_get_56538 ip_options_get 4 56538 NULL
102678 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
102679 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
102680 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
102681 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
102682 +event_filter_write_56609 event_filter_write 3 56609 NULL
102683 +gather_array_56641 gather_array 3 56641 NULL
102684 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
102685 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
102686 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
102687 +build_map_info_56696 build_map_info 2 56696 NULL
102688 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
102689 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
102690 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
102691 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
102692 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
102693 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
102694 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
102695 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
102696 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
102697 +hash_lookup_56792 hash_lookup 2 56792 NULL
102698 +do_syslog_56807 do_syslog 3 56807 NULL
102699 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
102700 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
102701 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
102702 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
102703 +wb_lookup_56858 wb_lookup 2 56858 NULL
102704 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
102705 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
102706 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
102707 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
102708 +strcspn_56913 strcspn 0 56913 NULL
102709 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
102710 +check_header_56930 check_header 2 56930 NULL
102711 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
102712 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
102713 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
102714 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
102715 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
102716 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
102717 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
102718 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
102719 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
102720 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
102721 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
102722 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
102723 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
102724 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
102725 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
102726 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
102727 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
102728 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
102729 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
102730 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
102731 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
102732 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
102733 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
102734 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
102735 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
102736 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
102737 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
102738 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
102739 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
102740 +flush_space_57241 flush_space 3 57241 NULL
102741 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
102742 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
102743 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
102744 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
102745 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
102746 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
102747 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
102748 +fw_file_size_57307 fw_file_size 0 57307 NULL
102749 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
102750 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
102751 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
102752 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
102753 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
102754 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
102755 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
102756 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
102757 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
102758 +read_file_blob_57406 read_file_blob 3 57406 NULL
102759 +enclosure_register_57412 enclosure_register 3 57412 NULL
102760 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
102761 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
102762 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
102763 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
102764 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
102765 +ReadReg_57453 ReadReg 0 57453 NULL
102766 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
102767 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
102768 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
102769 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
102770 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
102771 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
102772 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
102773 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
102774 +skb_headlen_57501 skb_headlen 0 57501 NULL
102775 +copy_in_user_57502 copy_in_user 3 57502 NULL
102776 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
102777 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
102778 +init_tag_map_57515 init_tag_map 3 57515 NULL
102779 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
102780 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
102781 +inode_permission_57531 inode_permission 0 57531 NULL
102782 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
102783 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
102784 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
102785 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
102786 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
102787 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
102788 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
102789 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
102790 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
102791 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
102792 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
102793 +mem_read_57631 mem_read 3 57631 NULL
102794 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
102795 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
102796 +r3964_write_57662 r3964_write 4 57662 NULL
102797 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
102798 +__lgwrite_57669 __lgwrite 4 57669 NULL
102799 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
102800 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
102801 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
102802 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
102803 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
102804 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
102805 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
102806 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
102807 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
102808 +ld2_57794 ld2 0 57794 NULL
102809 +ivtv_read_57796 ivtv_read 3 57796 NULL
102810 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
102811 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
102812 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
102813 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
102814 +copy_to_user_57835 copy_to_user 3 57835 NULL
102815 +flash_read_57843 flash_read 3 57843 NULL
102816 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
102817 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
102818 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
102819 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
102820 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
102821 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
102822 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
102823 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
102824 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
102825 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
102826 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
102827 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
102828 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
102829 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
102830 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
102831 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
102832 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
102833 +mce_async_out_58056 mce_async_out 3 58056 NULL
102834 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
102835 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
102836 +cm4040_write_58079 cm4040_write 3 58079 NULL
102837 +udi_log_event_58105 udi_log_event 3 58105 NULL
102838 +savemem_58129 savemem 3 58129 NULL
102839 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
102840 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
102841 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
102842 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
102843 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
102844 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
102845 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
102846 +read_file_debug_58256 read_file_debug 3 58256 NULL
102847 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
102848 +profile_load_58267 profile_load 3 58267 NULL
102849 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
102850 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
102851 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
102852 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
102853 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
102854 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
102855 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
102856 +next_pidmap_58347 next_pidmap 2 58347 NULL
102857 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
102858 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
102859 +save_hint_58359 save_hint 2 58359 NULL
102860 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
102861 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
102862 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
102863 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
102864 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
102865 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
102866 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
102867 +capabilities_read_58457 capabilities_read 3 58457 NULL
102868 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
102869 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
102870 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
102871 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
102872 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
102873 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
102874 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
102875 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
102876 +__clear_discard_58546 __clear_discard 2 58546 NULL
102877 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
102878 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
102879 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
102880 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
102881 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
102882 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
102883 +xip_file_read_58592 xip_file_read 3 58592 NULL
102884 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
102885 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
102886 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
102887 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
102888 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
102889 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
102890 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
102891 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
102892 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
102893 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
102894 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
102895 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
102896 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
102897 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
102898 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
102899 +acpi_map_58725 acpi_map 1-2 58725 NULL
102900 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
102901 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
102902 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
102903 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
102904 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
102905 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
102906 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
102907 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
102908 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
102909 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
102910 +ep_read_58813 ep_read 3 58813 NULL
102911 +command_write_58841 command_write 3 58841 NULL
102912 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
102913 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
102914 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
102915 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
102916 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
102917 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
102918 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
102919 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
102920 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
102921 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
102922 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
102923 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
102924 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
102925 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
102926 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
102927 +ep_write_59008 ep_write 3 59008 NULL
102928 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
102929 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
102930 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
102931 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
102932 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
102933 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
102934 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
102935 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
102936 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
102937 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
102938 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
102939 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
102940 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
102941 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
102942 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
102943 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
102944 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
102945 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
102946 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
102947 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
102948 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
102949 +dt3155_read_59226 dt3155_read 3 59226 NULL
102950 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
102951 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
102952 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
102953 +nla_len_59258 nla_len 0 59258 NULL
102954 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
102955 +fd_copyout_59323 fd_copyout 3 59323 NULL
102956 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
102957 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
102958 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
102959 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
102960 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
102961 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
102962 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
102963 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
102964 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
102965 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
102966 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
102967 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
102968 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
102969 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
102970 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
102971 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
102972 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
102973 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
102974 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
102975 +tunables_write_59563 tunables_write 3 59563 NULL
102976 +memdup_user_59590 memdup_user 2 59590 NULL
102977 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
102978 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
102979 +mtrr_write_59622 mtrr_write 3 59622 NULL
102980 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
102981 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
102982 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
102983 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
102984 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
102985 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
102986 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
102987 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
102988 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
102989 +sriov_enable_59689 sriov_enable 2 59689 NULL
102990 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
102991 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
102992 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
102993 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
102994 +strnlen_59746 strnlen 0 59746 NULL
102995 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
102996 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
102997 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
102998 +venus_remove_59781 venus_remove 4 59781 NULL
102999 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
103000 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
103001 +ipw_write_59807 ipw_write 3 59807 NULL
103002 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
103003 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
103004 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
103005 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
103006 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
103007 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
103008 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
103009 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
103010 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
103011 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
103012 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
103013 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
103014 +lookup_node_59953 lookup_node 2 59953 NULL
103015 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
103016 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
103017 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
103018 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
103019 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
103020 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
103021 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
103022 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
103023 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
103024 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
103025 +register_device_60015 register_device 2-3 60015 NULL
103026 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
103027 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
103028 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
103029 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
103030 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
103031 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
103032 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
103033 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
103034 +compat_writev_60063 compat_writev 3 60063 NULL
103035 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
103036 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
103037 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
103038 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
103039 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
103040 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
103041 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
103042 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
103043 +init_state_60165 init_state 2 60165 NULL
103044 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
103045 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
103046 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
103047 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
103048 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
103049 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
103050 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
103051 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
103052 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
103053 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
103054 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
103055 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
103056 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
103057 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
103058 +printer_write_60276 printer_write 3 60276 NULL
103059 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
103060 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
103061 +getDataLength_60301 getDataLength 0 60301 NULL
103062 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
103063 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
103064 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
103065 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
103066 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
103067 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
103068 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
103069 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
103070 +driver_names_read_60399 driver_names_read 3 60399 NULL
103071 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
103072 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
103073 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
103074 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
103075 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
103076 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
103077 +rx_data_60442 rx_data 4 60442 NULL nohasharray
103078 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
103079 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
103080 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
103081 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
103082 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
103083 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
103084 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
103085 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
103086 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
103087 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
103088 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
103089 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
103090 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
103091 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
103092 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
103093 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
103094 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
103095 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
103096 +init_data_container_60709 init_data_container 1 60709 NULL
103097 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
103098 +raid_status_60755 raid_status 5 60755 NULL
103099 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
103100 +opticon_write_60775 opticon_write 4 60775 NULL
103101 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
103102 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
103103 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
103104 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
103105 +generic_writepages_60871 generic_writepages 0 60871 NULL
103106 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
103107 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
103108 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
103109 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
103110 +sys_mlock_60932 sys_mlock 1 60932 NULL
103111 +pti_char_write_60960 pti_char_write 3 60960 NULL
103112 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
103113 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
103114 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
103115 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
103116 +symtab_init_61050 symtab_init 2 61050 NULL
103117 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
103118 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
103119 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
103120 +get_derived_key_61100 get_derived_key 4 61100 NULL
103121 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
103122 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
103123 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
103124 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
103125 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
103126 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
103127 +__vmalloc_61168 __vmalloc 1 61168 NULL
103128 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
103129 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
103130 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
103131 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
103132 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
103133 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
103134 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
103135 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
103136 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
103137 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
103138 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
103139 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
103140 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
103141 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
103142 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
103143 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
103144 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
103145 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
103146 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
103147 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
103148 +change_xattr_61390 change_xattr 5 61390 NULL
103149 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
103150 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
103151 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
103152 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
103153 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
103154 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
103155 +erst_errno_61526 erst_errno 0 61526 NULL
103156 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
103157 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
103158 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
103159 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
103160 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
103161 +seq_open_private_61589 seq_open_private 3 61589 NULL
103162 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
103163 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
103164 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
103165 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
103166 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
103167 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
103168 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
103169 +resize_stripes_61650 resize_stripes 2 61650 NULL
103170 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
103171 +insert_one_name_61668 insert_one_name 7 61668 NULL
103172 +lock_loop_61681 lock_loop 1 61681 NULL
103173 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
103174 +filter_read_61692 filter_read 3 61692 NULL
103175 +iov_length_61716 iov_length 0 61716 NULL
103176 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
103177 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
103178 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
103179 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
103180 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
103181 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
103182 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
103183 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
103184 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
103185 +get_fw_name_61874 get_fw_name 3 61874 NULL
103186 +free_init_pages_61875 free_init_pages 2 61875 NULL
103187 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
103188 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
103189 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
103190 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
103191 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
103192 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
103193 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
103194 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
103195 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
103196 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
103197 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
103198 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
103199 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
103200 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
103201 +cow_file_range_61979 cow_file_range 3 61979 NULL
103202 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
103203 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
103204 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
103205 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
103206 +SYSC_select_62024 SYSC_select 1 62024 NULL
103207 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
103208 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
103209 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
103210 +do_pselect_62061 do_pselect 1 62061 NULL
103211 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
103212 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
103213 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
103214 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
103215 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
103216 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
103217 +ql_status_62135 ql_status 5 62135 NULL
103218 +video_usercopy_62151 video_usercopy 2 62151 NULL
103219 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
103220 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
103221 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
103222 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
103223 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
103224 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
103225 +allocate_partition_62245 allocate_partition 4 62245 NULL
103226 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
103227 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
103228 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
103229 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
103230 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
103231 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
103232 +subseq_list_62332 subseq_list 3-0 62332 NULL
103233 +flash_write_62354 flash_write 3 62354 NULL
103234 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
103235 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
103236 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
103237 +altera_irscan_62396 altera_irscan 2 62396 NULL
103238 +set_ssp_62411 set_ssp 4 62411 NULL
103239 +unmap_single_62423 unmap_single 2 62423 NULL
103240 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
103241 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
103242 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
103243 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
103244 +remove_mapping_62491 remove_mapping 2 62491 NULL
103245 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
103246 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
103247 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
103248 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
103249 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
103250 +debugfs_read_62535 debugfs_read 3 62535 NULL
103251 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
103252 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
103253 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
103254 +get_subdir_62581 get_subdir 3 62581 NULL
103255 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
103256 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
103257 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
103258 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
103259 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
103260 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
103261 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
103262 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
103263 +write_62671 write 3 62671 NULL
103264 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
103265 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
103266 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
103267 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
103268 +rdm_62719 rdm 0 62719 NULL
103269 +key_replays_read_62746 key_replays_read 3 62746 NULL
103270 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
103271 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
103272 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
103273 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
103274 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
103275 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
103276 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
103277 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
103278 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
103279 +set_swbp_62853 set_swbp 3 62853 NULL
103280 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
103281 +aoechr_write_62883 aoechr_write 3 62883 NULL
103282 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
103283 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
103284 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
103285 +getdqbuf_62908 getdqbuf 1 62908 NULL
103286 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
103287 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
103288 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
103289 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
103290 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
103291 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
103292 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
103293 +unlink1_63059 unlink1 3 63059 NULL
103294 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
103295 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
103296 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
103297 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
103298 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
103299 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
103300 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
103301 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
103302 +vme_master_read_63221 vme_master_read 0 63221 NULL
103303 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
103304 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
103305 +ptp_read_63251 ptp_read 4 63251 NULL
103306 +raid5_resize_63306 raid5_resize 2 63306 NULL
103307 +proc_info_read_63344 proc_info_read 3 63344 NULL
103308 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
103309 +idmouse_read_63374 idmouse_read 3 63374 NULL
103310 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
103311 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
103312 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
103313 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
103314 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
103315 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
103316 +kone_send_63435 kone_send 4 63435 NULL
103317 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
103318 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
103319 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
103320 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
103321 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
103322 +read_kcore_63488 read_kcore 3 63488 NULL
103323 +save_hint_63497 save_hint 2 63497 NULL
103324 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
103325 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
103326 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
103327 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
103328 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
103329 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
103330 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
103331 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
103332 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
103333 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
103334 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
103335 +module_alloc_63630 module_alloc 1 63630 NULL
103336 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
103337 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
103338 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
103339 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
103340 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
103341 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
103342 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
103343 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
103344 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
103345 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
103346 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
103347 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
103348 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
103349 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
103350 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
103351 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
103352 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
103353 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
103354 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
103355 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
103356 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
103357 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
103358 +prepare_copy_63826 prepare_copy 2 63826 NULL
103359 +sel_write_load_63830 sel_write_load 3 63830 NULL
103360 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
103361 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
103362 +divas_write_63901 divas_write 3 63901 NULL
103363 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
103364 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
103365 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
103366 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
103367 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
103368 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
103369 +__team_options_register_63941 __team_options_register 3 63941 NULL
103370 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
103371 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
103372 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
103373 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
103374 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
103375 +kmemdup_64015 kmemdup 2 64015 NULL
103376 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
103377 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
103378 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
103379 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
103380 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
103381 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
103382 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
103383 +get_u8_64076 get_u8 0 64076 NULL
103384 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
103385 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
103386 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
103387 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
103388 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
103389 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
103390 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
103391 +init_bch_64130 init_bch 1-2 64130 NULL
103392 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
103393 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
103394 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
103395 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
103396 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
103397 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
103398 +read_pulse_64227 read_pulse 0-3 64227 NULL
103399 +header_len_64232 header_len 0 64232 NULL
103400 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
103401 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
103402 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
103403 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
103404 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
103405 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
103406 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
103407 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
103408 +ffz_64324 ffz 0 64324 NULL
103409 +map_region_64328 map_region 1 64328 NULL
103410 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
103411 +ts_write_64336 ts_write 3 64336 NULL
103412 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
103413 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
103414 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
103415 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
103416 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
103417 +ilo_write_64378 ilo_write 3 64378 NULL
103418 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
103419 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
103420 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
103421 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
103422 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
103423 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
103424 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
103425 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
103426 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
103427 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
103428 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
103429 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
103430 +cap_capable_64462 cap_capable 0 64462 NULL
103431 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
103432 +single_open_size_64483 single_open_size 4 64483 NULL
103433 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
103434 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
103435 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
103436 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
103437 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
103438 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
103439 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
103440 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
103441 +SyS_bind_64544 SyS_bind 3 64544 NULL
103442 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
103443 +__spi_sync_64561 __spi_sync 0 64561 NULL
103444 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
103445 +fanotify_write_64623 fanotify_write 3 64623 NULL
103446 +to_dblock_64655 to_dblock 0-1 64655 NULL
103447 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
103448 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
103449 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
103450 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
103451 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
103452 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
103453 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
103454 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
103455 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
103456 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
103457 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
103458 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
103459 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
103460 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
103461 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
103462 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
103463 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
103464 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
103465 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
103466 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
103467 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
103468 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
103469 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
103470 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
103471 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
103472 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
103473 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
103474 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
103475 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
103476 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
103477 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
103478 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
103479 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
103480 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
103481 +pskb_pull_65005 pskb_pull 2 65005 NULL
103482 +unifi_write_65012 unifi_write 3 65012 NULL
103483 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
103484 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
103485 +insert_dent_65034 insert_dent 7 65034 NULL
103486 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
103487 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
103488 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
103489 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
103490 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
103491 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
103492 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
103493 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
103494 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
103495 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
103496 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
103497 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
103498 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
103499 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
103500 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
103501 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
103502 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
103503 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
103504 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
103505 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
103506 +get_var_len_65304 get_var_len 0 65304 NULL
103507 +unpack_array_65318 unpack_array 0 65318 NULL
103508 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
103509 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
103510 +init_list_set_65351 init_list_set 2-3 65351 NULL
103511 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
103512 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
103513 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
103514 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
103515 +strchr_65372 strchr 0 65372 NULL nohasharray
103516 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
103517 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
103518 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
103519 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
103520 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
103521 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
103522 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
103523 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
103524 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
103525 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
103526 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
103527 +alloc_dr_65495 alloc_dr 2 65495 NULL
103528 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
103529 new file mode 100644
103530 index 0000000..9db0d0e
103531 --- /dev/null
103532 +++ b/tools/gcc/size_overflow_plugin.c
103533 @@ -0,0 +1,2114 @@
103534 +/*
103535 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
103536 + * Licensed under the GPL v2, or (at your option) v3
103537 + *
103538 + * Homepage:
103539 + * http://www.grsecurity.net/~ephox/overflow_plugin/
103540 + *
103541 + * Documentation:
103542 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
103543 + *
103544 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
103545 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
103546 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
103547 + *
103548 + * Usage:
103549 + * $ 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
103550 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
103551 + */
103552 +
103553 +#include "gcc-plugin.h"
103554 +#include "config.h"
103555 +#include "system.h"
103556 +#include "coretypes.h"
103557 +#include "tree.h"
103558 +#include "tree-pass.h"
103559 +#include "intl.h"
103560 +#include "plugin-version.h"
103561 +#include "tm.h"
103562 +#include "toplev.h"
103563 +#include "function.h"
103564 +#include "tree-flow.h"
103565 +#include "plugin.h"
103566 +#include "gimple.h"
103567 +#include "diagnostic.h"
103568 +#include "cfgloop.h"
103569 +
103570 +#if BUILDING_GCC_VERSION >= 4008
103571 +#define TODO_dump_func 0
103572 +#endif
103573 +
103574 +struct size_overflow_hash {
103575 + const struct size_overflow_hash * const next;
103576 + const char * const name;
103577 + const unsigned int param;
103578 +};
103579 +
103580 +#include "size_overflow_hash.h"
103581 +
103582 +enum mark {
103583 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
103584 +};
103585 +
103586 +enum err_code_conditions {
103587 + CAST_ONLY, FROM_CONST
103588 +};
103589 +
103590 +static unsigned int call_count = 0;
103591 +
103592 +#define __unused __attribute__((__unused__))
103593 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103594 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
103595 +#define BEFORE_STMT true
103596 +#define AFTER_STMT false
103597 +#define CREATE_NEW_VAR NULL_TREE
103598 +#define CODES_LIMIT 32
103599 +#define MAX_PARAM 31
103600 +#define MY_STMT GF_PLF_1
103601 +#define NO_CAST_CHECK GF_PLF_2
103602 +#define FROM_ARG true
103603 +#define FROM_RET false
103604 +
103605 +#if BUILDING_GCC_VERSION == 4005
103606 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
103607 +#endif
103608 +
103609 +int plugin_is_GPL_compatible;
103610 +void debug_gimple_stmt(gimple gs);
103611 +
103612 +static tree expand(struct pointer_set_t *visited, tree lhs);
103613 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
103614 +static tree report_size_overflow_decl;
103615 +static const_tree const_char_ptr_type_node;
103616 +static unsigned int handle_function(void);
103617 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
103618 +static tree get_size_overflow_type(gimple stmt, const_tree node);
103619 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
103620 +static void print_missing_msg(tree func, unsigned int argnum);
103621 +
103622 +static struct plugin_info size_overflow_plugin_info = {
103623 + .version = "20130410beta",
103624 + .help = "no-size-overflow\tturn off size overflow checking\n",
103625 +};
103626 +
103627 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
103628 +{
103629 + unsigned int arg_count;
103630 + enum tree_code code = TREE_CODE(*node);
103631 +
103632 + switch (code) {
103633 + case FUNCTION_DECL:
103634 + arg_count = type_num_arguments(TREE_TYPE(*node));
103635 + break;
103636 + case FUNCTION_TYPE:
103637 + case METHOD_TYPE:
103638 + arg_count = type_num_arguments(*node);
103639 + break;
103640 + default:
103641 + *no_add_attrs = true;
103642 + error("%s: %qE attribute only applies to functions", __func__, name);
103643 + return NULL_TREE;
103644 + }
103645 +
103646 + for (; args; args = TREE_CHAIN(args)) {
103647 + tree position = TREE_VALUE(args);
103648 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
103649 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
103650 + *no_add_attrs = true;
103651 + }
103652 + }
103653 + return NULL_TREE;
103654 +}
103655 +
103656 +static const char* get_asm_name(tree node)
103657 +{
103658 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
103659 +}
103660 +
103661 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
103662 +{
103663 + unsigned int arg_count, arg_num;
103664 + enum tree_code code = TREE_CODE(*node);
103665 +
103666 + switch (code) {
103667 + case FUNCTION_DECL:
103668 + arg_count = type_num_arguments(TREE_TYPE(*node));
103669 + break;
103670 + case FUNCTION_TYPE:
103671 + case METHOD_TYPE:
103672 + arg_count = type_num_arguments(*node);
103673 + break;
103674 + case FIELD_DECL:
103675 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
103676 + if (arg_num != 0) {
103677 + *no_add_attrs = true;
103678 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
103679 + }
103680 + return NULL_TREE;
103681 + default:
103682 + *no_add_attrs = true;
103683 + error("%qE attribute only applies to functions", name);
103684 + return NULL_TREE;
103685 + }
103686 +
103687 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
103688 + return NULL_TREE;
103689 +
103690 + for (; args; args = TREE_CHAIN(args)) {
103691 + tree position = TREE_VALUE(args);
103692 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
103693 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
103694 + *no_add_attrs = true;
103695 + }
103696 + }
103697 + return NULL_TREE;
103698 +}
103699 +
103700 +static struct attribute_spec size_overflow_attr = {
103701 + .name = "size_overflow",
103702 + .min_length = 1,
103703 + .max_length = -1,
103704 + .decl_required = true,
103705 + .type_required = false,
103706 + .function_type_required = false,
103707 + .handler = handle_size_overflow_attribute,
103708 +#if BUILDING_GCC_VERSION >= 4007
103709 + .affects_type_identity = false
103710 +#endif
103711 +};
103712 +
103713 +static struct attribute_spec intentional_overflow_attr = {
103714 + .name = "intentional_overflow",
103715 + .min_length = 1,
103716 + .max_length = -1,
103717 + .decl_required = true,
103718 + .type_required = false,
103719 + .function_type_required = false,
103720 + .handler = handle_intentional_overflow_attribute,
103721 +#if BUILDING_GCC_VERSION >= 4007
103722 + .affects_type_identity = false
103723 +#endif
103724 +};
103725 +
103726 +static void register_attributes(void __unused *event_data, void __unused *data)
103727 +{
103728 + register_attribute(&size_overflow_attr);
103729 + register_attribute(&intentional_overflow_attr);
103730 +}
103731 +
103732 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
103733 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
103734 +{
103735 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
103736 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
103737 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
103738 +
103739 + unsigned int m = 0x57559429;
103740 + unsigned int n = 0x5052acdb;
103741 + const unsigned int *key4 = (const unsigned int *)key;
103742 + unsigned int h = len;
103743 + unsigned int k = len + seed + n;
103744 + unsigned long long p;
103745 +
103746 + while (len >= 8) {
103747 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
103748 + len -= 8;
103749 + }
103750 + if (len >= 4) {
103751 + cwmixb(key4[0]) key4 += 1;
103752 + len -= 4;
103753 + }
103754 + if (len)
103755 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
103756 + cwmixb(h ^ (k + n));
103757 + return k ^ h;
103758 +
103759 +#undef cwfold
103760 +#undef cwmixa
103761 +#undef cwmixb
103762 +}
103763 +
103764 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
103765 +{
103766 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
103767 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
103768 + return fn ^ codes;
103769 +}
103770 +
103771 +static inline tree get_original_function_decl(tree fndecl)
103772 +{
103773 + if (DECL_ABSTRACT_ORIGIN(fndecl))
103774 + return DECL_ABSTRACT_ORIGIN(fndecl);
103775 + return fndecl;
103776 +}
103777 +
103778 +static inline gimple get_def_stmt(const_tree node)
103779 +{
103780 + gcc_assert(node != NULL_TREE);
103781 + if (TREE_CODE(node) != SSA_NAME)
103782 + return NULL;
103783 + return SSA_NAME_DEF_STMT(node);
103784 +}
103785 +
103786 +static unsigned char get_tree_code(const_tree type)
103787 +{
103788 + switch (TREE_CODE(type)) {
103789 + case ARRAY_TYPE:
103790 + return 0;
103791 + case BOOLEAN_TYPE:
103792 + return 1;
103793 + case ENUMERAL_TYPE:
103794 + return 2;
103795 + case FUNCTION_TYPE:
103796 + return 3;
103797 + case INTEGER_TYPE:
103798 + return 4;
103799 + case POINTER_TYPE:
103800 + return 5;
103801 + case RECORD_TYPE:
103802 + return 6;
103803 + case UNION_TYPE:
103804 + return 7;
103805 + case VOID_TYPE:
103806 + return 8;
103807 + case REAL_TYPE:
103808 + return 9;
103809 + case VECTOR_TYPE:
103810 + return 10;
103811 + case REFERENCE_TYPE:
103812 + return 11;
103813 + case OFFSET_TYPE:
103814 + return 12;
103815 + case COMPLEX_TYPE:
103816 + return 13;
103817 + default:
103818 + debug_tree((tree)type);
103819 + gcc_unreachable();
103820 + }
103821 +}
103822 +
103823 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
103824 +{
103825 + gcc_assert(type != NULL_TREE);
103826 +
103827 + while (type && len < CODES_LIMIT) {
103828 + tree_codes[len] = get_tree_code(type);
103829 + len++;
103830 + type = TREE_TYPE(type);
103831 + }
103832 + return len;
103833 +}
103834 +
103835 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
103836 +{
103837 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
103838 + enum tree_code code = TREE_CODE(type);
103839 + size_t len = 0;
103840 +
103841 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
103842 +
103843 + arg = TYPE_ARG_TYPES(type);
103844 + // skip builtins __builtin_constant_p
103845 + if (!arg && DECL_BUILT_IN(fndecl))
103846 + return 0;
103847 +
103848 + if (TREE_CODE_CLASS(code) == tcc_type)
103849 + result = type;
103850 + else
103851 + result = DECL_RESULT(fndecl);
103852 +
103853 + gcc_assert(result != NULL_TREE);
103854 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
103855 +
103856 + if (arg == NULL_TREE) {
103857 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
103858 + arg_field = DECL_ARGUMENT_FLD(fndecl);
103859 + if (arg_field == NULL_TREE)
103860 + return 0;
103861 + arg = TREE_TYPE(arg_field);
103862 + len = add_type_codes(arg, tree_codes, len);
103863 + gcc_assert(len != 0);
103864 + return len;
103865 + }
103866 +
103867 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
103868 + while (arg && len < CODES_LIMIT) {
103869 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
103870 + arg = TREE_CHAIN(arg);
103871 + }
103872 +
103873 + gcc_assert(len != 0);
103874 + return len;
103875 +}
103876 +
103877 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
103878 +{
103879 + unsigned int hash;
103880 + const struct size_overflow_hash *entry;
103881 + unsigned char tree_codes[CODES_LIMIT];
103882 + size_t len;
103883 + const char *func_name;
103884 +
103885 + fndecl = get_original_function_decl(fndecl);
103886 + len = get_function_decl(fndecl, tree_codes);
103887 + if (len == 0)
103888 + return NULL;
103889 +
103890 + func_name = get_asm_name(fndecl);
103891 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
103892 +
103893 + entry = size_overflow_hash[hash];
103894 + while (entry) {
103895 + if (!strcmp(entry->name, func_name))
103896 + return entry;
103897 + entry = entry->next;
103898 + }
103899 +
103900 + return NULL;
103901 +}
103902 +
103903 +static bool is_bool(const_tree node)
103904 +{
103905 + const_tree type;
103906 +
103907 + if (node == NULL_TREE)
103908 + return false;
103909 +
103910 + type = TREE_TYPE(node);
103911 + if (!INTEGRAL_TYPE_P(type))
103912 + return false;
103913 + if (TREE_CODE(type) == BOOLEAN_TYPE)
103914 + return true;
103915 + if (TYPE_PRECISION(type) == 1)
103916 + return true;
103917 + return false;
103918 +}
103919 +
103920 +static bool skip_types(const_tree var)
103921 +{
103922 + tree type;
103923 +
103924 + if (is_gimple_constant(var))
103925 + return true;
103926 +
103927 + switch (TREE_CODE(var)) {
103928 + case ADDR_EXPR:
103929 +#if BUILDING_GCC_VERSION >= 4006
103930 + case MEM_REF:
103931 +#endif
103932 + case ARRAY_REF:
103933 + case BIT_FIELD_REF:
103934 + case INDIRECT_REF:
103935 + case TARGET_MEM_REF:
103936 + return true;
103937 + case PARM_DECL:
103938 + case VAR_DECL:
103939 + case COMPONENT_REF:
103940 + return false;
103941 + default:
103942 + break;
103943 + }
103944 +
103945 + gcc_assert(TREE_CODE(var) == SSA_NAME);
103946 +
103947 + type = TREE_TYPE(var);
103948 + switch (TREE_CODE(type)) {
103949 + case INTEGER_TYPE:
103950 + case ENUMERAL_TYPE:
103951 + return false;
103952 + case BOOLEAN_TYPE:
103953 + return is_bool(var);
103954 + default:
103955 + break;
103956 + }
103957 +
103958 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
103959 +
103960 + type = TREE_TYPE(type);
103961 + gcc_assert(type != NULL_TREE);
103962 + switch (TREE_CODE(type)) {
103963 + case RECORD_TYPE:
103964 + case POINTER_TYPE:
103965 + case ARRAY_TYPE:
103966 + return true;
103967 + case VOID_TYPE:
103968 + case INTEGER_TYPE:
103969 + case UNION_TYPE:
103970 + return false;
103971 + default:
103972 + break;
103973 + }
103974 +
103975 + debug_tree((tree)var);
103976 + gcc_unreachable();
103977 +}
103978 +
103979 +static unsigned int find_arg_number(const_tree arg, tree func)
103980 +{
103981 + tree var;
103982 + unsigned int argnum = 1;
103983 +
103984 + if (TREE_CODE(arg) == SSA_NAME)
103985 + arg = SSA_NAME_VAR(arg);
103986 +
103987 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
103988 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
103989 + continue;
103990 + if (!skip_types(var))
103991 + return argnum;
103992 + }
103993 +
103994 + return 0;
103995 +}
103996 +
103997 +static tree create_new_var(tree type)
103998 +{
103999 + tree new_var = create_tmp_var(type, "cicus");
104000 +
104001 +#if BUILDING_GCC_VERSION <= 4007
104002 + add_referenced_var(new_var);
104003 + mark_sym_for_renaming(new_var);
104004 +#endif
104005 + return new_var;
104006 +}
104007 +
104008 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
104009 +{
104010 + gimple assign;
104011 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
104012 + tree type = TREE_TYPE(rhs1);
104013 + tree lhs = create_new_var(type);
104014 +
104015 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
104016 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
104017 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
104018 +
104019 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
104020 + update_stmt(assign);
104021 + gimple_set_plf(assign, MY_STMT, true);
104022 + return assign;
104023 +}
104024 +
104025 +static tree cast_a_tree(tree type, tree var)
104026 +{
104027 + gcc_assert(type != NULL_TREE);
104028 + gcc_assert(var != NULL_TREE);
104029 + gcc_assert(fold_convertible_p(type, var));
104030 +
104031 + return fold_convert(type, var);
104032 +}
104033 +
104034 +static tree get_lhs(const_gimple stmt)
104035 +{
104036 + switch (gimple_code(stmt)) {
104037 + case GIMPLE_ASSIGN:
104038 + return gimple_get_lhs(stmt);
104039 + case GIMPLE_PHI:
104040 + return gimple_phi_result(stmt);
104041 + case GIMPLE_CALL:
104042 + return gimple_call_lhs(stmt);
104043 + default:
104044 + return NULL_TREE;
104045 + }
104046 +}
104047 +
104048 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
104049 +{
104050 + const_gimple def_stmt = get_def_stmt(rhs);
104051 +
104052 + if (force)
104053 + return false;
104054 +
104055 + if (is_gimple_constant(rhs))
104056 + return false;
104057 +
104058 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
104059 + return false;
104060 +
104061 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
104062 + return false;
104063 +
104064 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
104065 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
104066 + return false;
104067 +
104068 + return true;
104069 +}
104070 +
104071 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
104072 +{
104073 + gimple assign, def_stmt;
104074 +
104075 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
104076 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
104077 + gcc_unreachable();
104078 +
104079 + def_stmt = get_def_stmt(rhs);
104080 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
104081 + return def_stmt;
104082 +
104083 + if (lhs == CREATE_NEW_VAR)
104084 + lhs = create_new_var(dst_type);
104085 +
104086 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
104087 +
104088 + if (!gsi_end_p(*gsi)) {
104089 + location_t loc = gimple_location(gsi_stmt(*gsi));
104090 + gimple_set_location(assign, loc);
104091 + }
104092 +
104093 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
104094 +
104095 + if (before)
104096 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
104097 + else
104098 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
104099 + update_stmt(assign);
104100 + gimple_set_plf(assign, MY_STMT, true);
104101 +
104102 + return assign;
104103 +}
104104 +
104105 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
104106 +{
104107 + gimple_stmt_iterator gsi;
104108 + tree lhs;
104109 + const_gimple new_stmt;
104110 +
104111 + if (rhs == NULL_TREE)
104112 + return NULL_TREE;
104113 +
104114 + gsi = gsi_for_stmt(stmt);
104115 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
104116 +
104117 + lhs = get_lhs(new_stmt);
104118 + gcc_assert(lhs != NULL_TREE);
104119 + return lhs;
104120 +}
104121 +
104122 +static tree cast_to_TI_type(gimple stmt, tree node)
104123 +{
104124 + gimple_stmt_iterator gsi;
104125 + gimple cast_stmt;
104126 + tree type = TREE_TYPE(node);
104127 +
104128 + if (types_compatible_p(type, intTI_type_node))
104129 + return node;
104130 +
104131 + gsi = gsi_for_stmt(stmt);
104132 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
104133 + return gimple_get_lhs(cast_stmt);
104134 +}
104135 +
104136 +static void check_function_hash(const_gimple stmt)
104137 +{
104138 + tree func;
104139 + const struct size_overflow_hash *hash;
104140 +
104141 + if (gimple_code(stmt) != GIMPLE_CALL)
104142 + return;
104143 +
104144 + func = gimple_call_fndecl(stmt);
104145 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
104146 + if (func == NULL_TREE)
104147 + return;
104148 +
104149 + hash = get_function_hash(func);
104150 + if (!hash)
104151 + print_missing_msg(func, 0);
104152 +}
104153 +
104154 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
104155 +{
104156 + tree lhs, new_lhs;
104157 + gimple_stmt_iterator gsi;
104158 +
104159 + if (rhs1 == NULL_TREE) {
104160 + debug_gimple_stmt(oldstmt);
104161 + error("%s: rhs1 is NULL_TREE", __func__);
104162 + gcc_unreachable();
104163 + }
104164 +
104165 + switch (gimple_code(oldstmt)) {
104166 + case GIMPLE_ASM:
104167 + lhs = rhs1;
104168 + break;
104169 + case GIMPLE_CALL:
104170 + lhs = gimple_call_lhs(oldstmt);
104171 + break;
104172 + case GIMPLE_ASSIGN:
104173 + lhs = gimple_get_lhs(oldstmt);
104174 + break;
104175 + default:
104176 + debug_gimple_stmt(oldstmt);
104177 + gcc_unreachable();
104178 + }
104179 +
104180 + gsi = gsi_for_stmt(oldstmt);
104181 + pointer_set_insert(visited, oldstmt);
104182 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
104183 + basic_block next_bb, cur_bb;
104184 + const_edge e;
104185 +
104186 + gcc_assert(before == false);
104187 + gcc_assert(stmt_can_throw_internal(oldstmt));
104188 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
104189 + gcc_assert(!gsi_end_p(gsi));
104190 +
104191 + cur_bb = gimple_bb(oldstmt);
104192 + next_bb = cur_bb->next_bb;
104193 + e = find_edge(cur_bb, next_bb);
104194 + gcc_assert(e != NULL);
104195 + gcc_assert(e->flags & EDGE_FALLTHRU);
104196 +
104197 + gsi = gsi_after_labels(next_bb);
104198 + gcc_assert(!gsi_end_p(gsi));
104199 +
104200 + before = true;
104201 + oldstmt = gsi_stmt(gsi);
104202 + }
104203 +
104204 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
104205 + return new_lhs;
104206 +}
104207 +
104208 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
104209 +{
104210 + gimple stmt;
104211 + gimple_stmt_iterator gsi;
104212 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
104213 +
104214 + if (gimple_plf(oldstmt, MY_STMT))
104215 + return lhs;
104216 +
104217 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
104218 + rhs1 = gimple_assign_rhs1(oldstmt);
104219 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
104220 + }
104221 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
104222 + rhs2 = gimple_assign_rhs2(oldstmt);
104223 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
104224 + }
104225 +
104226 + stmt = gimple_copy(oldstmt);
104227 + gimple_set_location(stmt, gimple_location(oldstmt));
104228 + gimple_set_plf(stmt, MY_STMT, true);
104229 +
104230 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
104231 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
104232 +
104233 + size_overflow_type = get_size_overflow_type(oldstmt, node);
104234 +
104235 + new_var = create_new_var(size_overflow_type);
104236 + new_var = make_ssa_name(new_var, stmt);
104237 + gimple_set_lhs(stmt, new_var);
104238 +
104239 + if (rhs1 != NULL_TREE)
104240 + gimple_assign_set_rhs1(stmt, rhs1);
104241 +
104242 + if (rhs2 != NULL_TREE)
104243 + gimple_assign_set_rhs2(stmt, rhs2);
104244 +#if BUILDING_GCC_VERSION >= 4007
104245 + if (rhs3 != NULL_TREE)
104246 + gimple_assign_set_rhs3(stmt, rhs3);
104247 +#endif
104248 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
104249 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
104250 +
104251 + gsi = gsi_for_stmt(oldstmt);
104252 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
104253 + update_stmt(stmt);
104254 + pointer_set_insert(visited, oldstmt);
104255 + return gimple_get_lhs(stmt);
104256 +}
104257 +
104258 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
104259 +{
104260 + basic_block first_bb;
104261 + gimple assign;
104262 + gimple_stmt_iterator gsi;
104263 +
104264 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104265 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
104266 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
104267 +
104268 + gsi = gsi_start_bb(first_bb);
104269 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
104270 + return gimple_get_lhs(assign);
104271 +}
104272 +
104273 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
104274 +{
104275 + gimple_stmt_iterator gsi;
104276 + const_gimple assign;
104277 + gimple def_stmt = get_def_stmt(new_arg);
104278 +
104279 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
104280 + gsi = gsi_after_labels(gimple_bb(def_stmt));
104281 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
104282 + } else {
104283 + gsi = gsi_for_stmt(def_stmt);
104284 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
104285 + }
104286 +
104287 + return gimple_get_lhs(assign);
104288 +}
104289 +
104290 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
104291 +{
104292 + basic_block bb;
104293 + gimple_stmt_iterator gsi;
104294 + const_gimple assign, def_stmt;
104295 +
104296 + def_stmt = get_def_stmt(arg);
104297 + bb = gimple_bb(def_stmt);
104298 + gcc_assert(bb->index != 0);
104299 + gsi = gsi_after_labels(bb);
104300 +
104301 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
104302 + return gimple_get_lhs(assign);
104303 +}
104304 +
104305 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
104306 +{
104307 + tree size_overflow_type;
104308 + const_gimple def_stmt = get_def_stmt(arg);
104309 +
104310 + if (phi_ssa_name != NULL_TREE)
104311 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
104312 +
104313 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
104314 +
104315 + if (new_arg != NULL_TREE) {
104316 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
104317 + return use_phi_ssa_name(phi_ssa_name, new_arg);
104318 + }
104319 +
104320 + switch(gimple_code(def_stmt)) {
104321 + case GIMPLE_PHI:
104322 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
104323 + case GIMPLE_NOP:
104324 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
104325 + default:
104326 + debug_gimple_stmt((gimple)def_stmt);
104327 + gcc_unreachable();
104328 + }
104329 +}
104330 +
104331 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
104332 +{
104333 + basic_block bb;
104334 + gimple phi;
104335 + gimple_seq seq;
104336 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
104337 +
104338 + bb = gsi_bb(gsi);
104339 +
104340 + phi = create_phi_node(result, bb);
104341 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
104342 + seq = phi_nodes(bb);
104343 + gsi = gsi_last(seq);
104344 + gsi_remove(&gsi, false);
104345 +
104346 + gsi = gsi_for_stmt(oldstmt);
104347 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
104348 + gimple_set_bb(phi, bb);
104349 + gimple_set_plf(phi, MY_STMT, true);
104350 + return phi;
104351 +}
104352 +
104353 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
104354 +{
104355 + gimple new_phi = NULL;
104356 + gimple oldstmt = get_def_stmt(orig_result);
104357 + tree phi_ssa_name = NULL_TREE;
104358 + unsigned int i;
104359 +
104360 + pointer_set_insert(visited, oldstmt);
104361 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
104362 + tree arg, new_arg;
104363 +
104364 + arg = gimple_phi_arg_def(oldstmt, i);
104365 +
104366 + new_arg = expand(visited, arg);
104367 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
104368 + if (i == 0) {
104369 + phi_ssa_name = new_arg;
104370 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
104371 + }
104372 +
104373 + gcc_assert(new_phi != NULL);
104374 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
104375 + }
104376 +
104377 + gcc_assert(new_phi != NULL);
104378 + update_stmt(new_phi);
104379 + return gimple_phi_result(new_phi);
104380 +}
104381 +
104382 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
104383 +{
104384 + const_gimple assign;
104385 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
104386 + tree origtype = TREE_TYPE(orig_rhs);
104387 +
104388 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
104389 +
104390 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
104391 + return gimple_get_lhs(assign);
104392 +}
104393 +
104394 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
104395 +{
104396 + const_tree rhs1, lhs, rhs1_type, lhs_type;
104397 + enum machine_mode lhs_mode, rhs_mode;
104398 + gimple def_stmt = get_def_stmt(no_const_rhs);
104399 +
104400 + if (!gimple_assign_cast_p(def_stmt))
104401 + return false;
104402 +
104403 + rhs1 = gimple_assign_rhs1(def_stmt);
104404 + lhs = gimple_get_lhs(def_stmt);
104405 + rhs1_type = TREE_TYPE(rhs1);
104406 + lhs_type = TREE_TYPE(lhs);
104407 + rhs_mode = TYPE_MODE(rhs1_type);
104408 + lhs_mode = TYPE_MODE(lhs_type);
104409 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
104410 + return false;
104411 +
104412 + return true;
104413 +}
104414 +
104415 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
104416 +{
104417 + tree rhs1 = gimple_assign_rhs1(stmt);
104418 + tree lhs = gimple_get_lhs(stmt);
104419 + const_tree rhs1_type = TREE_TYPE(rhs1);
104420 + const_tree lhs_type = TREE_TYPE(lhs);
104421 +
104422 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
104423 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104424 +
104425 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
104426 +}
104427 +
104428 +static bool no_uses(tree node)
104429 +{
104430 + imm_use_iterator imm_iter;
104431 + use_operand_p use_p;
104432 +
104433 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
104434 + const_gimple use_stmt = USE_STMT(use_p);
104435 + if (use_stmt == NULL)
104436 + return true;
104437 + if (is_gimple_debug(use_stmt))
104438 + continue;
104439 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
104440 + continue;
104441 + return false;
104442 + }
104443 + return true;
104444 +}
104445 +
104446 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
104447 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
104448 +{
104449 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
104450 + gimple def_stmt = get_def_stmt(lhs);
104451 +
104452 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
104453 + return false;
104454 +
104455 + rhs1 = gimple_assign_rhs1(def_stmt);
104456 + rhs_type = TREE_TYPE(rhs1);
104457 + lhs_type = TREE_TYPE(lhs);
104458 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
104459 + return false;
104460 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
104461 + return false;
104462 +
104463 + def_stmt = get_def_stmt(rhs1);
104464 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
104465 + return false;
104466 +
104467 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
104468 + return false;
104469 +
104470 + rhs1 = gimple_assign_rhs1(def_stmt);
104471 + rhs2 = gimple_assign_rhs2(def_stmt);
104472 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
104473 + return false;
104474 +
104475 + if (is_gimple_constant(rhs2))
104476 + not_const_rhs = rhs1;
104477 + else
104478 + not_const_rhs = rhs2;
104479 +
104480 + return no_uses(not_const_rhs);
104481 +}
104482 +
104483 +static bool skip_lhs_cast_check(const_gimple stmt)
104484 +{
104485 + const_tree rhs = gimple_assign_rhs1(stmt);
104486 + const_gimple def_stmt = get_def_stmt(rhs);
104487 +
104488 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
104489 + if (gimple_code(def_stmt) == GIMPLE_ASM)
104490 + return true;
104491 +
104492 + if (is_const_plus_unsigned_signed_truncation(rhs))
104493 + return true;
104494 +
104495 + return false;
104496 +}
104497 +
104498 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
104499 +{
104500 + bool cast_lhs, cast_rhs;
104501 + tree lhs = gimple_get_lhs(stmt);
104502 + tree rhs = gimple_assign_rhs1(stmt);
104503 + const_tree lhs_type = TREE_TYPE(lhs);
104504 + const_tree rhs_type = TREE_TYPE(rhs);
104505 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
104506 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
104507 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
104508 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
104509 +
104510 + static bool check_lhs[3][4] = {
104511 + // ss su us uu
104512 + { false, true, true, false }, // lhs > rhs
104513 + { false, false, false, false }, // lhs = rhs
104514 + { true, true, true, true }, // lhs < rhs
104515 + };
104516 +
104517 + static bool check_rhs[3][4] = {
104518 + // ss su us uu
104519 + { true, false, true, true }, // lhs > rhs
104520 + { true, false, true, true }, // lhs = rhs
104521 + { true, false, true, true }, // lhs < rhs
104522 + };
104523 +
104524 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
104525 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
104526 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104527 +
104528 + if (lhs_size > rhs_size) {
104529 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104530 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104531 + } else if (lhs_size == rhs_size) {
104532 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104533 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104534 + } else {
104535 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104536 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
104537 + }
104538 +
104539 + if (!cast_lhs && !cast_rhs)
104540 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
104541 +
104542 + if (cast_lhs && !skip_lhs_cast_check(stmt))
104543 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
104544 +
104545 + if (cast_rhs)
104546 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
104547 +
104548 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
104549 +}
104550 +
104551 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
104552 +{
104553 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
104554 +
104555 + if (gimple_plf(stmt, MY_STMT))
104556 + return lhs;
104557 +
104558 + rhs1 = gimple_assign_rhs1(stmt);
104559 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
104560 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104561 +
104562 + new_rhs1 = expand(visited, rhs1);
104563 +
104564 + if (new_rhs1 == NULL_TREE)
104565 + return create_cast_assign(visited, stmt);
104566 +
104567 + if (gimple_plf(stmt, NO_CAST_CHECK))
104568 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
104569 +
104570 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
104571 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
104572 +
104573 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
104574 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
104575 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104576 + }
104577 +
104578 + if (!gimple_assign_cast_p(stmt))
104579 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
104580 +
104581 + return create_cast_overflow_check(visited, new_rhs1, stmt);
104582 +}
104583 +
104584 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
104585 +{
104586 + tree rhs1, lhs = gimple_get_lhs(stmt);
104587 + gimple def_stmt = get_def_stmt(lhs);
104588 +
104589 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
104590 + rhs1 = gimple_assign_rhs1(def_stmt);
104591 +
104592 + if (is_gimple_constant(rhs1))
104593 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
104594 +
104595 + switch (TREE_CODE(rhs1)) {
104596 + case SSA_NAME:
104597 + return handle_unary_rhs(visited, def_stmt);
104598 + case ARRAY_REF:
104599 + case BIT_FIELD_REF:
104600 + case ADDR_EXPR:
104601 + case COMPONENT_REF:
104602 + case INDIRECT_REF:
104603 +#if BUILDING_GCC_VERSION >= 4006
104604 + case MEM_REF:
104605 +#endif
104606 + case TARGET_MEM_REF:
104607 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
104608 + case PARM_DECL:
104609 + case VAR_DECL:
104610 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104611 +
104612 + default:
104613 + debug_gimple_stmt(def_stmt);
104614 + debug_tree(rhs1);
104615 + gcc_unreachable();
104616 + }
104617 +}
104618 +
104619 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
104620 +{
104621 + gimple cond_stmt;
104622 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
104623 +
104624 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
104625 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
104626 + update_stmt(cond_stmt);
104627 +}
104628 +
104629 +static tree create_string_param(tree string)
104630 +{
104631 + tree i_type, a_type;
104632 + const int length = TREE_STRING_LENGTH(string);
104633 +
104634 + gcc_assert(length > 0);
104635 +
104636 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
104637 + a_type = build_array_type(char_type_node, i_type);
104638 +
104639 + TREE_TYPE(string) = a_type;
104640 + TREE_CONSTANT(string) = 1;
104641 + TREE_READONLY(string) = 1;
104642 +
104643 + return build1(ADDR_EXPR, ptr_type_node, string);
104644 +}
104645 +
104646 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
104647 +{
104648 + gimple func_stmt;
104649 + const_gimple def_stmt;
104650 + const_tree loc_line;
104651 + tree loc_file, ssa_name, current_func;
104652 + expanded_location xloc;
104653 + char *ssa_name_buf;
104654 + int len;
104655 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
104656 +
104657 + def_stmt = get_def_stmt(arg);
104658 + xloc = expand_location(gimple_location(def_stmt));
104659 +
104660 + if (!gimple_has_location(def_stmt)) {
104661 + xloc = expand_location(gimple_location(stmt));
104662 + if (!gimple_has_location(stmt))
104663 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
104664 + }
104665 +
104666 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
104667 +
104668 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
104669 + loc_file = create_string_param(loc_file);
104670 +
104671 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
104672 + current_func = create_string_param(current_func);
104673 +
104674 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
104675 + call_count++;
104676 + 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);
104677 + gcc_assert(len > 0);
104678 + ssa_name = build_string(len + 1, ssa_name_buf);
104679 + free(ssa_name_buf);
104680 + ssa_name = create_string_param(ssa_name);
104681 +
104682 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
104683 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
104684 +
104685 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
104686 +}
104687 +
104688 +static void __unused print_the_code_insertions(const_gimple stmt)
104689 +{
104690 + location_t loc = gimple_location(stmt);
104691 +
104692 + inform(loc, "Integer size_overflow check applied here.");
104693 +}
104694 +
104695 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
104696 +{
104697 + basic_block cond_bb, join_bb, bb_true;
104698 + edge e;
104699 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
104700 +
104701 + cond_bb = gimple_bb(stmt);
104702 + if (before)
104703 + gsi_prev(&gsi);
104704 + if (gsi_end_p(gsi))
104705 + e = split_block_after_labels(cond_bb);
104706 + else
104707 + e = split_block(cond_bb, gsi_stmt(gsi));
104708 + cond_bb = e->src;
104709 + join_bb = e->dest;
104710 + e->flags = EDGE_FALSE_VALUE;
104711 + e->probability = REG_BR_PROB_BASE;
104712 +
104713 + bb_true = create_empty_bb(cond_bb);
104714 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
104715 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
104716 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
104717 +
104718 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
104719 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
104720 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
104721 +
104722 + if (current_loops != NULL) {
104723 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
104724 + add_bb_to_loop(bb_true, cond_bb->loop_father);
104725 + }
104726 +
104727 + insert_cond(cond_bb, arg, cond_code, type_value);
104728 + insert_cond_result(bb_true, stmt, arg, min);
104729 +
104730 +// print_the_code_insertions(stmt);
104731 +}
104732 +
104733 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
104734 +{
104735 + const_tree rhs_type = TREE_TYPE(rhs);
104736 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
104737 +
104738 + gcc_assert(rhs_type != NULL_TREE);
104739 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
104740 + return;
104741 +
104742 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
104743 +
104744 + if (is_const_plus_unsigned_signed_truncation(rhs))
104745 + return;
104746 +
104747 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
104748 + // typemax (-1) < typemin (0)
104749 + if (TREE_OVERFLOW(type_max))
104750 + return;
104751 +
104752 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
104753 +
104754 + cast_rhs_type = TREE_TYPE(cast_rhs);
104755 + type_max_type = TREE_TYPE(type_max);
104756 + type_min_type = TREE_TYPE(type_min);
104757 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
104758 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
104759 +
104760 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
104761 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
104762 +}
104763 +
104764 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
104765 +{
104766 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
104767 + return false;
104768 + if (!is_gimple_constant(rhs))
104769 + return false;
104770 + return true;
104771 +}
104772 +
104773 +static tree get_def_stmt_rhs(const_tree var)
104774 +{
104775 + tree rhs1, def_stmt_rhs1;
104776 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
104777 +
104778 + def_stmt = get_def_stmt(var);
104779 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
104780 +
104781 + rhs1 = gimple_assign_rhs1(def_stmt);
104782 + rhs1_def_stmt = get_def_stmt(rhs1);
104783 + if (!gimple_assign_cast_p(rhs1_def_stmt))
104784 + return rhs1;
104785 +
104786 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
104787 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
104788 +
104789 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
104790 + case GIMPLE_CALL:
104791 + case GIMPLE_NOP:
104792 + case GIMPLE_ASM:
104793 + case GIMPLE_PHI:
104794 + return def_stmt_rhs1;
104795 + case GIMPLE_ASSIGN:
104796 + return rhs1;
104797 + default:
104798 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
104799 + gcc_unreachable();
104800 + }
104801 +}
104802 +
104803 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
104804 +{
104805 + tree new_rhs, orig_rhs;
104806 + void (*gimple_assign_set_rhs)(gimple, tree);
104807 + tree rhs1 = gimple_assign_rhs1(stmt);
104808 + tree rhs2 = gimple_assign_rhs2(stmt);
104809 + tree lhs = gimple_get_lhs(stmt);
104810 +
104811 + if (!check_overflow)
104812 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104813 +
104814 + if (change_rhs == NULL_TREE)
104815 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104816 +
104817 + if (new_rhs2 == NULL_TREE) {
104818 + orig_rhs = rhs1;
104819 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
104820 + } else {
104821 + orig_rhs = rhs2;
104822 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
104823 + }
104824 +
104825 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
104826 +
104827 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
104828 + gimple_assign_set_rhs(stmt, new_rhs);
104829 + update_stmt(stmt);
104830 +
104831 + return create_assign(visited, stmt, lhs, AFTER_STMT);
104832 +}
104833 +
104834 +static bool is_subtraction_special(const_gimple stmt)
104835 +{
104836 + gimple rhs1_def_stmt, rhs2_def_stmt;
104837 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
104838 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
104839 + const_tree rhs1 = gimple_assign_rhs1(stmt);
104840 + const_tree rhs2 = gimple_assign_rhs2(stmt);
104841 +
104842 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
104843 + return false;
104844 +
104845 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
104846 +
104847 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
104848 + return false;
104849 +
104850 + rhs1_def_stmt = get_def_stmt(rhs1);
104851 + rhs2_def_stmt = get_def_stmt(rhs2);
104852 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
104853 + return false;
104854 +
104855 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
104856 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
104857 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
104858 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
104859 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
104860 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
104861 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
104862 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
104863 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
104864 + return false;
104865 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
104866 + return false;
104867 +
104868 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
104869 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
104870 + return true;
104871 +}
104872 +
104873 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
104874 +{
104875 + tree new_rhs1, new_rhs2;
104876 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
104877 + gimple assign, stmt = get_def_stmt(lhs);
104878 + tree rhs1 = gimple_assign_rhs1(stmt);
104879 + tree rhs2 = gimple_assign_rhs2(stmt);
104880 +
104881 + if (!is_subtraction_special(stmt))
104882 + return NULL_TREE;
104883 +
104884 + new_rhs1 = expand(visited, rhs1);
104885 + new_rhs2 = expand(visited, rhs2);
104886 +
104887 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
104888 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
104889 +
104890 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
104891 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
104892 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
104893 + }
104894 +
104895 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
104896 + new_lhs = gimple_get_lhs(assign);
104897 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
104898 +
104899 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
104900 +}
104901 +
104902 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
104903 +{
104904 + const_gimple def_stmt;
104905 +
104906 + if (TREE_CODE(rhs) != SSA_NAME)
104907 + return false;
104908 +
104909 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
104910 + return false;
104911 +
104912 + def_stmt = get_def_stmt(rhs);
104913 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
104914 + return false;
104915 +
104916 + return true;
104917 +}
104918 +
104919 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
104920 +{
104921 + tree rhs1, rhs2, new_lhs;
104922 + gimple def_stmt = get_def_stmt(lhs);
104923 + tree new_rhs1 = NULL_TREE;
104924 + tree new_rhs2 = NULL_TREE;
104925 +
104926 + rhs1 = gimple_assign_rhs1(def_stmt);
104927 + rhs2 = gimple_assign_rhs2(def_stmt);
104928 +
104929 + /* no DImode/TImode division in the 32/64 bit kernel */
104930 + switch (gimple_assign_rhs_code(def_stmt)) {
104931 + case RDIV_EXPR:
104932 + case TRUNC_DIV_EXPR:
104933 + case CEIL_DIV_EXPR:
104934 + case FLOOR_DIV_EXPR:
104935 + case ROUND_DIV_EXPR:
104936 + case TRUNC_MOD_EXPR:
104937 + case CEIL_MOD_EXPR:
104938 + case FLOOR_MOD_EXPR:
104939 + case ROUND_MOD_EXPR:
104940 + case EXACT_DIV_EXPR:
104941 + case POINTER_PLUS_EXPR:
104942 + case BIT_AND_EXPR:
104943 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
104944 + default:
104945 + break;
104946 + }
104947 +
104948 + new_lhs = handle_integer_truncation(visited, lhs);
104949 + if (new_lhs != NULL_TREE)
104950 + return new_lhs;
104951 +
104952 + if (TREE_CODE(rhs1) == SSA_NAME)
104953 + new_rhs1 = expand(visited, rhs1);
104954 + if (TREE_CODE(rhs2) == SSA_NAME)
104955 + new_rhs2 = expand(visited, rhs2);
104956 +
104957 + if (is_a_neg_overflow(def_stmt, rhs2))
104958 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
104959 + if (is_a_neg_overflow(def_stmt, rhs1))
104960 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
104961 +
104962 +
104963 + if (is_a_constant_overflow(def_stmt, rhs2))
104964 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
104965 + if (is_a_constant_overflow(def_stmt, rhs1))
104966 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
104967 +
104968 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
104969 +}
104970 +
104971 +#if BUILDING_GCC_VERSION >= 4007
104972 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
104973 +{
104974 + if (is_gimple_constant(rhs))
104975 + return cast_a_tree(size_overflow_type, rhs);
104976 + if (TREE_CODE(rhs) != SSA_NAME)
104977 + return NULL_TREE;
104978 + return expand(visited, rhs);
104979 +}
104980 +
104981 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
104982 +{
104983 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
104984 + gimple def_stmt = get_def_stmt(lhs);
104985 +
104986 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
104987 +
104988 + rhs1 = gimple_assign_rhs1(def_stmt);
104989 + rhs2 = gimple_assign_rhs2(def_stmt);
104990 + rhs3 = gimple_assign_rhs3(def_stmt);
104991 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
104992 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
104993 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
104994 +
104995 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
104996 +}
104997 +#endif
104998 +
104999 +static tree get_size_overflow_type(gimple stmt, const_tree node)
105000 +{
105001 + const_tree type;
105002 + tree new_type;
105003 +
105004 + gcc_assert(node != NULL_TREE);
105005 +
105006 + type = TREE_TYPE(node);
105007 +
105008 + if (gimple_plf(stmt, MY_STMT))
105009 + return TREE_TYPE(node);
105010 +
105011 + switch (TYPE_MODE(type)) {
105012 + case QImode:
105013 + new_type = intHI_type_node;
105014 + break;
105015 + case HImode:
105016 + new_type = intSI_type_node;
105017 + break;
105018 + case SImode:
105019 + new_type = intDI_type_node;
105020 + break;
105021 + case DImode:
105022 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
105023 + new_type = intDI_type_node;
105024 + else
105025 + new_type = intTI_type_node;
105026 + break;
105027 + default:
105028 + debug_tree((tree)node);
105029 + error("%s: unsupported gcc configuration.", __func__);
105030 + gcc_unreachable();
105031 + }
105032 +
105033 + if (TYPE_QUALS(type) != 0)
105034 + return build_qualified_type(new_type, TYPE_QUALS(type));
105035 + return new_type;
105036 +}
105037 +
105038 +static tree expand_visited(gimple def_stmt)
105039 +{
105040 + const_gimple next_stmt;
105041 + gimple_stmt_iterator gsi;
105042 + enum gimple_code code = gimple_code(def_stmt);
105043 +
105044 + if (code == GIMPLE_ASM)
105045 + return NULL_TREE;
105046 +
105047 + gsi = gsi_for_stmt(def_stmt);
105048 + gsi_next(&gsi);
105049 +
105050 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
105051 + return NULL_TREE;
105052 + gcc_assert(!gsi_end_p(gsi));
105053 + next_stmt = gsi_stmt(gsi);
105054 +
105055 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
105056 + return NULL_TREE;
105057 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
105058 +
105059 + return get_lhs(next_stmt);
105060 +}
105061 +
105062 +static tree expand(struct pointer_set_t *visited, tree lhs)
105063 +{
105064 + gimple def_stmt;
105065 +
105066 + if (skip_types(lhs))
105067 + return NULL_TREE;
105068 +
105069 + def_stmt = get_def_stmt(lhs);
105070 +
105071 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
105072 + return NULL_TREE;
105073 +
105074 + if (gimple_plf(def_stmt, MY_STMT))
105075 + return lhs;
105076 +
105077 + if (pointer_set_contains(visited, def_stmt))
105078 + return expand_visited(def_stmt);
105079 +
105080 + switch (gimple_code(def_stmt)) {
105081 + case GIMPLE_PHI:
105082 + return handle_phi(visited, lhs);
105083 + case GIMPLE_CALL:
105084 + case GIMPLE_ASM:
105085 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
105086 + case GIMPLE_ASSIGN:
105087 + switch (gimple_num_ops(def_stmt)) {
105088 + case 2:
105089 + return handle_unary_ops(visited, def_stmt);
105090 + case 3:
105091 + return handle_binary_ops(visited, lhs);
105092 +#if BUILDING_GCC_VERSION >= 4007
105093 + case 4:
105094 + return handle_ternary_ops(visited, lhs);
105095 +#endif
105096 + }
105097 + default:
105098 + debug_gimple_stmt(def_stmt);
105099 + error("%s: unknown gimple code", __func__);
105100 + gcc_unreachable();
105101 + }
105102 +}
105103 +
105104 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
105105 +{
105106 + const_gimple assign;
105107 + tree orig_type = TREE_TYPE(orig_node);
105108 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
105109 +
105110 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
105111 + return gimple_get_lhs(assign);
105112 +}
105113 +
105114 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
105115 +{
105116 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
105117 + update_stmt(stmt);
105118 +}
105119 +
105120 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
105121 +{
105122 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
105123 + update_stmt(stmt);
105124 +}
105125 +
105126 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
105127 +{
105128 + tree arg;
105129 + const_tree origarg;
105130 +
105131 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
105132 + return true;
105133 +
105134 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
105135 + while (origarg && *argnum) {
105136 + (*argnum)--;
105137 + origarg = TREE_CHAIN(origarg);
105138 + }
105139 +
105140 + gcc_assert(*argnum == 0);
105141 +
105142 + gcc_assert(origarg != NULL_TREE);
105143 + *argnum = 0;
105144 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
105145 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
105146 + return true;
105147 + return false;
105148 +}
105149 +
105150 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
105151 +{
105152 + gimple phi = get_def_stmt(result);
105153 + unsigned int i, n = gimple_phi_num_args(phi);
105154 +
105155 + if (!phi)
105156 + return MARK_NO;
105157 +
105158 + pointer_set_insert(visited, phi);
105159 + for (i = 0; i < n; i++) {
105160 + enum mark marked;
105161 + const_tree arg = gimple_phi_arg_def(phi, i);
105162 + marked = pre_expand(visited, search_err_code, arg);
105163 + if (marked != MARK_NO)
105164 + return marked;
105165 + }
105166 + return MARK_NO;
105167 +}
105168 +
105169 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
105170 +{
105171 + gimple def_stmt = get_def_stmt(lhs);
105172 + const_tree rhs;
105173 +
105174 + if (!def_stmt)
105175 + return MARK_NO;
105176 +
105177 + rhs = gimple_assign_rhs1(def_stmt);
105178 +
105179 + def_stmt = get_def_stmt(rhs);
105180 + if (is_gimple_constant(rhs))
105181 + search_err_code[FROM_CONST] = true;
105182 +
105183 + return pre_expand(visited, search_err_code, rhs);
105184 +}
105185 +
105186 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
105187 +{
105188 + gimple def_stmt = get_def_stmt(lhs);
105189 + const_tree rhs1, rhs2;
105190 + enum mark marked;
105191 +
105192 + if (!def_stmt)
105193 + return MARK_NO;
105194 +
105195 + search_err_code[CAST_ONLY] = false;
105196 +
105197 + rhs1 = gimple_assign_rhs1(def_stmt);
105198 + rhs2 = gimple_assign_rhs2(def_stmt);
105199 + marked = pre_expand(visited, search_err_code, rhs1);
105200 + if (marked != MARK_NO)
105201 + return marked;
105202 + return pre_expand(visited, search_err_code, rhs2);
105203 +}
105204 +
105205 +static const_tree search_field_decl(const_tree comp_ref)
105206 +{
105207 + const_tree field = NULL_TREE;
105208 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
105209 +
105210 + for (i = 0; i < len; i++) {
105211 + field = TREE_OPERAND(comp_ref, i);
105212 + if (TREE_CODE(field) == FIELD_DECL)
105213 + break;
105214 + }
105215 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
105216 + return field;
105217 +}
105218 +
105219 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
105220 +{
105221 + const_tree attr, p;
105222 +
105223 + // 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);
105224 + if (fndecl == NULL_TREE)
105225 + return MARK_NO;
105226 +
105227 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
105228 + if (!attr || !TREE_VALUE(attr))
105229 + return MARK_NO;
105230 +
105231 + p = TREE_VALUE(attr);
105232 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
105233 + return MARK_TURN_OFF;
105234 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
105235 + return MARK_NOT_INTENTIONAL;
105236 + if (argnum == 0) {
105237 + gcc_assert(current_function_decl == fndecl);
105238 + return MARK_NO;
105239 + }
105240 +
105241 + do {
105242 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
105243 + return MARK_YES;
105244 + p = TREE_CHAIN(p);
105245 + } while (p);
105246 +
105247 + return MARK_NO;
105248 +}
105249 +
105250 +static void print_missing_msg(tree func, unsigned int argnum)
105251 +{
105252 + unsigned int new_hash;
105253 + size_t len;
105254 + unsigned char tree_codes[CODES_LIMIT];
105255 + location_t loc;
105256 + const char *curfunc;
105257 +
105258 + func = get_original_function_decl(func);
105259 + loc = DECL_SOURCE_LOCATION(func);
105260 + curfunc = get_asm_name(func);
105261 +
105262 + len = get_function_decl(func, tree_codes);
105263 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
105264 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
105265 +}
105266 +
105267 +static unsigned int search_missing_attribute(const_tree arg)
105268 +{
105269 + unsigned int argnum;
105270 + const struct size_overflow_hash *hash;
105271 + const_tree type = TREE_TYPE(arg);
105272 + tree func = get_original_function_decl(current_function_decl);
105273 +
105274 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
105275 +
105276 + if (TREE_CODE(type) == POINTER_TYPE)
105277 + return 0;
105278 +
105279 + argnum = find_arg_number(arg, func);
105280 + if (argnum == 0)
105281 + return 0;
105282 +
105283 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
105284 + return argnum;
105285 +
105286 + hash = get_function_hash(func);
105287 + if (!hash || !(hash->param & (1U << argnum))) {
105288 + print_missing_msg(func, argnum);
105289 + return 0;
105290 + }
105291 + return argnum;
105292 +}
105293 +
105294 +static enum mark is_already_marked(const_tree lhs)
105295 +{
105296 + unsigned int argnum;
105297 + const_tree fndecl;
105298 +
105299 + argnum = search_missing_attribute(lhs);
105300 + fndecl = get_original_function_decl(current_function_decl);
105301 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
105302 + return MARK_YES;
105303 + return MARK_NO;
105304 +}
105305 +
105306 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
105307 +{
105308 + const_gimple def_stmt;
105309 +
105310 + if (skip_types(lhs))
105311 + return MARK_NO;
105312 +
105313 + if (TREE_CODE(lhs) == PARM_DECL)
105314 + return is_already_marked(lhs);
105315 +
105316 + if (TREE_CODE(lhs) == COMPONENT_REF) {
105317 + const_tree field, attr;
105318 +
105319 + field = search_field_decl(lhs);
105320 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
105321 + if (!attr || !TREE_VALUE(attr))
105322 + return MARK_NO;
105323 + return MARK_YES;
105324 + }
105325 +
105326 + def_stmt = get_def_stmt(lhs);
105327 +
105328 + if (!def_stmt)
105329 + return MARK_NO;
105330 +
105331 + if (pointer_set_contains(visited, def_stmt))
105332 + return MARK_NO;
105333 +
105334 + switch (gimple_code(def_stmt)) {
105335 + case GIMPLE_NOP:
105336 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
105337 + return is_already_marked(lhs);
105338 + return MARK_NO;
105339 + case GIMPLE_PHI:
105340 + return walk_phi(visited, search_err_code, lhs);
105341 + case GIMPLE_CALL:
105342 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
105343 + return MARK_TURN_OFF;
105344 + check_function_hash(def_stmt);
105345 + return MARK_NO;
105346 + case GIMPLE_ASM:
105347 + search_err_code[CAST_ONLY] = false;
105348 + return MARK_NO;
105349 + case GIMPLE_ASSIGN:
105350 + switch (gimple_num_ops(def_stmt)) {
105351 + case 2:
105352 + return walk_unary_ops(visited, search_err_code, lhs);
105353 + case 3:
105354 + return walk_binary_ops(visited, search_err_code, lhs);
105355 + }
105356 + default:
105357 + debug_gimple_stmt((gimple)def_stmt);
105358 + error("%s: unknown gimple code", __func__);
105359 + gcc_unreachable();
105360 + }
105361 +}
105362 +
105363 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
105364 +static bool skip_asm(const_tree arg)
105365 +{
105366 + gimple def_stmt = get_def_stmt(arg);
105367 +
105368 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
105369 + return false;
105370 +
105371 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
105372 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
105373 +}
105374 +
105375 +/*
105376 +0</MARK_YES: no dup, search attributes (so, int)
105377 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
105378 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
105379 +*/
105380 +
105381 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
105382 +{
105383 + struct pointer_set_t *visited;
105384 + enum mark is_marked, is_found;
105385 + location_t loc;
105386 + bool search_err_code[2] = {true, false};
105387 +
105388 + is_marked = mark_status(current_function_decl, 0);
105389 + if (is_marked == MARK_TURN_OFF)
105390 + return true;
105391 +
105392 + is_marked = mark_status(fndecl, argnum + 1);
105393 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
105394 + return true;
105395 +
105396 + visited = pointer_set_create();
105397 + is_found = pre_expand(visited, search_err_code, arg);
105398 + pointer_set_destroy(visited);
105399 +
105400 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
105401 + return true;
105402 +
105403 + if (where == FROM_ARG && skip_asm(arg))
105404 + return true;
105405 +
105406 + if (is_found == MARK_TURN_OFF)
105407 + return true;
105408 +
105409 + if ((is_found == MARK_YES && is_marked == MARK_YES))
105410 + return true;
105411 +
105412 + if (is_found == MARK_YES) {
105413 + loc = DECL_SOURCE_LOCATION(fndecl);
105414 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
105415 + return true;
105416 + }
105417 + return false;
105418 +}
105419 +
105420 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
105421 +{
105422 + struct pointer_set_t *visited;
105423 + tree arg, new_arg;
105424 + bool match;
105425 +
105426 + if (argnum == 0)
105427 + return;
105428 +
105429 + argnum--;
105430 +
105431 + match = get_function_arg(&argnum, fndecl);
105432 + if (!match)
105433 + return;
105434 + gcc_assert(gimple_call_num_args(stmt) > argnum);
105435 + arg = gimple_call_arg(stmt, argnum);
105436 + if (arg == NULL_TREE)
105437 + return;
105438 +
105439 + if (skip_types(arg))
105440 + return;
105441 +
105442 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
105443 + return;
105444 +
105445 + visited = pointer_set_create();
105446 + new_arg = expand(visited, arg);
105447 + pointer_set_destroy(visited);
105448 +
105449 + if (new_arg == NULL_TREE)
105450 + return;
105451 +
105452 + change_function_arg(stmt, arg, argnum, new_arg);
105453 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
105454 +}
105455 +
105456 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
105457 +{
105458 + tree p = TREE_VALUE(attr);
105459 + do {
105460 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
105461 + p = TREE_CHAIN(p);
105462 + } while (p);
105463 +}
105464 +
105465 +static void handle_function_by_hash(gimple stmt, tree fndecl)
105466 +{
105467 + unsigned int num;
105468 + const struct size_overflow_hash *hash;
105469 +
105470 + hash = get_function_hash(fndecl);
105471 + if (!hash)
105472 + return;
105473 +
105474 + for (num = 0; num <= MAX_PARAM; num++)
105475 + if (hash->param & (1U << num))
105476 + handle_function_arg(stmt, fndecl, num);
105477 +}
105478 +
105479 +static bool check_return_value(void)
105480 +{
105481 + const struct size_overflow_hash *hash;
105482 +
105483 + hash = get_function_hash(current_function_decl);
105484 + if (!hash || !(hash->param & 1U << 0))
105485 + return false;
105486 +
105487 + return true;
105488 +}
105489 +
105490 +static void handle_return_value(gimple ret_stmt)
105491 +{
105492 + struct pointer_set_t *visited;
105493 + tree ret, new_ret;
105494 +
105495 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
105496 + return;
105497 +
105498 + ret = gimple_return_retval(ret_stmt);
105499 +
105500 + if (skip_types(ret))
105501 + return;
105502 +
105503 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
105504 + return;
105505 +
105506 + visited = pointer_set_create();
105507 + new_ret = expand(visited, ret);
105508 + pointer_set_destroy(visited);
105509 +
105510 + change_function_return(ret_stmt, ret, new_ret);
105511 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
105512 +}
105513 +
105514 +static void set_plf_false(void)
105515 +{
105516 + basic_block bb;
105517 +
105518 + FOR_ALL_BB(bb) {
105519 + gimple_stmt_iterator si;
105520 +
105521 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
105522 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
105523 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
105524 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
105525 + }
105526 +}
105527 +
105528 +static unsigned int handle_function(void)
105529 +{
105530 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
105531 + bool check_ret;
105532 +
105533 + set_plf_false();
105534 +
105535 + check_ret = check_return_value();
105536 +
105537 + do {
105538 + gimple_stmt_iterator gsi;
105539 + next = bb->next_bb;
105540 +
105541 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
105542 + tree fndecl, attr;
105543 + gimple stmt = gsi_stmt(gsi);
105544 +
105545 + if (check_ret)
105546 + handle_return_value(stmt);
105547 +
105548 + if (!(is_gimple_call(stmt)))
105549 + continue;
105550 + fndecl = gimple_call_fndecl(stmt);
105551 + if (fndecl == NULL_TREE)
105552 + continue;
105553 + if (gimple_call_num_args(stmt) == 0)
105554 + continue;
105555 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
105556 + if (!attr || !TREE_VALUE(attr))
105557 + handle_function_by_hash(stmt, fndecl);
105558 + else
105559 + handle_function_by_attribute(stmt, attr, fndecl);
105560 + gsi = gsi_for_stmt(stmt);
105561 + next = gimple_bb(stmt)->next_bb;
105562 + }
105563 + bb = next;
105564 + } while (bb);
105565 + return 0;
105566 +}
105567 +
105568 +static struct gimple_opt_pass size_overflow_pass = {
105569 + .pass = {
105570 + .type = GIMPLE_PASS,
105571 + .name = "size_overflow",
105572 +#if BUILDING_GCC_VERSION >= 4008
105573 + .optinfo_flags = OPTGROUP_NONE,
105574 +#endif
105575 + .gate = NULL,
105576 + .execute = handle_function,
105577 + .sub = NULL,
105578 + .next = NULL,
105579 + .static_pass_number = 0,
105580 + .tv_id = TV_NONE,
105581 + .properties_required = PROP_cfg,
105582 + .properties_provided = 0,
105583 + .properties_destroyed = 0,
105584 + .todo_flags_start = 0,
105585 + .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
105586 + }
105587 +};
105588 +
105589 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
105590 +{
105591 + tree fntype;
105592 +
105593 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
105594 +
105595 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
105596 + fntype = build_function_type_list(void_type_node,
105597 + const_char_ptr_type_node,
105598 + unsigned_type_node,
105599 + const_char_ptr_type_node,
105600 + const_char_ptr_type_node,
105601 + NULL_TREE);
105602 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
105603 +
105604 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
105605 + TREE_PUBLIC(report_size_overflow_decl) = 1;
105606 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
105607 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
105608 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
105609 +}
105610 +
105611 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
105612 +{
105613 + int i;
105614 + const char * const plugin_name = plugin_info->base_name;
105615 + const int argc = plugin_info->argc;
105616 + const struct plugin_argument * const argv = plugin_info->argv;
105617 + bool enable = true;
105618 +
105619 + struct register_pass_info size_overflow_pass_info = {
105620 + .pass = &size_overflow_pass.pass,
105621 + .reference_pass_name = "ssa",
105622 + .ref_pass_instance_number = 1,
105623 + .pos_op = PASS_POS_INSERT_AFTER
105624 + };
105625 +
105626 + if (!plugin_default_version_check(version, &gcc_version)) {
105627 + error(G_("incompatible gcc/plugin versions"));
105628 + return 1;
105629 + }
105630 +
105631 + for (i = 0; i < argc; ++i) {
105632 + if (!strcmp(argv[i].key, "no-size-overflow")) {
105633 + enable = false;
105634 + continue;
105635 + }
105636 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
105637 + }
105638 +
105639 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
105640 + if (enable) {
105641 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
105642 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
105643 + }
105644 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
105645 +
105646 + return 0;
105647 +}
105648 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
105649 new file mode 100644
105650 index 0000000..ac2901e
105651 --- /dev/null
105652 +++ b/tools/gcc/stackleak_plugin.c
105653 @@ -0,0 +1,327 @@
105654 +/*
105655 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
105656 + * Licensed under the GPL v2
105657 + *
105658 + * Note: the choice of the license means that the compilation process is
105659 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
105660 + * but for the kernel it doesn't matter since it doesn't link against
105661 + * any of the gcc libraries
105662 + *
105663 + * gcc plugin to help implement various PaX features
105664 + *
105665 + * - track lowest stack pointer
105666 + *
105667 + * TODO:
105668 + * - initialize all local variables
105669 + *
105670 + * BUGS:
105671 + * - none known
105672 + */
105673 +#include "gcc-plugin.h"
105674 +#include "config.h"
105675 +#include "system.h"
105676 +#include "coretypes.h"
105677 +#include "tree.h"
105678 +#include "tree-pass.h"
105679 +#include "flags.h"
105680 +#include "intl.h"
105681 +#include "toplev.h"
105682 +#include "plugin.h"
105683 +//#include "expr.h" where are you...
105684 +#include "diagnostic.h"
105685 +#include "plugin-version.h"
105686 +#include "tm.h"
105687 +#include "function.h"
105688 +#include "basic-block.h"
105689 +#include "gimple.h"
105690 +#include "rtl.h"
105691 +#include "emit-rtl.h"
105692 +
105693 +#if BUILDING_GCC_VERSION >= 4008
105694 +#define TODO_dump_func 0
105695 +#endif
105696 +
105697 +extern void print_gimple_stmt(FILE *, gimple, int, int);
105698 +
105699 +int plugin_is_GPL_compatible;
105700 +
105701 +static int track_frame_size = -1;
105702 +static const char track_function[] = "pax_track_stack";
105703 +static const char check_function[] = "pax_check_alloca";
105704 +static bool init_locals;
105705 +
105706 +static struct plugin_info stackleak_plugin_info = {
105707 + .version = "201302112000",
105708 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
105709 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
105710 +};
105711 +
105712 +static bool gate_stackleak_track_stack(void);
105713 +static unsigned int execute_stackleak_tree_instrument(void);
105714 +static unsigned int execute_stackleak_final(void);
105715 +
105716 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
105717 + .pass = {
105718 + .type = GIMPLE_PASS,
105719 + .name = "stackleak_tree_instrument",
105720 +#if BUILDING_GCC_VERSION >= 4008
105721 + .optinfo_flags = OPTGROUP_NONE,
105722 +#endif
105723 + .gate = gate_stackleak_track_stack,
105724 + .execute = execute_stackleak_tree_instrument,
105725 + .sub = NULL,
105726 + .next = NULL,
105727 + .static_pass_number = 0,
105728 + .tv_id = TV_NONE,
105729 + .properties_required = PROP_gimple_leh | PROP_cfg,
105730 + .properties_provided = 0,
105731 + .properties_destroyed = 0,
105732 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
105733 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
105734 + }
105735 +};
105736 +
105737 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
105738 + .pass = {
105739 + .type = RTL_PASS,
105740 + .name = "stackleak_final",
105741 +#if BUILDING_GCC_VERSION >= 4008
105742 + .optinfo_flags = OPTGROUP_NONE,
105743 +#endif
105744 + .gate = gate_stackleak_track_stack,
105745 + .execute = execute_stackleak_final,
105746 + .sub = NULL,
105747 + .next = NULL,
105748 + .static_pass_number = 0,
105749 + .tv_id = TV_NONE,
105750 + .properties_required = 0,
105751 + .properties_provided = 0,
105752 + .properties_destroyed = 0,
105753 + .todo_flags_start = 0,
105754 + .todo_flags_finish = TODO_dump_func
105755 + }
105756 +};
105757 +
105758 +static bool gate_stackleak_track_stack(void)
105759 +{
105760 + return track_frame_size >= 0;
105761 +}
105762 +
105763 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
105764 +{
105765 + gimple check_alloca;
105766 + tree fntype, fndecl, alloca_size;
105767 +
105768 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
105769 + fndecl = build_fn_decl(check_function, fntype);
105770 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
105771 +
105772 + // insert call to void pax_check_alloca(unsigned long size)
105773 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
105774 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
105775 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
105776 +}
105777 +
105778 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
105779 +{
105780 + gimple track_stack;
105781 + tree fntype, fndecl;
105782 +
105783 + fntype = build_function_type_list(void_type_node, NULL_TREE);
105784 + fndecl = build_fn_decl(track_function, fntype);
105785 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
105786 +
105787 + // insert call to void pax_track_stack(void)
105788 + track_stack = gimple_build_call(fndecl, 0);
105789 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
105790 +}
105791 +
105792 +#if BUILDING_GCC_VERSION == 4005
105793 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
105794 +{
105795 + tree fndecl;
105796 +
105797 + if (!is_gimple_call(stmt))
105798 + return false;
105799 + fndecl = gimple_call_fndecl(stmt);
105800 + if (!fndecl)
105801 + return false;
105802 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
105803 + return false;
105804 +// print_node(stderr, "pax", fndecl, 4);
105805 + return DECL_FUNCTION_CODE(fndecl) == code;
105806 +}
105807 +#endif
105808 +
105809 +static bool is_alloca(gimple stmt)
105810 +{
105811 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
105812 + return true;
105813 +
105814 +#if BUILDING_GCC_VERSION >= 4007
105815 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
105816 + return true;
105817 +#endif
105818 +
105819 + return false;
105820 +}
105821 +
105822 +static unsigned int execute_stackleak_tree_instrument(void)
105823 +{
105824 + basic_block bb, entry_bb;
105825 + bool prologue_instrumented = false, is_leaf = true;
105826 +
105827 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
105828 +
105829 + // 1. loop through BBs and GIMPLE statements
105830 + FOR_EACH_BB(bb) {
105831 + gimple_stmt_iterator gsi;
105832 +
105833 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
105834 + gimple stmt;
105835 +
105836 + stmt = gsi_stmt(gsi);
105837 +
105838 + if (is_gimple_call(stmt))
105839 + is_leaf = false;
105840 +
105841 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
105842 + if (!is_alloca(stmt))
105843 + continue;
105844 +
105845 + // 2. insert stack overflow check before each __builtin_alloca call
105846 + stackleak_check_alloca(&gsi);
105847 +
105848 + // 3. insert track call after each __builtin_alloca call
105849 + stackleak_add_instrumentation(&gsi);
105850 + if (bb == entry_bb)
105851 + prologue_instrumented = true;
105852 + }
105853 + }
105854 +
105855 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
105856 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
105857 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
105858 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
105859 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
105860 + return 0;
105861 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
105862 + return 0;
105863 +
105864 + // 4. insert track call at the beginning
105865 + if (!prologue_instrumented) {
105866 + gimple_stmt_iterator gsi;
105867 +
105868 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
105869 + if (dom_info_available_p(CDI_DOMINATORS))
105870 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
105871 + gsi = gsi_start_bb(bb);
105872 + stackleak_add_instrumentation(&gsi);
105873 + }
105874 +
105875 + return 0;
105876 +}
105877 +
105878 +static unsigned int execute_stackleak_final(void)
105879 +{
105880 + rtx insn, next;
105881 +
105882 + if (cfun->calls_alloca)
105883 + return 0;
105884 +
105885 + // keep calls only if function frame is big enough
105886 + if (get_frame_size() >= track_frame_size)
105887 + return 0;
105888 +
105889 + // 1. find pax_track_stack calls
105890 + for (insn = get_insns(); insn; insn = next) {
105891 + // 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))
105892 + rtx body;
105893 +
105894 + next = NEXT_INSN(insn);
105895 + if (!CALL_P(insn))
105896 + continue;
105897 + body = PATTERN(insn);
105898 + if (GET_CODE(body) != CALL)
105899 + continue;
105900 + body = XEXP(body, 0);
105901 + if (GET_CODE(body) != MEM)
105902 + continue;
105903 + body = XEXP(body, 0);
105904 + if (GET_CODE(body) != SYMBOL_REF)
105905 + continue;
105906 + if (strcmp(XSTR(body, 0), track_function))
105907 + continue;
105908 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
105909 + // 2. delete call
105910 + delete_insn_and_edges(insn);
105911 +#if BUILDING_GCC_VERSION >= 4007
105912 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
105913 + insn = next;
105914 + next = NEXT_INSN(insn);
105915 + delete_insn_and_edges(insn);
105916 + }
105917 +#endif
105918 + }
105919 +
105920 +// print_simple_rtl(stderr, get_insns());
105921 +// print_rtl(stderr, get_insns());
105922 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
105923 +
105924 + return 0;
105925 +}
105926 +
105927 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
105928 +{
105929 + const char * const plugin_name = plugin_info->base_name;
105930 + const int argc = plugin_info->argc;
105931 + const struct plugin_argument * const argv = plugin_info->argv;
105932 + int i;
105933 + struct register_pass_info stackleak_tree_instrument_pass_info = {
105934 + .pass = &stackleak_tree_instrument_pass.pass,
105935 +// .reference_pass_name = "tree_profile",
105936 + .reference_pass_name = "optimized",
105937 + .ref_pass_instance_number = 1,
105938 + .pos_op = PASS_POS_INSERT_BEFORE
105939 + };
105940 + struct register_pass_info stackleak_final_pass_info = {
105941 + .pass = &stackleak_final_rtl_opt_pass.pass,
105942 + .reference_pass_name = "final",
105943 + .ref_pass_instance_number = 1,
105944 + .pos_op = PASS_POS_INSERT_BEFORE
105945 + };
105946 +
105947 + if (!plugin_default_version_check(version, &gcc_version)) {
105948 + error(G_("incompatible gcc/plugin versions"));
105949 + return 1;
105950 + }
105951 +
105952 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
105953 +
105954 + for (i = 0; i < argc; ++i) {
105955 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
105956 + if (!argv[i].value) {
105957 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
105958 + continue;
105959 + }
105960 + track_frame_size = atoi(argv[i].value);
105961 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
105962 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
105963 + continue;
105964 + }
105965 + if (!strcmp(argv[i].key, "initialize-locals")) {
105966 + if (argv[i].value) {
105967 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
105968 + continue;
105969 + }
105970 + init_locals = true;
105971 + continue;
105972 + }
105973 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
105974 + }
105975 +
105976 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
105977 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
105978 +
105979 + return 0;
105980 +}
105981 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
105982 new file mode 100644
105983 index 0000000..4fae911
105984 --- /dev/null
105985 +++ b/tools/gcc/structleak_plugin.c
105986 @@ -0,0 +1,277 @@
105987 +/*
105988 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
105989 + * Licensed under the GPL v2
105990 + *
105991 + * Note: the choice of the license means that the compilation process is
105992 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
105993 + * but for the kernel it doesn't matter since it doesn't link against
105994 + * any of the gcc libraries
105995 + *
105996 + * gcc plugin to forcibly initialize certain local variables that could
105997 + * otherwise leak kernel stack to userland if they aren't properly initialized
105998 + * by later code
105999 + *
106000 + * Homepage: http://pax.grsecurity.net/
106001 + *
106002 + * Usage:
106003 + * $ # for 4.5/4.6/C based 4.7
106004 + * $ 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
106005 + * $ # for C++ based 4.7/4.8+
106006 + * $ 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
106007 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
106008 + *
106009 + * TODO: eliminate redundant initializers
106010 + * increase type coverage
106011 + */
106012 +
106013 +#include "gcc-plugin.h"
106014 +#include "config.h"
106015 +#include "system.h"
106016 +#include "coretypes.h"
106017 +#include "tree.h"
106018 +#include "tree-pass.h"
106019 +#include "intl.h"
106020 +#include "plugin-version.h"
106021 +#include "tm.h"
106022 +#include "toplev.h"
106023 +#include "function.h"
106024 +#include "tree-flow.h"
106025 +#include "plugin.h"
106026 +#include "gimple.h"
106027 +#include "diagnostic.h"
106028 +#include "cfgloop.h"
106029 +#include "langhooks.h"
106030 +
106031 +#if BUILDING_GCC_VERSION >= 4008
106032 +#define TODO_dump_func 0
106033 +#endif
106034 +
106035 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
106036 +
106037 +// unused type flag in all versions 4.5-4.8
106038 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
106039 +
106040 +int plugin_is_GPL_compatible;
106041 +void debug_gimple_stmt(gimple gs);
106042 +
106043 +static struct plugin_info structleak_plugin_info = {
106044 + .version = "201304082245",
106045 + .help = "disable\tdo not activate plugin\n",
106046 +};
106047 +
106048 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
106049 +{
106050 + *no_add_attrs = true;
106051 +
106052 + // check for types? for now accept everything linux has to offer
106053 + if (TREE_CODE(*node) != FIELD_DECL)
106054 + return NULL_TREE;
106055 +
106056 + *no_add_attrs = false;
106057 + return NULL_TREE;
106058 +}
106059 +
106060 +static struct attribute_spec user_attr = {
106061 + .name = "user",
106062 + .min_length = 0,
106063 + .max_length = 0,
106064 + .decl_required = false,
106065 + .type_required = false,
106066 + .function_type_required = false,
106067 + .handler = handle_user_attribute,
106068 +#if BUILDING_GCC_VERSION >= 4007
106069 + .affects_type_identity = true
106070 +#endif
106071 +};
106072 +
106073 +static void register_attributes(void *event_data, void *data)
106074 +{
106075 + register_attribute(&user_attr);
106076 +// register_attribute(&force_attr);
106077 +}
106078 +
106079 +static tree get_field_type(tree field)
106080 +{
106081 + return strip_array_types(TREE_TYPE(field));
106082 +}
106083 +
106084 +static bool is_userspace_type(tree type)
106085 +{
106086 + tree field;
106087 +
106088 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
106089 + tree fieldtype = get_field_type(field);
106090 + enum tree_code code = TREE_CODE(fieldtype);
106091 +
106092 + if (code == RECORD_TYPE || code == UNION_TYPE)
106093 + if (is_userspace_type(fieldtype))
106094 + return true;
106095 +
106096 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
106097 + return true;
106098 + }
106099 + return false;
106100 +}
106101 +
106102 +static void finish_type(void *event_data, void *data)
106103 +{
106104 + tree type = (tree)event_data;
106105 +
106106 + if (TYPE_USERSPACE(type))
106107 + return;
106108 +
106109 + if (is_userspace_type(type))
106110 + TYPE_USERSPACE(type) = 1;
106111 +}
106112 +
106113 +static void initialize(tree var)
106114 +{
106115 + basic_block bb;
106116 + gimple_stmt_iterator gsi;
106117 + tree initializer;
106118 + gimple init_stmt;
106119 +
106120 + // this is the original entry bb before the forced split
106121 + // TODO: check further BBs in case more splits occured before us
106122 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
106123 +
106124 + // first check if the variable is already initialized, warn otherwise
106125 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
106126 + gimple stmt = gsi_stmt(gsi);
106127 + tree rhs1;
106128 +
106129 + // we're looking for an assignment of a single rhs...
106130 + if (!gimple_assign_single_p(stmt))
106131 + continue;
106132 + rhs1 = gimple_assign_rhs1(stmt);
106133 +#if BUILDING_GCC_VERSION >= 4007
106134 + // ... of a non-clobbering expression...
106135 + if (TREE_CLOBBER_P(rhs1))
106136 + continue;
106137 +#endif
106138 + // ... to our variable...
106139 + if (gimple_get_lhs(stmt) != var)
106140 + continue;
106141 + // if it's an initializer then we're good
106142 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
106143 + return;
106144 + }
106145 +
106146 + // these aren't the 0days you're looking for
106147 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
106148 +
106149 + // build the initializer expression
106150 + initializer = build_constructor(TREE_TYPE(var), NULL);
106151 +
106152 + // build the initializer stmt
106153 + init_stmt = gimple_build_assign(var, initializer);
106154 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
106155 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
106156 + update_stmt(init_stmt);
106157 +}
106158 +
106159 +static unsigned int handle_function(void)
106160 +{
106161 + basic_block bb;
106162 + unsigned int ret = 0;
106163 + tree var;
106164 +
106165 +#if BUILDING_GCC_VERSION == 4005
106166 + tree vars;
106167 +#else
106168 + unsigned int i;
106169 +#endif
106170 +
106171 + // split the first bb where we can put the forced initializers
106172 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
106173 + if (dom_info_available_p(CDI_DOMINATORS))
106174 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
106175 +
106176 + // enumarate all local variables and forcibly initialize our targets
106177 +#if BUILDING_GCC_VERSION == 4005
106178 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
106179 + var = TREE_VALUE(vars);
106180 +#else
106181 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
106182 +#endif
106183 + tree type = TREE_TYPE(var);
106184 +
106185 + gcc_assert(DECL_P(var));
106186 + if (!auto_var_in_fn_p(var, current_function_decl))
106187 + continue;
106188 +
106189 + // only care about structure types
106190 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
106191 + continue;
106192 +
106193 + // if the type is of interest, examine the variable
106194 + if (TYPE_USERSPACE(type))
106195 + initialize(var);
106196 + }
106197 +
106198 + return ret;
106199 +}
106200 +
106201 +static struct gimple_opt_pass structleak_pass = {
106202 + .pass = {
106203 + .type = GIMPLE_PASS,
106204 + .name = "structleak",
106205 +#if BUILDING_GCC_VERSION >= 4008
106206 + .optinfo_flags = OPTGROUP_NONE,
106207 +#endif
106208 + .gate = NULL,
106209 + .execute = handle_function,
106210 + .sub = NULL,
106211 + .next = NULL,
106212 + .static_pass_number = 0,
106213 + .tv_id = TV_NONE,
106214 + .properties_required = PROP_cfg,
106215 + .properties_provided = 0,
106216 + .properties_destroyed = 0,
106217 + .todo_flags_start = 0,
106218 + .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
106219 + }
106220 +};
106221 +
106222 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
106223 +{
106224 + int i;
106225 + const char * const plugin_name = plugin_info->base_name;
106226 + const int argc = plugin_info->argc;
106227 + const struct plugin_argument * const argv = plugin_info->argv;
106228 + bool enable = true;
106229 +
106230 + struct register_pass_info structleak_pass_info = {
106231 + .pass = &structleak_pass.pass,
106232 + .reference_pass_name = "ssa",
106233 + .ref_pass_instance_number = 1,
106234 + .pos_op = PASS_POS_INSERT_AFTER
106235 + };
106236 +
106237 + if (!plugin_default_version_check(version, &gcc_version)) {
106238 + error(G_("incompatible gcc/plugin versions"));
106239 + return 1;
106240 + }
106241 +
106242 + if (strcmp(lang_hooks.name, "GNU C")) {
106243 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
106244 + enable = false;
106245 + }
106246 +
106247 + for (i = 0; i < argc; ++i) {
106248 + if (!strcmp(argv[i].key, "disable")) {
106249 + enable = false;
106250 + continue;
106251 + }
106252 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
106253 + }
106254 +
106255 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
106256 + if (enable) {
106257 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
106258 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
106259 + }
106260 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
106261 +
106262 + return 0;
106263 +}
106264 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
106265 index 6789d78..4afd019e 100644
106266 --- a/tools/perf/util/include/asm/alternative-asm.h
106267 +++ b/tools/perf/util/include/asm/alternative-asm.h
106268 @@ -5,4 +5,7 @@
106269
106270 #define altinstruction_entry #
106271
106272 + .macro pax_force_retaddr rip=0, reload=0
106273 + .endm
106274 +
106275 #endif
106276 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
106277 index 96b919d..c49bb74 100644
106278 --- a/tools/perf/util/include/linux/compiler.h
106279 +++ b/tools/perf/util/include/linux/compiler.h
106280 @@ -18,4 +18,12 @@
106281 #define __force
106282 #endif
106283
106284 +#ifndef __size_overflow
106285 +# define __size_overflow(...)
106286 +#endif
106287 +
106288 +#ifndef __intentional_overflow
106289 +# define __intentional_overflow(...)
106290 +#endif
106291 +
106292 #endif
106293 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
106294 index 302681c..3bde377 100644
106295 --- a/virt/kvm/kvm_main.c
106296 +++ b/virt/kvm/kvm_main.c
106297 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
106298
106299 static cpumask_var_t cpus_hardware_enabled;
106300 static int kvm_usage_count = 0;
106301 -static atomic_t hardware_enable_failed;
106302 +static atomic_unchecked_t hardware_enable_failed;
106303
106304 struct kmem_cache *kvm_vcpu_cache;
106305 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
106306
106307 -static __read_mostly struct preempt_ops kvm_preempt_ops;
106308 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
106309 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
106310 +static struct preempt_ops kvm_preempt_ops = {
106311 + .sched_in = kvm_sched_in,
106312 + .sched_out = kvm_sched_out,
106313 +};
106314
106315 struct dentry *kvm_debugfs_dir;
106316
106317 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
106318 /* We can read the guest memory with __xxx_user() later on. */
106319 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
106320 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
106321 - !access_ok(VERIFY_WRITE,
106322 + !__access_ok(VERIFY_WRITE,
106323 (void __user *)(unsigned long)mem->userspace_addr,
106324 mem->memory_size)))
106325 goto out;
106326 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
106327 return 0;
106328 }
106329
106330 -static struct file_operations kvm_vcpu_fops = {
106331 +static file_operations_no_const kvm_vcpu_fops __read_only = {
106332 .release = kvm_vcpu_release,
106333 .unlocked_ioctl = kvm_vcpu_ioctl,
106334 #ifdef CONFIG_COMPAT
106335 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
106336 return 0;
106337 }
106338
106339 -static struct file_operations kvm_vm_fops = {
106340 +static file_operations_no_const kvm_vm_fops __read_only = {
106341 .release = kvm_vm_release,
106342 .unlocked_ioctl = kvm_vm_ioctl,
106343 #ifdef CONFIG_COMPAT
106344 @@ -2662,7 +2667,7 @@ out:
106345 return r;
106346 }
106347
106348 -static struct file_operations kvm_chardev_ops = {
106349 +static file_operations_no_const kvm_chardev_ops __read_only = {
106350 .unlocked_ioctl = kvm_dev_ioctl,
106351 .compat_ioctl = kvm_dev_ioctl,
106352 .llseek = noop_llseek,
106353 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
106354
106355 if (r) {
106356 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
106357 - atomic_inc(&hardware_enable_failed);
106358 + atomic_inc_unchecked(&hardware_enable_failed);
106359 printk(KERN_INFO "kvm: enabling virtualization on "
106360 "CPU%d failed\n", cpu);
106361 }
106362 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
106363
106364 kvm_usage_count++;
106365 if (kvm_usage_count == 1) {
106366 - atomic_set(&hardware_enable_failed, 0);
106367 + atomic_set_unchecked(&hardware_enable_failed, 0);
106368 on_each_cpu(hardware_enable_nolock, NULL, 1);
106369
106370 - if (atomic_read(&hardware_enable_failed)) {
106371 + if (atomic_read_unchecked(&hardware_enable_failed)) {
106372 hardware_disable_all_nolock();
106373 r = -EBUSY;
106374 }
106375 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
106376 kvm_arch_vcpu_put(vcpu);
106377 }
106378
106379 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106380 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106381 struct module *module)
106382 {
106383 int r;
106384 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106385 if (!vcpu_align)
106386 vcpu_align = __alignof__(struct kvm_vcpu);
106387 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
106388 - 0, NULL);
106389 + SLAB_USERCOPY, NULL);
106390 if (!kvm_vcpu_cache) {
106391 r = -ENOMEM;
106392 goto out_free_3;
106393 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106394 if (r)
106395 goto out_free;
106396
106397 + pax_open_kernel();
106398 kvm_chardev_ops.owner = module;
106399 kvm_vm_fops.owner = module;
106400 kvm_vcpu_fops.owner = module;
106401 + pax_close_kernel();
106402
106403 r = misc_register(&kvm_dev);
106404 if (r) {
106405 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
106406
106407 register_syscore_ops(&kvm_syscore_ops);
106408
106409 - kvm_preempt_ops.sched_in = kvm_sched_in;
106410 - kvm_preempt_ops.sched_out = kvm_sched_out;
106411 -
106412 r = kvm_init_debug();
106413 if (r) {
106414 printk(KERN_ERR "kvm: create debugfs files failed\n");